From b70413c6731d5932354ac61ab5f7257c4f65022f Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Thu, 11 Jul 2024 13:13:59 +0100 Subject: [PATCH] Feature/move to GitHub actions Part 1 (#2136) Started the move to GitHub Actions. Build and package is there, but release is still in Azur eDevOps --- .github/release.yml | 13 + .github/workflows/build-docs.yml | 109 ------- .github/workflows/main.yml | 282 ++++++++++++++++++ .gitignore | 1 + AzureDevOps.yaml | 197 ------------ MigrationTools.sln | 32 +- build/azure-pipeline.yml | 9 +- build/build.ps1 | 7 +- build/changelogs.ps1 | 11 + build/packageChocolatey.ps1 | 13 +- build/packageExecutable.ps1 | 82 +++-- build/packageExtension.ps1 | 26 +- .../MigrationTools.Host.csproj | 4 +- .../VstsSyncMigrator.Core.csproj | 2 +- 14 files changed, 430 insertions(+), 358 deletions(-) create mode 100644 .github/release.yml delete mode 100644 .github/workflows/build-docs.yml create mode 100644 .github/workflows/main.yml delete mode 100644 AzureDevOps.yaml create mode 100644 build/changelogs.ps1 diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..dfc7dacf3 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,13 @@ +# .github/release.yml + +changelog: + categories: + - title: 🏕 Features + labels: + - '*' + exclude: + labels: + - dependencies + - title: 👒 Dependencies + labels: + - dependencies diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml deleted file mode 100644 index 4d1a13146..000000000 --- a/.github/workflows/build-docs.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Build Docs - -on: - # Runs on pushes targeting the default branch - push: - branches: ["master"] - pull_request: - branches: - - master - - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: write - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - # Build job - build: - outputs: - version: ${{ steps.gitversion.outputs.semVer }} - environment: - name: nakedalmweb-githubSDK - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0 - with: - versionSpec: '5.x' - - name: Display GitVersion config - id: gitversion # id to later be referenced - uses: gittools/actions/gitversion/execute@v0 - - uses: cschleiden/replace-tokens@v1 - with: - files: '["**/*.html"]' - tokenPrefix: "${" - tokenSuffix: "}" - - uses: igsekor/pyspelling-any@v1.0.4 - id: spellcheck - name: Spellcheck - - name: Build Jekyll - uses: jerryjvl/jekyll-build-action@v1 - - uses: actions/upload-artifact@v3 - with: - name: _site - path: ./_site/**/* - - publish: - environment: - name: nakedalmweb-githubAzDo - needs: [build] - if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest - steps: - - name: Download a single artifact - uses: actions/download-artifact@v3 - with: - name: _site - path: ./_site - - name: SFTP Upload - # You may pin to the exact commit or the version. - # uses: Dylan700/sftp-upload-action@f90db607d9fe1acdc0eefccee84d37c119b268fe - uses: Dylan700/sftp-upload-action@v1.1.4 - with: - server: nakedalmweb.sftp.wpengine.com - username: nakedalmweb-learn - password: ${{ secrets.SFTP_PASSWORD }} - port: 2222 - # If true, outputs the results of the upload, without actually uploading. - dry-run: false - # A list of folders to upload in the format of `folder/ => upload_folder/` - uploads: | - ./_site/ => ./azure-devops-migration-tools - # If true, any existing files in the remote upload directories are deleted. - delete: true - - -# release: -# environment: -# name: nakedalmweb-githubSDK -# needs: [publish, build] -# if: github.ref == 'refs/heads/master' -# runs-on: ubuntu-latest -# steps: -# - name: Checkout -# uses: actions/checkout@v3 -# with: -# fetch-depth: 0 -# - name: Tag with v${{needs.build.outputs.version}} -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token -# run: | -# git tag v${{needs.build.outputs.version}} -# git push origin --tags -# gh release create v${{needs.build.outputs.version}} --generate-notes --latest \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..1d313155d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,282 @@ +name: Build & Release (Azure DevOps Migration Tools) + +on: + push: + workflow_dispatch: + +env: + APP_ID: "Iv23li9aYvt0VW9x4Jhh" + PRIVATE_KEY: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} + +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 }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v1.1.1 + with: + versionSpec: '5.x' + includePrerelease: true + - name: Execute GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v1.1.1 + with: + useConfigFile: true + + # Setup Validator + SetupValidatorStage: + name: "Setup Validator" + runs-on: ubuntu-latest + needs: Setup + steps: + - name: "Release WorkItemClone" + shell: pwsh + run: | + Write-Output "GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}}" + Write-Output "GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}}" + Write-Output "GitVersion_PreReleaseLabel: ${{needs.Setup.outputs.GitVersion_PreReleaseLabel}}" + Write-Output "GitVersion_AssemblySemVer: ${{needs.Setup.outputs.GitVersion_AssemblySemVer}}" + Write-Output "GitVersion_InformationalVersion: ${{needs.Setup.outputs.GitVersion_InformationalVersion}}" + + # Build, Test, Sonar Cloud Analysis, & Package + build: + name: "Build, Test, Sonar Cloud Analysis, & Package" + runs-on: windows-latest + needs: Setup + env: + solution: '**/*.sln' + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' + 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 }} + steps: + # - name: Setup NuGet + # uses: NuGet/setup-nuget@v1.0.2 + # - name: Restore NuGet Packages + # run: nuget restore MigrationTools.sln + # - name: Build and Publish Web App + # run: msbuild MigrationTools.sln + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'zulu' + - name: Checkout + uses: actions/checkout@v2 + - 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_AssemblySemVer }} /p:FileVersion=${{ env.GitVersion_AssemblySemVer }} /p:InformationalVersion=${{ env.GitVersion_InformationalVersion }} + 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/pyspelling-any@v1.0.4 + 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 (Not Migrated)" + runs-on: ubuntu-latest + env: + 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 }} + needs: [build, Setup] + if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }} + steps: + - uses: actions/download-artifact@v4 + with: + name: AzureDevOpsMigrationTools-Packages + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ env.APP_ID }} + private-key: ${{ env.PRIVATE_KEY }} + - name: "Package Files" + shell: pwsh + run: | + Get-ChildItem -Path .\ -Recurse | ForEach-Object { $_.FullName } + - 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: Azure DevOps Migration Tools v${{ needs.Setup.outputs.GitVersion_SemVer }} + token: ${{ steps.app-token.outputs.token }} + prerelease: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' }} + discussion_category_name: "Anouncement" + + # Release to Marketplace + MarketplaceRelease: + name: "Release to Marketplace (Not Migrated)" + runs-on: ubuntu-latest + needs: [Setup, GitHubRelease] + if: ${{ false }} + #if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }} + steps: + - uses: actions/download-artifact@v4 + with: + name: AzureDevOpsMigrationTools-Packages + - name: "Find solution files" + shell: pwsh + run: | + Get-Item -Path .\ + Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName } + + # Release to Chocolatey + ChocolateyRelease: + name: "Release to Chocolatey (Not Migrated)" + runs-on: ubuntu-latest + needs: [Setup, GitHubRelease] + if: ${{ false }} + #if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }} + steps: + - uses: actions/download-artifact@v4 + with: + name: AzureDevOpsMigrationTools-Packages + - name: "Find solution files" + shell: pwsh + run: | + Get-Item -Path .\ + Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName } + + # Release to Winget + WingetRelease: + name: "Release to Winget (Not Migrated)" + runs-on: ubuntu-latest + needs: [Setup, GitHubRelease] + if: ${{ false }} + #if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }} + steps: + - uses: actions/download-artifact@v4 + with: + name: AzureDevOpsMigrationTools-Packages + - name: "Find solution files" + shell: pwsh + run: | + Get-Item -Path .\ + Get-ChildItem -Path .\ -Recurse -Filter '*.sln' | ForEach-Object { $_.FullName } + + # Release to Docs + DocsRelease: + name: "Release to Docs" + runs-on: ubuntu-latest + needs: [BuildDocs, GitHubRelease] + if: ${{ false }} + #if: ${{ success() && ( needs.Setup.outputs.GitVersion_PreReleaseLabel == 'Preview' || needs.Setup.outputs.GitVersion_PreReleaseLabel == '' ) }} + steps: + - name: Download a single artifact + uses: actions/download-artifact@v3 + with: + name: AzureDevOpsMigrationTools-Site + path: ./_site + - name: "Find files" + shell: pwsh + run: | + Get-Item -Path .\ + - name: SFTP Upload + # You may pin to the exact commit or the version. + # uses: Dylan700/sftp-upload-action@f90db607d9fe1acdc0eefccee84d37c119b268fe + uses: Dylan700/sftp-upload-action@v1.1.4 + with: + server: nakedalmweb.sftp.wpengine.com + username: nakedalmweb-learn + password: ${{ secrets.SFTP_PASSWORD }} + port: 2222 + # If true, outputs the results of the upload, without actually uploading. + dry-run: false + # A list of folders to upload in the format of `folder/ => upload_folder/` + uploads: | + ./_site/ => ./azure-devops-migration-tools + # If true, any existing files in the remote upload directories are deleted. + delete: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 548b40b9e..9edfb8da0 100644 --- a/.gitignore +++ b/.gitignore @@ -164,3 +164,4 @@ docs/Reference/Generated/MigrationTools.Host.xml /docs/.obsidian /output/ logs/ +/staging/ diff --git a/AzureDevOps.yaml b/AzureDevOps.yaml deleted file mode 100644 index 5ee160008..000000000 --- a/AzureDevOps.yaml +++ /dev/null @@ -1,197 +0,0 @@ -# 'Allow scripts to access the OAuth token' was selected in pipeline. Add the following YAML to any steps requiring access: -# env: -# MY_ACCESS_TOKEN: $(System.AccessToken) -# Variable 'agent.diagnostic' was defined in the Variables tab -# Variable 'azuredevopsToken' was defined in the Variables tab -# Variable 'githubToken' was defined in the Variables tab -# Variable 'wingetPAT' was defined in the Variables tab -trigger: - branches: - include: - - refs/heads/master - - refs/heads/preview - - paths: - exclude: - - /.github/* - - /docs/* - -name: $(GITVERSION_SemVer) -jobs: -- job: Build - displayName: Build - cancelTimeoutInMinutes: 1 - pool: - vmImage: windows-latest - steps: - - checkout: self - fetchTags: true - persistCredentials: True - - task: gittools.gittools.setup-gitversion-task.gitversion/setup@0 - displayName: gitversion/setup - inputs: - versionSpec: 5.x - - task: gitversion/execute@0 - inputs: - useConfigFile: true - configFilePath: 'GitVersion.yml' - updateAssemblyInfo: true - - task: UseDotNet@2 - displayName: Use .NET Core sdk 7.x - inputs: - version: 7.x - - task: DotNetCoreCLI@2 - displayName: dotnet restore - inputs: - command: restore - projects: '**/*.sln' - - task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1 - displayName: Prepare analysis on SonarCloud - continueOnError: True - inputs: - SonarCloud: f98e494c-4566-47a7-9d9d-5c39533c2ff4 - organization: nkdagility - projectKey: vsts-sync-migrator:master - projectName: vsts-sync-migrator - projectVersion: $(GITVERSION.SemVer) - - task: DotNetCoreCLI@2 - displayName: dotnet build - inputs: - arguments: -c $(BuildConfiguration) --no-restore /p:Version=$(GitVersion.AssemblySemVer) - - task: DotNetCoreCLI@2 - displayName: dotnet test (L0 & L1) - continueOnError: True - inputs: - command: test - projects: '**/*Tests/*.csproj' - arguments: -c $(BuildConfiguration) --collect "Code coverage" --no-build --filter (TestCategory=L0|TestCategory=L1) - testRunTitle: $(GitVersion.SemVer) - - task: DotNetCoreCLI@2 - displayName: dotnet test (L2 & L3) - continueOnError: True - inputs: - command: test - projects: '**/*Tests/*.csproj' - arguments: -c $(BuildConfiguration) --collect "Code coverage" --no-build --filter (TestCategory=L2|TestCategory=L3) - testRunTitle: $(GitVersion.SemVer) - - task: DotNetCoreCLI@2 - displayName: dotnet test (L?) - tests with No Catagory - continueOnError: True - inputs: - command: test - projects: '**/*Tests/*.csproj' - arguments: -c $(BuildConfiguration) --collect "Code coverage" --no-build --filter (TestCategory!=L0&TestCategory!=L1&TestCategory!=L2&TestCategory!=L3) - testRunTitle: $(GitVersion.SemVer) - - task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@1 - displayName: Run Code Analysis - continueOnError: True - - task: PublishSymbols@2 - name: PublishSymbols_7 - displayName: 'Publish symbols path: ' - continueOnError: True - inputs: - SymbolsFolder: '' - SearchPattern: '**\bin\**\*.pdb' - SymbolServerType: TeamServices - SymbolsMaximumWaitTime: 5 - - task: CopyFiles@2 - displayName: 'Copy : ConsoleFull' - inputs: - SourceFolder: $(Build.SourcesDirectory)\src\MigrationTools.ConsoleFull\bin\Release\net472\ - TargetFolder: $(Build.ArtifactStagingDirectory)/MigrationTools/ - - task: CopyFiles@2 - displayName: 'Copy : ConsoleCore' - inputs: - SourceFolder: $(Build.SourcesDirectory)\src\MigrationTools.ConsoleCore\bin\Release\net7.0\ - TargetFolder: $(Build.ArtifactStagingDirectory)/MigrationTools/preview/ - - task: CopyFiles@2 - displayName: 'Copy : Samples' - inputs: - SourceFolder: $(Build.SourcesDirectory)\src\MigrationTools.Samples\ - TargetFolder: $(Build.ArtifactStagingDirectory)/MigrationTools/ConfigSamples - - task: ms-devlabs.utilitytasks.task-zip.zip@0 - name: zip_8 - displayName: Zip MigrationTools - condition: succeededOrFailed() - inputs: - pathToZipFolder: $(Build.ArtifactStagingDirectory)/MigrationTools/ - pathToZipFile: $(Build.ArtifactStagingDirectory)/MigrationTools-$(GITVERSION.SemVer).zip - overwrite: true - - task: DeleteFiles@1 - displayName: Delete MigrationTools Staging folder - continueOnError: True - inputs: - SourceFolder: $(Build.ArtifactStagingDirectory)/MigrationTools - Contents: '*' - RemoveSourceFolder: true - - task: PowerShell@2 - name: PowerShell_9 - displayName: Get-FileHash (.net) - inputs: - targetType: inline - script: >- - $ZipHash = Get-FileHash $Env:Build_ArtifactStagingDirectory/MigrationTools-$Env:GITVERSION_SemVer.zip -Algorithm SHA256 - - Write-Host "##vso[task.setvariable variable=Chocolatey.FileHash;]$($ZipHash.Hash)" - - Write-Host "##vso[task.setvariable variable=Chocolatey.FullHash;]$ZipHash" - - task: qetza.replacetokens.replacetokens-task.replacetokens@5 - name: replacetokens_10 - displayName: Replace tokens in **\*.json **\*.md **\*.ps1 - inputs: - rootDirectory: $(System.DefaultWorkingDirectory) - targetFiles: >- - **\*.json - - **\*.md - - **\*.ps1 - escapeType: none - - task: ms-devlabs.vsts-developer-tools-build-tasks.tfx-installer-build-task.TfxInstaller@4 - displayName: 'Use Node CLI for Azure DevOps (tfx-cli): v0.7.x' - inputs: - version: v0.7.x - - task: ms-devlabs.vsts-developer-tools-build-tasks.package-extension-build-task.PackageAzureDevOpsExtension@4 - name: PackageVSTSExtension_11 - displayName: 'Package Extension: src\MigrationTools.Extension' - inputs: - rootFolder: src\MigrationTools.Extension - outputPath: $(Build.ArtifactStagingDirectory) - extensionVisibility: public - extensionPricing: free - - task: gep13.chocolatey-azuredevops.chocolatey-azuredevops.ChocolateyCommand@0 - displayName: Chocolatey pack - continueOnError: True - inputs: - packWorkingDirectory: src/MigrationTools.Chocolatey/ - packNuspecFileName: nkdAgility.AzureDevOpsMigrationTools.nuspec - packVersion: $(GitVersion.NuGetVersion) - - task: CopyFiles@2 - displayName: 'Copy : MigrationTools.nupkg' - inputs: - SourceFolder: $(Build.SourcesDirectory)\src\MigrationTools\bin\ - Contents: '**\*.nupkg' - TargetFolder: $(Build.ArtifactStagingDirectory) - flattenFolders: true - - task: CopyFiles@2 - displayName: 'Copy : MigrationTools Winget' - inputs: - SourceFolder: $(Build.SourcesDirectory)\src\MigrationTools.WinGet\ - Contents: '**\*' - TargetFolder: $(Build.ArtifactStagingDirectory)\WinGet - flattenFolders: true - - task: nkdagility.variablehydration.variabledehydration-task.variabledehydration@0 - name: variabledehydration_14 - displayName: (de)Hydrate Build Veriables GITVERSION,BUILD,Extension,Chocolatey - condition: succeededOrFailed() - inputs: - prefixes: GITVERSION,BUILD,Extension,Chocolatey - - task: PublishBuildArtifacts@1 - name: PublishBuildArtifacts_15 - displayName: 'Publish Artifact: drop' - condition: succeededOrFailed() - inputs: - PathtoPublish: $(build.artifactstagingdirectory) - TargetPath: '\\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)' - - task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@1 - displayName: Publish Analysis Result diff --git a/MigrationTools.sln b/MigrationTools.sln index 6ee0c891a..378b54de0 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -90,7 +90,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.TestExtensio EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".workflows", ".workflows", "{8A70932A-F6C7-45D1-8E72-608B6BF0F9FD}" ProjectSection(SolutionItems) = preProject - .github\workflows\build.yml = .github\workflows\build.yml + .github\workflows\main.yml = .github\workflows\main.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.ConsoleDataGenerator", "src\MigrationTools.ConsoleDataGenerator\MigrationTools.ConsoleDataGenerator.csproj", "{6A259EA6-860B-448A-8943-594DC1A15105}" @@ -101,6 +101,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modern", "Modern", "{83F368 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Clients", "Clients", "{AC3B5101-83F5-4C28-976C-C325425D1988}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{88C3582D-6C5D-4A8B-9EC3-F816C501AFA0}" + ProjectSection(SolutionItems) = preProject + build\azure-pipeline.yml = build\azure-pipeline.yml + build\build.ps1 = build\build.ps1 + build\buildDocs.ps1 = build\buildDocs.ps1 + build\compile-and-test.ps1 = build\compile-and-test.ps1 + build\install-prerequsits.ps1 = build\install-prerequsits.ps1 + build\packageChocolatey.ps1 = build\packageChocolatey.ps1 + build\packageExecutable.ps1 = build\packageExecutable.ps1 + build\packageExtension.ps1 = build\packageExtension.ps1 + build\packageNuget.ps1 = build\packageNuget.ps1 + build\packageWinget.ps1 = build\packageWinget.ps1 + build\releaseGitHubRelease.ps1 = build\releaseGitHubRelease.ps1 + build\releaseWingetPackage.ps1 = build\releaseWingetPackage.ps1 + build\versioning.ps1 = build\versioning.ps1 + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{BB497233-248C-49DF-AE12-F7A76F775E74}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -197,24 +216,25 @@ Global {32E2956A-9056-4D9D-8018-14DFD0E6CA41} = {A05A7847-4C75-4E92-B156-F529483688CC} {A314A07F-1D5E-44B8-9973-3AB2C41F17D5} = {83F36820-E9BC-4F48-8202-5EAF9530405E} {7CE6D8B2-920C-43F6-95E8-F2682B029DB8} = {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} - {EBDB3038-9081-41B5-B82A-D0BC8F96859F} = {83F36820-E9BC-4F48-8202-5EAF9530405E} + {EBDB3038-9081-41B5-B82A-D0BC8F96859F} = {BB497233-248C-49DF-AE12-F7A76F775E74} {6F97F030-162D-49BF-A45C-1CF12E7ABA88} = {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} - {A679B3FF-1355-455F-853F-433A9CB1BE60} = {83F36820-E9BC-4F48-8202-5EAF9530405E} + {A679B3FF-1355-455F-853F-433A9CB1BE60} = {BB497233-248C-49DF-AE12-F7A76F775E74} {D58EEDFA-D74C-4E84-9C26-6D69521382FD} = {AC3B5101-83F5-4C28-976C-C325425D1988} - {B400FC37-A4B7-4526-85DD-36784E3B56EC} = {83F36820-E9BC-4F48-8202-5EAF9530405E} + {B400FC37-A4B7-4526-85DD-36784E3B56EC} = {BB497233-248C-49DF-AE12-F7A76F775E74} {E5294FF3-167A-49A5-A453-19332DA32B01} = {1F5E9C8C-AD05-4C4F-B370-FF3D080A6541} {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} = {83F36820-E9BC-4F48-8202-5EAF9530405E} {A6831354-6128-4F1A-A1F3-C6E598B0925F} = {32E2956A-9056-4D9D-8018-14DFD0E6CA41} {54DF41E6-9F94-42DD-877E-437DC6E9F3E2} = {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} {504D6953-E83D-498D-A1C7-E511F14B9563} = {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} {3191B594-1C3A-4245-8AFE-076EA142B778} = {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} - {6F51CE1D-FEBD-4F7F-A462-27A4745924F4} = {83F36820-E9BC-4F48-8202-5EAF9530405E} + {6F51CE1D-FEBD-4F7F-A462-27A4745924F4} = {BB497233-248C-49DF-AE12-F7A76F775E74} {AADA5B89-83F9-45E4-B713-EA1FEB9EBC89} = {1F5E9C8C-AD05-4C4F-B370-FF3D080A6541} {72FA4853-D840-480E-A6FD-670EF66E9D5B} = {AC3B5101-83F5-4C28-976C-C325425D1988} {70EA792C-E84C-4A5D-8280-FCC47F4AE150} = {13FE9FE2-9C6E-4866-BBAD-106F5BF765F1} - {4C16C19A-AF2D-4061-B2DE-87E39B1DF422} = {83F36820-E9BC-4F48-8202-5EAF9530405E} + {4C16C19A-AF2D-4061-B2DE-87E39B1DF422} = {BB497233-248C-49DF-AE12-F7A76F775E74} {6A259EA6-860B-448A-8943-594DC1A15105} = {83F36820-E9BC-4F48-8202-5EAF9530405E} {AC3B5101-83F5-4C28-976C-C325425D1988} = {1F5E9C8C-AD05-4C4F-B370-FF3D080A6541} + {BB497233-248C-49DF-AE12-F7A76F775E74} = {83F36820-E9BC-4F48-8202-5EAF9530405E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {62EE0B27-C55A-46EE-8D17-1691DE9BBD50} diff --git a/build/azure-pipeline.yml b/build/azure-pipeline.yml index 7fe373091..32b0adf4b 100644 --- a/build/azure-pipeline.yml +++ b/build/azure-pipeline.yml @@ -224,10 +224,13 @@ stages: filePath: '.\build\packageExtension.ps1' arguments: '-version $(GitVersion.AssemblySemVer) -outfolder "$(Build.ArtifactStagingDirectory)"' - task: PowerShell@2 - displayName: "Packaging (Chocolatey)" + displayName: Packaging (Chocolatey) + name: ChocolateyPack inputs: - filePath: '.\build\packageChocolatey.ps1' - arguments: '-SemVer $(GitVersion.SemVer) -NuGetVersion $(GitVersion.NuGetVersion) -outfolder "$(Build.ArtifactStagingDirectory)"' + targetType: 'inline' + script: | + $item = Get-ChildItem -Path $(Build.ArtifactStagingDirectory) -Recurse -Filter 'MigrationTools-$(GitVersion.SemVer).zip' | Select-Object -First 1; + .\build\packageChocolatey.ps1 -SemVer $(GitVersion.SemVer) -NuGetVersion $(GitVersion.NuGetVersion) -outfolder "$(Build.ArtifactStagingDirectory)" -migrationToolsFilename $item.FullName - task: PowerShell@2 displayName: "Packaging (Winget)" inputs: diff --git a/build/build.ps1 b/build/build.ps1 index 5caf000fa..fd9bea0cb 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -1,6 +1,6 @@ cls - +$env:RUNNER_OS = "Windows" $StartTimeBuild = Get-Date; Write-Output "BUILD Azure DevOps Migration Tools" @@ -40,7 +40,8 @@ $stagingfolder = New-Item -Name "output\Staging" -ItemType Directory .\build\packageExtension.ps1 -SemVer $version -NuGetVersion $NuGetVersion -outfolder $stagingfolder #------------------------------------------- # Azure DevOps Migration Tools (Chocolatey) Packaging -.\build\packageChocolatey.ps1 -version $version -outfolder $stagingfolder +$item = Get-ChildItem -Path .\ -Recurse -Filter 'MigrationTools-$version.zip' | Select-Object -First 1 +.\build\packageChocolatey.ps1 -version $version -outfolder $stagingfolder -migrationToolsFilename $item.FullName #------------------------------------------- # Azure DevOps Migration Tools (Nuget) Packaging .\build\packageNuget.ps1 -version $version -outfolder $stagingfolder @@ -73,3 +74,5 @@ $stagingfolder = New-Item -Name "output\Staging" -ItemType Directory # Final Write-Output "Build ran in $((Get-Date) - $StartTimeBuild)" #============================================================================== + + .\build\packageExecutable.ps1 -version "1.0.0" -outfolder ".\staging" \ No newline at end of file diff --git a/build/changelogs.ps1 b/build/changelogs.ps1 new file mode 100644 index 000000000..27065ad0c --- /dev/null +++ b/build/changelogs.ps1 @@ -0,0 +1,11 @@ + +$releases = gh release list --json name,tagName -L 5009 --exclude-pre-releases | ConvertFrom-Json + + +foreach ($release in $releases) { + Write-Output "Release: $($release.name)" + gren changelog --generate --override --tags=v15.0.4..$($release.tagName) --data-source=issues --changelog-filename=./changelogs/CHANGELOG-$($release.tagName)-issues.md +} + +$tags = git tag -l +$tags|%{[System.Version]$_}|sort \ No newline at end of file diff --git a/build/packageChocolatey.ps1 b/build/packageChocolatey.ps1 index de2a20d91..de353bd39 100644 --- a/build/packageChocolatey.ps1 +++ b/build/packageChocolatey.ps1 @@ -14,31 +14,34 @@ param ( # name of the output folder [Parameter(Mandatory=$true)] - [string]$outfolder + [string]$outfolder, + + # name of the migrationToolsZip File path + [Parameter(Mandatory=$true)] + [string]$migrationToolsFilename ) Write-Output "Azure DevOps Migration Tools (Chocolatey) Packaging" Write-Output "----------------------------------------" Write-Output "SemVer: $SemVer" Write-Output "NuGetVersion: $NuGetVersion" Write-Output "Output Folder: $outfolder" -$MigrationToolsFilename = "MigrationTools-$SemVer.zip" Write-Output "MigrationTools Filename: $MigrationToolsFilename" # create hash Write-Output "Creating Hash for $MigrationToolsFilename" -$ZipHash = Get-FileHash $outfolder\$MigrationToolsFilename -Algorithm SHA256 +$ZipHash = Get-FileHash $MigrationToolsFilename -Algorithm SHA256 $obj = @{ "Hash" = $($ZipHash.Hash) "FullHash" = $ZipHash } -$hashSaveFile = "$outfolder\MigrationTools-$SemVer.hash.txt" +$hashSaveFile = "$outfolder/MigrationTools-$SemVer.hash.txt" $obj | ConvertTo-Json | Set-Content -Path $hashSaveFile Write-Output "Hash saved to $hashSaveFile" #------------------------------------------- # Replace tokens Write-Output "Find and replace tokens" -$tokens = @("**\chocolatey*.ps1") +$tokens = @("**/chocolatey*.ps1") $files = Get-ChildItem -Path $tokens -Recurse -Exclude "output" Write-Output "Found $($files.Count) files that might have tokens" diff --git a/build/packageExecutable.ps1 b/build/packageExecutable.ps1 index 4cac167e8..01f2d4e8c 100644 --- a/build/packageExecutable.ps1 +++ b/build/packageExecutable.ps1 @@ -13,35 +13,77 @@ param ( [string]$outfolder ) Write-Output "Azure DevOps Migration Tools (Executable) Packaging" -Write-Output "----------------------------------------" +Write-Output "=========================================" Write-Output "Version: $version" Write-Output "Output Folder: $outfolder" $OutputFilename = "MigrationTools-$version.zip" Write-Output "Filename: $OutputFilename" -$OutputFullName = "$outfolder\$OutputFilename" +$OutputFullName = "$outfolder/$OutputFilename" Write-Output "Full Name: $OutputFullName" +Write-Output "OS: $env:RUNNER_OS" #============================================================================== +Write-Output "----------------------------------------" # Install Prerequisits -$installedStuff = choco list -i -if (($installedStuff -like "*7zip*").Count -eq 0) { - Write-Output "Installing 7zip" - choco install 7zip --confirm --accept-license -y -} else { Write-Output "Detected 7zip"} -#============================================================================== +Write-Output "Install Prerequisits for GH($env:RUNNER_OS) | ADO($env:AGENT_OS)" +If ($env:AGENT_OS -ne $null) +{ + switch ($env:AGENT_OS) + { + "Windows_NT" { + $env:RUNNER_OS = "Windows" + break; + } + "Linux" { + $env:RUNNER_OS = "Linux" + break; + } + default { + Write-Output "We dont support $env:AGENT_OS!" + exit 1 + break; + } + } +} + +switch ($env:RUNNER_OS) +{ + "Windows" { + Write-Output "Detected Windows" + $installedStuff = choco list -i + if (($installedStuff -like "*7zip*").Count -eq 0) { + Write-Output "Installing 7zip" + choco install 7zip --confirm --accept-license -y + } else { Write-Output "Detected 7zip"} + break; + } + "Linux" { + Write-Output "Detected Linux" + sudo apt install p7zip-full p7zip-rar + break; + } + default { + Write-Output "We dont support $env:RUNNER_OS!" + exit 1 + break; + } + +} +Write-Output "----------------------------------------" # Create output sub folders Write-Output "Create folders in $outfolder" -New-Item -Path $outfolder -Name "\MigrationTools\" -ItemType Directory -New-Item -Path $outfolder -Name "\MigrationTools\preview\" -ItemType Directory -New-Item -Path $outfolder -Name "\MigrationTools\ConfigSamples\" -ItemType Directory -#============================================================================== +New-Item -Path $outfolder -Name "/MigrationTools/" -ItemType Directory +New-Item -Path $outfolder -Name "/MigrationTools/preview/" -ItemType Directory +New-Item -Path $outfolder -Name "/MigrationTools/ConfigSamples/" -ItemType Directory +Write-Output "----------------------------------------" # Copy Files -Write-Output "Copy files to $outfolder\MigrationTools\" -Copy-Item -Path ".\src\MigrationTools.ConsoleFull\bin\Debug\net472\*" -Destination "$outfolder\MigrationTools\" -Recurse -Copy-Item -Path ".\src\MigrationTools.ConsoleCore\bin\Debug\net8.0\*" -Destination "$outfolder\MigrationTools\preview\" -Recurse -Copy-Item -Path ".\src\MigrationTools.Samples\*" -Destination "$outfolder\MigrationTools\ConfigSamples\" -Recurse -#============================================================================== +Write-Output "Copy files to $outfolder/MigrationTools/" +Copy-Item -Path "./src/MigrationTools.ConsoleFull/bin/Debug/net472/*" -Destination "$outfolder/MigrationTools/" -Recurse +Copy-Item -Path "./src/MigrationTools.ConsoleCore/bin/Debug/net8.0/*" -Destination "$outfolder/MigrationTools/preview/" -Recurse +Copy-Item -Path "./src/MigrationTools.Samples/*" -Destination "$outfolder/MigrationTools/ConfigSamples/" -Recurse +Write-Output "----------------------------------------" # Create Zip -7z a -tzip $OutputFullName $outfolder\MigrationTools\** -#============================================================================== +7z a -tzip $OutputFullName $outfolder/MigrationTools/** +Write-Output "----------------------------------------" # Cleanup -Remove-Item -Path "$outfolder\MigrationTools" -Recurse -Force \ No newline at end of file +Remove-Item -Path "$outfolder/MigrationTools" -Recurse -Force +Write-Output "=========================================" \ No newline at end of file diff --git a/build/packageExtension.ps1 b/build/packageExtension.ps1 index 0a4f611a9..2282a4ffb 100644 --- a/build/packageExtension.ps1 +++ b/build/packageExtension.ps1 @@ -16,28 +16,28 @@ Write-Output "Azure DevOps Migration Tools (Extension) Packaging" Write-Output "----------------------------------------" Write-Output "Version: $version" Write-Output "Output Folder: $outfolder" - +Write-Output "----------------------------------------" # Copy out Extension Files -New-Item -Path $outfolder -Name "\MigrationTools.Extension\" -ItemType Directory -Copy-Item -Path ".\src\MigrationTools.Extension\**" -Destination "$outfolder\MigrationTools.Extension\" -Recurse - - -$fileToUpdate = Get-Item -Path "$outfolder\MigrationTools.Extension\vss-extension.json" +New-Item -Path $outfolder -Name "MigrationTools.Extension" -ItemType Directory +Copy-Item -Path ".\src\MigrationTools.Extension\**" -Destination "$outfolder/MigrationTools.Extension/" -Recurse +Write-Output "----------------------------------------" +$fileToUpdate = Get-Item -Path "$outfolder/MigrationTools.Extension/vss-extension.json" Write-Output "Processing $($fileToUpdate.Name)" $contents = Get-Content -Path $fileToUpdate.FullName $contents = $contents | ForEach-Object { $_ -replace "#{EXTENSION-VERSION}#", $version } Set-Content -Path $fileToUpdate.FullName -Value $contents Write-Output "Replaced tokens in $($fileToUpdate.Name)" - -#------------------------------------------- +Write-Output "----------------------------------------" if (((npm list -g tfx-cli) -join "," ).Contains("empty")) { Write-Output "Installing tfx-cli" npm i -g tfx-cli } else { Write-Output "Detected tfx-cli"} -#------------------------------------------- +Write-Output "----------------------------------------" +Get-ChildItem -Path $outfolder -Recurse | ForEach-Object { $_.FullName } +Write-Output "----------------------------------------" # Build TFS Extension -Write-Output "Build TFS Extension" -tfx extension create --root "$outfolder\MigrationTools.Extension\" --output-path $outfolder --manifest-globs vss-extension.json -#------------------------------------------- +Write-Output ">>>>> Build TFS Extension" +tfx extension create --root "$outfolder/MigrationTools.Extension/" --output-path $outfolder --manifest-globs vss-extension.json +Write-Output "----------------------------------------" # Cleanup -Remove-Item -Path "$outfolder\MigrationTools.Extension" -Recurse -Force \ No newline at end of file +Remove-Item -Path "$outfolder/MigrationTools.Extension" -Recurse -Force \ No newline at end of file diff --git a/src/MigrationTools.Host/MigrationTools.Host.csproj b/src/MigrationTools.Host/MigrationTools.Host.csproj index 09a498e1f..943535143 100644 --- a/src/MigrationTools.Host/MigrationTools.Host.csproj +++ b/src/MigrationTools.Host/MigrationTools.Host.csproj @@ -23,7 +23,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/src/VstsSyncMigrator.Core/VstsSyncMigrator.Core.csproj b/src/VstsSyncMigrator.Core/VstsSyncMigrator.Core.csproj index 8d2ffe9a7..687c5d4aa 100644 --- a/src/VstsSyncMigrator.Core/VstsSyncMigrator.Core.csproj +++ b/src/VstsSyncMigrator.Core/VstsSyncMigrator.Core.csproj @@ -22,7 +22,7 @@ - + all none