Bump Microsoft.CodeAnalysis.Analyzers from 3.3.3 to 3.11.0 in /CSharp/TfsCmdlets #477
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
env: | |
Config: Release | |
Debug: ${{ false }} | |
SkipReleaseNotes: ${{ true }} | |
on: | |
pull_request: | |
branches: [ main ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
Build: | |
runs-on: windows-latest | |
env: | |
TFSCMDLETS_ACCESS_TOKEN: ${{ secrets.TFSCMDLETS_TOKEN }} | |
TFSCMDLETS_COLLECTION_URL: 'https://dev.azure.com/tfscmdlets' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: csharp | |
- name: Build module | |
id: build_module | |
shell: pwsh | |
run: | | |
./Build.ps1 -Targets Package -Config ${{ env.Config }} -Verbose:$${{ env.Debug }} -SkipReleaseNotes:$${{ env.SkipReleaseNotes }} | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action/windows@v2 | |
if: always() | |
with: | |
files: | | |
out\TestResults-Pester*.xml | |
- name: Publish Nuget | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nuget | |
path: "out/Nuget/*.nupkg" | |
- name: Publish Chocolatey | |
uses: actions/upload-artifact@v4 | |
with: | |
name: chocolatey | |
path: "out/Chocolatey/*.nupkg" | |
- name: Publish Portable | |
uses: actions/upload-artifact@v4 | |
with: | |
name: portable | |
path: "out/Portable/*.zip" | |
- name: Publish MSI | |
uses: actions/upload-artifact@v4 | |
with: | |
name: msi | |
path: "out/msi/*" | |
- name: Publish WinGet | |
uses: actions/upload-artifact@v4 | |
with: | |
name: winget | |
path: "out/winget/**" | |
- name: Publish Docs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: "out/docs/*.zip" | |
- name: Publish Release Notes | |
uses: actions/upload-artifact@v4 | |
with: | |
name: releasenotes | |
path: "docs/ReleaseNotes/**" | |
outputs: | |
BUILD_NAME: ${{ steps.build_module.outputs.BUILD_NAME }} | |
Staging: | |
runs-on: ubuntu-latest | |
environment: staging | |
needs: [ Build ] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BUILD_NAME: ${{ needs.Build.outputs.BUILD_NAME }} | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Extract release notes | |
id: extract_release_notes | |
shell: pwsh | |
run: | | |
$fileName = (Get-ChildItem [0-9]*.md -Recurse | Sort-Object Name | Select -ExpandProperty FullName -Last 1) | |
Write-Output $fileName | |
$releaseNotes = (Get-Content $fileName -Encoding UTF8 | Select-Object -Skip 4) | |
Write-Output $releaseNotes | |
Write-Output 'RELEASE_NOTES<<EOF' >> $env:GITHUB_OUTPUT | |
Write-Output $releaseNotes >> $env:GITHUB_OUTPUT | |
Write-Output 'EOF' >> $env:GITHUB_OUTPUT | |
- name: Create Draft Release | |
id: create_release | |
shell: pwsh | |
run: | | |
# Install module | |
Install-Module PowerShellForGitHub -Scope CurrentUser -Force | |
# Connect to GitHub | |
Set-GitHubConfiguration -SuppressTelemetryReminder -DefaultOwnerName igoravl -DefaultRepository tfscmdlets | |
$ghCreds = New-Object System.Management.Automation.PSCredential @( "pat", | |
(ConvertTo-SecureString -String $env:GITHUB_TOKEN -AsPlainText -Force) | |
) | |
Set-GitHubAuthentication -Credential $ghCreds -SessionOnly | |
# Remove stale draft releases | |
# TODO: Limit scope to this pull request (filter by PR name) | |
Get-GitHubRelease | Where-Object Draft -eq $true | Remove-GitHubRelease -Force | |
# Create new draft releases | |
$release = New-GitHubRelease -Tag 'v${{ env.BUILD_NAME }}' -Name 'Release ${{ env.BUILD_NAME }}' ` | |
-Draft -PreRelease:($env:BUILD_NAME -like '*-*') -commitish '${{ github.sha }}' -Body: @' | |
${{ steps.extract_release_notes.outputs.RELEASE_NOTES }} | |
'@ | |
# Upload assets | |
@('msi/TfsCmdlets*.msi', 'nuget/TfsCmdlets*.nupkg', 'portable/TfsCmdlets*.zip', 'docs/TfsCmdlets*.zip') ` | |
| ForEach-Object { New-GitHubReleaseAsset -Release $release.Id -Path $_ } | |
outputs: | |
BUILD_NAME: ${{ needs.Build.outputs.BUILD_NAME }} | |
RELEASE_NOTES: ${{ steps.extract_release_notes.outputs.RELEASE_NOTES }} | |
Release: | |
runs-on: ubuntu-latest | |
environment: production | |
needs: [ Staging ] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BUILD_NAME: ${{ needs.Staging.outputs.BUILD_NAME }} | |
steps: | |
- name: Promote release | |
id: promote_release | |
shell: pwsh | |
run: | | |
# Install module | |
Install-Module PowerShellForGitHub -Scope CurrentUser -Force | |
# Connect to GitHub | |
Set-GitHubConfiguration -SuppressTelemetryReminder -DefaultOwnerName igoravl -DefaultRepository tfscmdlets | |
Set-GitHubAuthentication -SessionOnly -Credential (New-Object System.Management.Automation.PSCredential @("pat", | |
(ConvertTo-SecureString -String $env:GITHUB_TOKEN -AsPlainText -Force))) | |
# Promote release | |
$rel = Get-GitHubRelease ` | |
| Where-Object { ($_.Draft -eq $true) -and ($_.Name -eq "Release $($env:BUILD_NAME)") } | |
Set-GitHubRelease -Release $rel.id -Draft:$false | |
Write-Output "RELEASE_URL=$($rel.html_url)" >> $env:GITHUB_OUTPUT | |
Write-Output "RELEASE_TAG=$($env:BUILD_NAME.Replace('+', '%2B'))" >> $env:GITHUB_OUTPUT | |
outputs: | |
BUILD_NAME: ${{ needs.Staging.outputs.BUILD_NAME }} | |
RELEASE_NOTES: ${{ needs.Staging.outputs.RELEASE_NOTES }} | |
RELEASE_URL: ${{ steps.promote_release.outputs.RELEASE_URL }} | |
RELEASE_TAG: ${{ steps.promote_release.outputs.RELEASE_TAG }} | |
Site: | |
runs-on: ubuntu-latest | |
needs: [ Release ] | |
env: | |
BUILD_NAME: ${{ needs.Release.outputs.BUILD_NAME }} | |
RELEASE_NOTES: ${{ needs.Release.outputs.RELEASE_NOTES }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
path: site | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: docs | |
- name: Publish site | |
run: | | |
cd site && mkdir docs && pushd docs | |
git checkout --track origin/gh-pages | |
unzip -o ../../TfsCmdlets-Docs-*.zip | |
popd | |
echo build_info: TfsCmdlets v${BUILD_NAME}, released $(date +%F) >> _config.yml | |
echo >> _config.yml | |
git config --local user.name "Igor Abade" | |
git config --local user.email [email protected] | |
git add * | |
git commit -m "Publish version $BUILD_NAME" | |
git push | |
PSGallery: | |
runs-on: ubuntu-latest | |
needs: [ Release ] | |
environment: psgallery | |
env: | |
RELEASE_NOTES: ${{ needs.Release.outputs.RELEASE_NOTES }} | |
PSGALLERY_KEY: ${{ secrets.API_KEY }} | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: portable | |
- name: Publish artifact | |
shell: pwsh | |
run: | | |
Install-Module PackageManagement -Scope CurrentUser -Force | |
Install-Module PowerShellGet -Scope CurrentUser -Force | |
Expand-Archive TfsCmdlets-Portable*.zip -DestinationPath Module/TfsCmdlets | |
$releaseNotes = $env:RELEASE_NOTES | |
Publish-Module -Name Module/TfsCmdlets -NuGetApiKey $env:PSGALLERY_KEY -AllowPreRelease -ReleaseNotes $releaseNotes | |
Nuget: | |
runs-on: ubuntu-latest | |
needs: [ Release ] | |
environment: nuget | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: nuget | |
- name: Install Nuget 5.x | |
uses: nuget/setup-nuget@v2 | |
with: | |
nuget-api-key: ${{ secrets.API_KEY }} | |
nuget-version: '5.x' | |
- name: Push package | |
run: | | |
nuget push $(ls TfsCmdlets*.nupkg) -Source https://api.nuget.org/v3/index.json | |
Chocolatey: | |
runs-on: windows-latest | |
needs: [ Release ] | |
environment: chocolatey | |
env: | |
CHOCO_KEY: ${{ secrets.API_KEY }} | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: chocolatey | |
- name: Install Chocolatey | |
shell: pwsh | |
run: | | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
- name: Push package | |
run: | | |
choco push $(ls TfsCmdlets*.nupkg) --api-key $env:CHOCO_KEY --source='https://push.chocolatey.org/' | |
WinGet: | |
runs-on: ubuntu-latest | |
needs: [ Release ] | |
environment: winget | |
env: | |
GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }} | |
BUILD_NAME: ${{ needs.Release.outputs.BUILD_NAME }} | |
steps: | |
- name: Clone winget-pkgs repository | |
shell: bash | |
run: | | |
git clone --single-branch --branch "master" "https://igoravl:[email protected]/igoravl/winget-pkgs.git" | |
cd winget-pkgs | |
git remote add upstream https://github.com/microsoft/winget-pkgs.git | |
git fetch upstream | |
git checkout -b "TfsCmdlets_$BUILD_NAME" | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: winget | |
path: winget-pkgs | |
- name: Push to wingets-pkgs repository | |
shell: bash | |
run: | | |
cd winget-pkgs | |
git config --local user.email "[email protected]" | |
git config --local user.name "Igor Abade" | |
git add manifests/i/Igoravl/TfsCmdlets/* | |
git commit -m "Release $BUILD_NAME" | |
git push -u origin "TfsCmdlets_$BUILD_NAME" | |
- name: Create pull request to microsoft/winget-pkgs | |
shell: pwsh | |
run: | | |
# Install module | |
Install-Module PowerShellForGitHub -Scope CurrentUser -Force | |
# Connect to GitHub | |
Set-GitHubConfiguration -SuppressTelemetryReminder -DefaultOwnerName igoravl -DefaultRepository winget-pkgs | |
Set-GitHubAuthentication -SessionOnly -Credential (New-Object System.Management.Automation.PSCredential @("pat", | |
(ConvertTo-SecureString -String $env:GITHUB_TOKEN -AsPlainText -Force))) | |
# Create pull request | |
New-GitHubPullRequest -OwnerName Microsoft -RepositoryName winget-pkgs ` | |
-Title "TfsCmdlets_$env:BUILD_NAME" -Head "igoravl:TfsCmdlets_$env:BUILD_NAME" -base master -Body @' | |
- [x] Have you signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs)? | |
- [x] Have you checked that there aren't other open [pull requests](https://github.com/microsoft/winget-pkgs/pulls) for the same manifest update/change? | |
- [x] Have you validated your manifest locally with `winget validate --manifest <path>`? | |
- [x] Have you tested your manifest locally with `winget install --manifest <path>`? | |
- [x] Does your manifest conform to the [1.0 schema](https://github.com/microsoft/winget-cli/blob/master/doc/ManifestSpecv1.0.md)? | |
Note: `<path>` is the name of the directory containing the manifest you're submitting. | |
----- | |
'@ | |
Announcements: | |
runs-on: ubuntu-latest | |
needs: [ Release, Nuget, PSGallery, Chocolatey, Site, WinGet ] | |
environment: announcements | |
steps: | |
- name: No-op | |
shell: bash | |
run: echo "Announcements are temporarily disabled." | |
# - name: Tweet | |
# id: tweet | |
# uses: snow-actions/[email protected] | |
# env: | |
# BUILD_NAME: ${{ needs.Release.outputs.BUILD_NAME }} | |
# CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} | |
# CONSUMER_API_SECRET_KEY: ${{ secrets.TWITTER_CONSUMER_API_SECRET_KEY }} | |
# ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | |
# ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} | |
# RELEASE_TAG: ${{ needs.Release.outputs.RELEASE_TAG }} | |
# with: | |
# status: | | |
# TfsCmdlets version ${{ env.BUILD_NAME }} has just been released. Check it out! https://github.com/igoravl/TfsCmdlets/releases/tag/v${{ env.RELEASE_TAG }} |