Update Marketplace Package to better version number (#2209) #186
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 & Release (Azure DevOps Migration Tools) | |
permissions: | |
contents: read | |
pull-requests: write | |
on: | |
push: | |
branches: ["main"] | |
tags-ignore: ["v*-*"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
# Setup & Configuration | |
Setup: | |
name: "Setup & Configuration " | |
runs-on: ubuntu-latest | |
outputs: | |
GitVersion_BranchName: ${{ steps.gitversion.outputs.GitVersion_BranchName }} | |
GitVersion_SemVer: ${{ steps.gitversion.outputs.GitVersion_SemVer }} | |
GitVersion_PreReleaseLabel: ${{ steps.gitversion.outputs.GitVersion_PreReleaseLabel }} | |
GitVersion_AssemblySemVer: ${{ steps.gitversion.outputs.GitVersion_AssemblySemVer }} | |
GitVersion_InformationalVersion: ${{ steps.gitversion.outputs.GitVersion_InformationalVersion }} | |
GitVersion_NuGetVersion: ${{ steps.gitversion.outputs.GitVersion_NuGetVersion }} | |
GitVersion_PreReleaseNumber: ${{ steps.gitversion.outputs.GitVersion_PreReleaseNumber }} | |
GitVersion_MajorMinorPatch: ${{ steps.gitversion.outputs.GitVersion_MajorMinorPatch }} | |
HasChanged_src: ${{ steps.filter.outputs.src }} | |
HasChanged_docs: ${{ steps.filter.outputs.docs }} | |
HasChanged_automation: ${{ steps.filter.outputs.automation }} | |
nkdAgility_Ring: ${{ steps.nkdagility.outputs.Ring }} | |
nkdAgility_WingetApplicationId: ${{ steps.nkdagility.outputs.WingetApplicationId }} | |
nkdAgility_IsBuildEditBranch: ${{ steps.nkdagility.outputs.IsBuildEditBranch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
includePrerelease: true | |
- name: Execute GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
src: | |
- 'src/**' | |
docs: | |
- 'docs/**' | |
automation: | |
- 'build/**' | |
- '.github/workflows/**' | |
- name: "Build NKDAgility Outputs" | |
shell: pwsh | |
id: nkdagility | |
run: | | |
$Ring = "Canary" | |
$WingetApplicationId = "nkdagility.azure-devops-migration-tools" | |
switch ($Env:GitVersion_PreReleaseLabel) { | |
"" { | |
$Ring = "Release"; | |
$WingetApplicationId = "nkdagility.azure-devops-migration-tools"; | |
} | |
"Preview" { | |
$Ring = "Preview"; | |
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Preview"; | |
} | |
default { | |
$Ring = "Canary"; | |
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Canary"; | |
} | |
} | |
Write-Output "We are running for the $Ring Ring!" | |
Write-Output "We are focused on Winget ID $WingetApplicationId!" | |
echo "Ring=$Ring" >> $env:GITHUB_OUTPUT | |
echo "WingetApplicationId=$WingetApplicationId" >> $env:GITHUB_OUTPUT | |
$IsBuildEditBranch = $false; | |
if (("${{ github.ref_name }}").contains("build/")) { | |
$IsBuildEditBranch = $true; | |
} | |
Write-Output "IsBuildEditBranch=$IsBuildEditBranch" | |
echo "IsBuildEditBranch=$IsBuildEditBranch" >> $env:GITHUB_OUTPUT | |
# Setup Validator | |
SetupSummeryStage: | |
name: "Build Run Data" | |
runs-on: ubuntu-latest | |
needs: Setup | |
steps: | |
- name: "Create Summery" | |
if: always() | |
shell: pwsh | |
id: nkdagility-summery | |
run: | | |
$markdown = @" | |
## ${{needs.Setup.outputs.GitVersion_SemVer}} (${{needs.Setup.outputs.nkdAgility_Ring}}) | |
### NKDAgility | |
- nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}} | |
- nkdAgility_IsBuildEditBranch: ${{needs.Setup.outputs.nkdAgility_IsBuildEditBranch}} | |
- nkdAgility_WingetApplicationId: ${{needs.Setup.outputs.nkdAgility_WingetApplicationId}} | |
### GitVersion | |
- GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}} | |
- GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}} | |
- GitVersion_PreReleaseLabel: ${{needs.Setup.outputs.GitVersion_PreReleaseLabel}} | |
- GitVersion_AssemblySemVer: ${{needs.Setup.outputs.GitVersion_AssemblySemVer}} | |
- GitVersion_InformationalVersion: ${{needs.Setup.outputs.GitVersion_InformationalVersion}} | |
- GitVersion_NuGetVersion: ${{needs.Setup.outputs.GitVersion_NuGetVersion}} | |
### Has Changed | |
- HasChanged_src: ${{needs.Setup.outputs.HasChanged_src}} | |
- HasChanged_docs: ${{needs.Setup.outputs.HasChanged_docs}} | |
- HasChanged_automation: ${{needs.Setup.outputs.HasChanged_automation}} | |
"@ | |
echo $markdown >> $Env:GITHUB_STEP_SUMMARY | |
# Build, Test, Sonar Cloud Analysis, & Package | |
build: | |
name: "Build, Test, Sonar Cloud Analysis, & Package" | |
runs-on: windows-latest | |
needs: Setup | |
if: ${{ needs.Setup.outputs.HasChanged_src }} | |
env: | |
solution: '**/*.sln' | |
buildPlatform: 'Any CPU' | |
buildConfiguration: 'Release' | |
nkdAgility_Ring: ${{ needs.Setup.outputs.nkdAgility_Ring }} | |
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }} | |
GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }} | |
GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }} | |
GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }} | |
GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }} | |
GitVersion_PreReleaseNumber: ${{ needs.Setup.outputs.GitVersion_PreReleaseNumber }} | |
GitVersion_MajorMinorPatch: ${{ needs.Setup.outputs.GitVersion_MajorMinorPatch }} | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: cschleiden/replace-tokens@v1 | |
with: | |
files: '["**/StaticVariables.cs"]' | |
tokenPrefix: "${" | |
tokenSuffix: "}" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: AzureDevOpsMigrationTools-BuildScripts | |
path: ./build/** | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
8.x | |
- name: "Find solution files" | |
shell: pwsh | |
run: | | |
Get-Item -Path .\ | |
Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName } | |
- run: dotnet tool install --global dotnet-sonarscanner | |
- run: dotnet sonarscanner begin | |
/o:"nkdagility" | |
/k:"vsts-sync-migrator:master" | |
/d:sonar.host.url="https://sonarcloud.io" | |
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
- run: dotnet build MigrationTools.sln /p:Version=${{ env.GitVersion_SemVer }} /p:FileVersion=${{ env.GitVersion_AssemblySemVer }} /p:InformationalVersion=${{ env.GitVersion_InformationalVersion }} /p:GitVersionTag=${{ env.GitVersion_PreReleaseLabel }} | |
name: Build MigrationTools.sln | |
id: Build | |
- run: dotnet test "MigrationTools.sln" --results-directory ".\test-results\" --logger trx --collect "Code coverage" --no-build --filter "(TestCategory=L0|TestCategory=L1)" | |
- run: dotnet test "MigrationTools.sln" --results-directory ".\test-results\" --logger trx --collect "Code coverage" --no-build --filter "(TestCategory=L2|TestCategory=L3)" | |
- run: dotnet test "MigrationTools.sln" --results-directory ".\test-results\" --logger trx --collect "Code coverage" --no-build --filter "(TestCategory!=L0&TestCategory!=L1&TestCategory!=L2&TestCategory!=L3)" | |
- run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
- name: "Package Executable Files" | |
id: packageExecutable | |
shell: pwsh | |
if: ${{ steps.Build.outcome == 'success' }} | |
run: | | |
./build/packageExecutable.ps1 -version ${{ env.GitVersion_SemVer }} -outfolder "./staging" | |
- name: "Package Chocolatey Files" | |
shell: pwsh | |
if: ${{ steps.packageExecutable.outcome == 'success' }} | |
run: | | |
$item = Get-ChildItem -Path ./staging/ -Recurse -Filter 'MigrationTools-${{ env.GitVersion_SemVer }}.zip' | Select-Object -First 1 | |
Write-Output "Found: $item.FullName" | |
.\build\packageChocolatey.ps1 -SemVer ${{ env.GitVersion_SemVer }} -NuGetVersion ${{ env.GitVersion_NuGetVersion }} -outfolder "./staging" -migrationToolsFilename $item.FullName | |
- name: "Package Extension Files" | |
shell: pwsh | |
if: ${{ steps.Build.outcome == 'success' }} | |
run: | | |
.\build\packageExtension.ps1 -version ${{ env.GitVersion_AssemblySemVer }} -outfolder "./staging" | |
- name: "List Package Files" | |
shell: pwsh | |
if: ${{ steps.Build.outcome == 'success' }} | |
run: | | |
Get-ChildItem -Path ./staging/ -Recurse | ForEach-Object { $_.FullName } | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: AzureDevOpsMigrationTools-Packages | |
path: ./staging/** | |
# Build Docs | |
BuildDocs: | |
name: "Build Documentation output" | |
runs-on: ubuntu-latest | |
needs: [Setup] | |
env: | |
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }} | |
GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }} | |
GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cschleiden/replace-tokens@v1 | |
with: | |
files: '["**/*.html"]' | |
tokenPrefix: "${" | |
tokenSuffix: "}" | |
- uses: igsekor/[email protected] | |
id: spellcheck | |
name: Spellcheck | |
- name: Build Jekyll | |
uses: jerryjvl/jekyll-build-action@v1 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: AzureDevOpsMigrationTools-Site | |
path: ./_site/**/* | |
# GitHubRelease | |
GitHubRelease: | |
name: "Release to GitHub Releases" | |
runs-on: ubuntu-latest | |
env: | |
nkdAgility_Ring: ${{ needs.Setup.outputs.nkdAgility_Ring }} | |
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }} | |
GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }} | |
GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }} | |
GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }} | |
GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }} | |
HasChanged_src: ${{ needs.Setup.outputs.HasChanged_src }} | |
HasChanged_docs: ${{ needs.Setup.outputs.HasChanged_docs }} | |
HasChanged_automation: ${{ needs.Setup.outputs.HasChanged_automation }} | |
needs: [build, Setup] | |
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: AzureDevOpsMigrationTools-Packages | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }} | |
private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} | |
- name: "Package Files" | |
shell: pwsh | |
run: | | |
Get-ChildItem -Path .\ -Recurse | ForEach-Object { $_.FullName } | |
- name: "Release options" | |
id: release-options | |
shell: pwsh | |
run: | | |
if ($Env:nkdAgility_Ring -ne 'Canary' && ($Env:HasChanged_src || $Env:HasChanged_docs )) { | |
echo "discussion_category_name=Anouncement" >> $env:GITHUB_OUTPUT | |
} | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
MigrationTools-*.zip | |
nkdAgility.vsts-sync-migration-*.vsix | |
vsts-sync-migrator.*.nupkg | |
generate_release_notes: true | |
tag_name: v${{ needs.Setup.outputs.GitVersion_SemVer }} | |
name: v${{ needs.Setup.outputs.GitVersion_SemVer }} (${{ needs.Setup.outputs.nkdAgility_Ring }}) | |
token: ${{ steps.app-token.outputs.token }} | |
prerelease: ${{ needs.Setup.outputs.nkdAgility_Ring != 'Release' }} | |
discussion_category_name: ${{ steps.release-options.outputs.discussion_category_name }} | |
draft: ${{ needs.Setup.outputs.nkdAgility_Ring == 'Canary' }} | |
body: | | |
## Azure DevOps Migration Tools v${{ needs.Setup.outputs.GitVersion_SemVer }} | |
Version: ${{ needs.Setup.outputs.GitVersion_SemVer }} | |
Ring: (${{ needs.Setup.outputs.nkdAgility_Ring }}) | |
## Get the tools | |
- Download the [MigrationTools-${{ needs.Setup.outputs.GitVersion_SemVer }}.zip](https://github.com/nkdAgility/azure-devops-migration-tools/releases/download/v${{ needs.Setup.outputs.GitVersion_SemVer }}/MigrationTools-${{ needs.Setup.outputs.GitVersion_SemVer }}.zip) file below | |
- Install with Winget with `winget install ${{needs.Setup.outputs.nkdAgility_WingetApplicationId}} --version ${{ needs.Setup.outputs.GitVersion_SemVer }}` . There is a delay for aprovals on the winget store, so you may need to wait a few days before this is available. | |
- Install with Chocolatey with `choco install nkdagility.azure-devops-migration-tools --version ${{ needs.Setup.outputs.GitVersion_NuGetVersion }}`. There is a delay for aprovals on the chocolatey store, so you may need to wait a few hours before this is available. | |
append_body: true | |
# ElmahDeployment | |
ElmahDeployemnt: | |
name: "Create Elmah.io Deployment" | |
runs-on: ubuntu-latest | |
env: | |
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }} | |
needs: [GitHubRelease, Setup] | |
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) }} | |
steps: | |
- name: Create Deployment on elmah.io | |
uses: elmahio/github-create-deployment-action@v1 | |
with: | |
apiKey: ${{ secrets.ELMAH_IO_API_KEY }} | |
version: ${{ needs.Setup.outputs.GitVersion_SemVer }} | |
logId: ${{ secrets.ELMAH_IO_LOG_ID }} | |
# Release to Marketplace | |
MarketplaceRelease: | |
name: "Release to Marketplace" | |
runs-on: ubuntu-latest | |
needs: [Setup, GitHubRelease] | |
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.HasChanged_src) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v4 | |
- name: "Find files" | |
shell: pwsh | |
run: | | |
Get-Item -Path .\ | |
Write-Output "Build Files" | |
Get-ChildItem -Path .\ -Recurse -Filter '*.ps1' | ForEach-Object { $_.FullName } | |
- name: "Marketplace" | |
shell: pwsh | |
run: | | |
$vsixFile = Get-ChildItem -Path .\ -Recurse -Filter '*.vsix' | |
if ($vsixFile -eq $null) { | |
Write-Output "No VSIX file found" | |
exit 1 | |
} else { | |
Write-Output $"Running with {$vsixFile}" | |
} | |
.\build\releaseExtension.ps1 -vsixFile $vsixFile.FullName -marketplaceToken ${{ secrets.VS_MARKET_TOKEN }} | |
# Release to Chocolatey | |
ChocolateyRelease: | |
name: "Release to Chocolatey" | |
runs-on: windows-latest | |
needs: [Setup, GitHubRelease] | |
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.HasChanged_src) }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: AzureDevOpsMigrationTools-Packages | |
- name: "Choco" | |
shell: pwsh | |
run: | | |
$chocoFile = Get-ChildItem -Path .\ -Recurse -Filter 'vsts-sync-migrator.${{ needs.Setup.outputs.GitVersion_NuGetVersion }}.nupkg' | |
if ($chocoFile -eq $null) { | |
Write-Output "No Choco file found" | |
exit 1 | |
} else { | |
Write-Output $"Running with {$chocoFile}" | |
} | |
Write-Output 'choco push "$chocoFile" --key "${{ secrets.CHOCO_APIKEY }}" --source "https://push.chocolatey.org/"' | |
choco push "$chocoFile" --key "${{ secrets.CHOCO_APIKEY }}" --source "https://push.chocolatey.org/" | |
# Release to Winget | |
WingetRelease: | |
name: "Release to Winget" | |
runs-on: windows-latest | |
needs: [Setup, GitHubRelease] | |
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.HasChanged_src) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v4 | |
- name: "Find files" | |
shell: pwsh | |
run: | | |
Get-Item -Path .\ | |
Write-Output "Build Files" | |
Get-ChildItem -Path .\ -Recurse -Filter '*.ps1' | ForEach-Object { $_.FullName } | |
- name: "Winget Release" | |
shell: pwsh | |
run: | | |
.\build\releaseWingetPackage.ps1 -version ${{ needs.Setup.outputs.GitVersion_SemVer }} -ring ${{needs.Setup.outputs.nkdAgility_Ring}} -GH_TOKEN ${{ secrets.NKD_MRHINSH_TOKEN }} | |
# Release to Docs | |
DocsRelease: | |
name: "Release to Docs" | |
runs-on: ubuntu-latest | |
needs: [Setup, BuildDocs, GitHubRelease] | |
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) }} | |
steps: | |
- name: Download a single artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: AzureDevOpsMigrationTools-Site | |
path: ./_site | |
- name: "Find files" | |
shell: pwsh | |
run: | | |
Get-Item -Path .\ | |
- name: "Folder Desider" | |
id: Folder-Decision | |
shell: pwsh | |
run: | | |
if ($Env:nkdAgility_Ring -ne 'Release') { | |
echo "subfolder=$Env:nkdAgility_Ring" >> $env:GITHUB_OUTPUT | |
Write-Output "subfolder=$Env:nkdAgility_Ring" | |
} else { | |
Write-Output "subfolder=" | |
} | |
- name: SFTP Upload ${{ (needs.Setup.outputs.nkdAgility_Ring) }} | |
uses: Dylan700/[email protected] | |
with: | |
server: nakedalmweb.sftp.wpengine.com | |
username: nakedalmweb-learn | |
password: ${{ secrets.NKDAGILITY_LEARN_SFTP }} | |
port: 2222 | |
# If true, outputs the results of the upload, without actually uploading. | |
dry-run: ${{ (needs.Setup.outputs.nkdAgility_Ring) == 'Canary' }} | |
# A list of folders to upload in the format of `folder/ => upload_folder/` | |
uploads: | | |
./_site/ => ./azure-devops-migration-tools/${{ steps.Folder-Decision.outputs.subfolder }} | |
# If true, any existing files in the remote upload directories are deleted. | |
delete: false |