From c6b4d955e84e2f11c0f2313a5cbc58be888f9775 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 14:23:33 +0100 Subject: [PATCH 01/10] Add prepare release step --- .github/workflows/build.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5999e9b7..cd98ece3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -247,13 +247,42 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + + prepare-release: + name: Prepare Release + if: startsWith(github.ref, 'refs/heads/release/') + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Rebase benchmarks onto main + shell: bash + run: | + git checkout benchmarks + git rebase main + git push origin + - name: Merge benchmarks into main + shell: bash + run: | + git checkout main + git checkout -b integrate/merge-benchmarks-to-main + git merge benchmarks + git push origin + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + branch: integrate/merge-benchmarks-to-main + base: main + title: 'docs: update benchmarks while releasing ${version}' deploy: name: Deploy if: startsWith(github.ref, 'refs/heads/release/') runs-on: ubuntu-latest environment: production - needs: [test-macos, test-ubuntu, test-windows, test-net-framework, stryker, benchmark] + needs: [test-macos, test-ubuntu, test-windows, test-net-framework, stryker, benchmark, prepare-release] steps: - name: Checkout sources uses: actions/checkout@v4 From 929b50268b42552c136f940785c11568c6ea8846 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 15:06:22 +0100 Subject: [PATCH 02/10] Add test possibility --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd98ece3..1476e0ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -250,8 +250,9 @@ jobs: prepare-release: name: Prepare Release - if: startsWith(github.ref, 'refs/heads/release/') + # if: startsWith(github.ref, 'refs/heads/release/') runs-on: ubuntu-latest + needs: [benchmark] steps: - name: Checkout sources uses: actions/checkout@v4 From 1c878edaa0217b669a5826cce0b7bf83e6243095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sun, 17 Nov 2024 15:21:23 +0100 Subject: [PATCH 03/10] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1476e0ff..38d906ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -262,7 +262,7 @@ jobs: shell: bash run: | git checkout benchmarks - git rebase main + git rebase origin/main git push origin - name: Merge benchmarks into main shell: bash From 1d30043dc3bba454d48275488427d692605164fa Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 16:38:42 +0100 Subject: [PATCH 04/10] Fix build error --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 38d906ed..82bc2caa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -228,6 +228,7 @@ jobs: pages: name: Deploy to Github Pages + if: github.ref == 'refs/heads/main' environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -270,7 +271,7 @@ jobs: git checkout main git checkout -b integrate/merge-benchmarks-to-main git merge benchmarks - git push origin + git push --set-upstream origin integrate/merge-benchmarks-to-main - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: From 5885b730ef1c8a2b5a3223f2e88d2209b4351fd5 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 16:50:16 +0100 Subject: [PATCH 05/10] Use gh --- .github/workflows/build.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82bc2caa..6805f766 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -272,12 +272,11 @@ jobs: git checkout -b integrate/merge-benchmarks-to-main git merge benchmarks git push --set-upstream origin integrate/merge-benchmarks-to-main - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - with: - branch: integrate/merge-benchmarks-to-main - base: main - title: 'docs: update benchmarks while releasing ${version}' + - name: Create pull request + run: | + gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} deploy: name: Deploy From 7916727710d6f103d01086272888663aac89f32d Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 16:53:34 +0100 Subject: [PATCH 06/10] Consolidate indentation --- .github/workflows/build.yml | 544 ++++++++++++++++++------------------ 1 file changed, 272 insertions(+), 272 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6805f766..04e1ba71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,215 +16,215 @@ jobs: name: Test (MacOS) runs-on: macos-latest steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Tag current commit - if: startsWith(github.ref, 'refs/heads/release/') - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - git tag "${version}" - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - name: Build solution - run: dotnet build /p:NetCoreOnly=True --configuration "Release" - - name: Run tests - run: dotnet test --no-build --collect:"XPlat Code Coverage" - - name: Upload coverage - uses: actions/upload-artifact@v3 - with: - name: Code coverage (MacOS) - path: "**/coverage.cobertura.xml" + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Tag current commit + if: startsWith(github.ref, 'refs/heads/release/') + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + git tag "${version}" + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Build solution + run: dotnet build /p:NetCoreOnly=True --configuration "Release" + - name: Run tests + run: dotnet test --no-build --collect:"XPlat Code Coverage" + - name: Upload coverage + uses: actions/upload-artifact@v3 + with: + name: Code coverage (MacOS) + path: "**/coverage.cobertura.xml" test-ubuntu: name: Test (Ubuntu) runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Tag current commit - if: startsWith(github.ref, 'refs/heads/release/') - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - git tag "${version}" - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - name: Build solution - run: dotnet build /p:NetCoreOnly=True --configuration "Release" - - name: Run tests - run: dotnet test --no-build --collect:"XPlat Code Coverage" - - name: Upload coverage - uses: actions/upload-artifact@v3 - with: - name: Code coverage (Ubuntu) - path: "**/coverage.cobertura.xml" + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Tag current commit + if: startsWith(github.ref, 'refs/heads/release/') + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + git tag "${version}" + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Build solution + run: dotnet build /p:NetCoreOnly=True --configuration "Release" + - name: Run tests + run: dotnet test --no-build --collect:"XPlat Code Coverage" + - name: Upload coverage + uses: actions/upload-artifact@v3 + with: + name: Code coverage (Ubuntu) + path: "**/coverage.cobertura.xml" test-windows: name: Test (Windows) runs-on: windows-latest steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Tag current commit - if: startsWith(github.ref, 'refs/heads/release/') - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - git tag "${version}" - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - name: Build solution - run: dotnet build /p:NetCoreOnly=True --configuration "Release" - - name: Run tests - run: dotnet test --no-build --collect:"XPlat Code Coverage" - - name: Upload coverage - uses: actions/upload-artifact@v3 - with: - name: Code coverage (Windows) - path: "**/coverage.cobertura.xml" + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Tag current commit + if: startsWith(github.ref, 'refs/heads/release/') + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + git tag "${version}" + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Build solution + run: dotnet build /p:NetCoreOnly=True --configuration "Release" + - name: Run tests + run: dotnet test --no-build --collect:"XPlat Code Coverage" + - name: Upload coverage + uses: actions/upload-artifact@v3 + with: + name: Code coverage (Windows) + path: "**/coverage.cobertura.xml" test-net-framework: name: Test (.NET Framework) runs-on: windows-latest steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Tag current commit - if: startsWith(github.ref, 'refs/heads/release/') - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - git tag "${version}" - - name: Setup .NET - uses: actions/setup-dotnet@v4 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v2 - - name: Setup VSTest - uses: darenm/Setup-VSTest@v1 - - name: Navigate to Workspace - run: cd $GITHUB_WORKSPACE - - name: Build solution - run: msbuild.exe Testably.Expectations.sln /p:NetFrameworkOnly=True /p:platform="Any CPU" /p:configuration="Release" -t:restore,build -p:RestorePackagesConfig=true - - name: Run tests - run: vstest.console.exe .\Build\Tests\Testably.Expectations.Tests\net48\Testably.Expectations.Tests.dll .\Build\Tests\Testably.Expectations.Internal.Tests\net48\Testably.Expectations.Internal.Tests.dll .\Build\Tests\TestFramework.NUnit3.Tests\net48\TestFramework.NUnit3.Tests.dll .\Build\Tests\TestFramework.NUnit4.Tests\net48\TestFramework.NUnit4.Tests.dll .\Build\Tests\TestFramework.XUnit2.Tests\net48\TestFramework.XUnit2.Tests.dll /Logger:trx /ResultsDirectory:TestResults /collect:"Code Coverage;Format=Cobertura" - - name: Upload coverage - uses: actions/upload-artifact@v3 - with: - name: Code coverage (.NET Framework) - path: "**/*.cobertura.xml" + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Tag current commit + if: startsWith(github.ref, 'refs/heads/release/') + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + git tag "${version}" + - name: Setup .NET + uses: actions/setup-dotnet@v4 + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + - name: Setup VSTest + uses: darenm/Setup-VSTest@v1 + - name: Navigate to Workspace + run: cd $GITHUB_WORKSPACE + - name: Build solution + run: msbuild.exe Testably.Expectations.sln /p:NetFrameworkOnly=True /p:platform="Any CPU" /p:configuration="Release" -t:restore,build -p:RestorePackagesConfig=true + - name: Run tests + run: vstest.console.exe .\Build\Tests\Testably.Expectations.Tests\net48\Testably.Expectations.Tests.dll .\Build\Tests\Testably.Expectations.Internal.Tests\net48\Testably.Expectations.Internal.Tests.dll .\Build\Tests\TestFramework.NUnit3.Tests\net48\TestFramework.NUnit3.Tests.dll .\Build\Tests\TestFramework.NUnit4.Tests\net48\TestFramework.NUnit4.Tests.dll .\Build\Tests\TestFramework.XUnit2.Tests\net48\TestFramework.XUnit2.Tests.dll /Logger:trx /ResultsDirectory:TestResults /collect:"Code Coverage;Format=Cobertura" + - name: Upload coverage + uses: actions/upload-artifact@v3 + with: + name: Code coverage (.NET Framework) + path: "**/*.cobertura.xml" upload-coverage: name: Upload coverage to Codacy needs: [test-macos, test-ubuntu, test-windows, test-net-framework] runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - - name: Download code coverage files (MacOS) - uses: actions/download-artifact@v3 - with: - name: Code coverage (MacOS) - path: Coverage/MacOS - - name: Download code coverage files (Ubuntu) - uses: actions/download-artifact@v3 - with: - name: Code coverage (Ubuntu) - path: Coverage/Ubuntu - - name: Download code coverage files (Windows) - uses: actions/download-artifact@v3 - with: - name: Code coverage (Windows) - path: Coverage/Windows - - name: Generate coverage report - uses: danielpalme/ReportGenerator-GitHub-Action@v5.3.11 - with: - reports: "Coverage/**/*.cobertura.xml" - targetdir: "coverage-report" - reporttypes: "Cobertura" - - name: Publish coverage report to Codacy - uses: codacy/codacy-coverage-reporter-action@master - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage-report/Cobertura.xml + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + - name: Download code coverage files (MacOS) + uses: actions/download-artifact@v3 + with: + name: Code coverage (MacOS) + path: Coverage/MacOS + - name: Download code coverage files (Ubuntu) + uses: actions/download-artifact@v3 + with: + name: Code coverage (Ubuntu) + path: Coverage/Ubuntu + - name: Download code coverage files (Windows) + uses: actions/download-artifact@v3 + with: + name: Code coverage (Windows) + path: Coverage/Windows + - name: Generate coverage report + uses: danielpalme/ReportGenerator-GitHub-Action@v5.3.11 + with: + reports: "Coverage/**/*.cobertura.xml" + targetdir: "coverage-report" + reporttypes: "Cobertura" + - name: Publish coverage report to Codacy + uses: codacy/codacy-coverage-reporter-action@master + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage-report/Cobertura.xml stryker: name: Stryker mutation testing runs-on: ubuntu-latest timeout-minutes: 300 steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - name: Install .NET Stryker - shell: bash - run: | - dotnet tool install dotnet-stryker --tool-path ../tools --version 4.3.0 - - name: Analyze Testably.Expectations - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Install .NET Stryker + shell: bash + run: | + dotnet tool install dotnet-stryker --tool-path ../tools --version 4.3.0 + - name: Analyze Testably.Expectations + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" benchmark: name: Run benchmarks runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: | - 6.0.x - 8.0.x - - name: Build solution - run: dotnet build /p:NetCoreOnly=True --configuration "Release" - - name: Run benchmark - run: cd Build/Tests/Testably.Expectations.Benchmarks && dotnet ./Testably.Expectations.Benchmarks.dll --exporters json --filter '*' - - name: Store benchmark result - uses: rhysd/github-action-benchmark@v1 - with: - name: Benchmark.Net Benchmark - tool: 'benchmarkdotnet' - output-file-path: Build/Tests/Testably.Expectations.Benchmarks/BenchmarkDotNet.Artifacts/results/Testably.Expectations.Benchmarks.HappyCaseBenchmarks-report-full-compressed.json - github-token: ${{ secrets.GITHUB_TOKEN }} - gh-pages-branch: 'benchmarks' - benchmark-data-dir-path: 'Docs/Benchmarks' - auto-push: true + - name: Checkout sources + uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Build solution + run: dotnet build /p:NetCoreOnly=True --configuration "Release" + - name: Run benchmark + run: cd Build/Tests/Testably.Expectations.Benchmarks && dotnet ./Testably.Expectations.Benchmarks.dll --exporters json --filter '*' + - name: Store benchmark result + uses: rhysd/github-action-benchmark@v1 + with: + name: Benchmark.Net Benchmark + tool: 'benchmarkdotnet' + output-file-path: Build/Tests/Testably.Expectations.Benchmarks/BenchmarkDotNet.Artifacts/results/Testably.Expectations.Benchmarks.HappyCaseBenchmarks-report-full-compressed.json + github-token: ${{ secrets.GITHUB_TOKEN }} + gh-pages-branch: 'benchmarks' + benchmark-data-dir-path: 'Docs/Benchmarks' + auto-push: true pages: name: Deploy to Github Pages @@ -255,28 +255,28 @@ jobs: runs-on: ubuntu-latest needs: [benchmark] steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Rebase benchmarks onto main - shell: bash - run: | - git checkout benchmarks - git rebase origin/main - git push origin - - name: Merge benchmarks into main - shell: bash - run: | - git checkout main - git checkout -b integrate/merge-benchmarks-to-main - git merge benchmarks - git push --set-upstream origin integrate/merge-benchmarks-to-main - - name: Create pull request - run: | - gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Rebase benchmarks onto main + shell: bash + run: | + git checkout benchmarks + git rebase origin/main + git push origin + - name: Merge benchmarks into main + shell: bash + run: | + git checkout main + git checkout -b integrate/merge-benchmarks-to-main + git merge benchmarks + git push --set-upstream origin integrate/merge-benchmarks-to-main + - name: Create pull request + run: | + gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} deploy: name: Deploy @@ -285,60 +285,60 @@ jobs: environment: production needs: [test-macos, test-ubuntu, test-windows, test-net-framework, stryker, benchmark, prepare-release] steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Tag current commit - id: tag - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - git tag "${version}" - git push origin "${version}" - echo "release_version=${version}" >> "$GITHUB_OUTPUT" - - name: Setup NuGet - uses: NuGet/setup-nuget@v2.0.0 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - - name: Prepare README.md - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - # Add changelog badge to README.md - sed -i -e "2 a\[!\[Changelog](https:\/\/img\.shields\.io\/badge\/Changelog-${version}-blue)](https:\/\/github\.com\/Testably\/Testably\.Expectations\/releases\/tag\/${version})" "./README.md" - for f in "README.md" - do - echo "Processing $f" # always double quote "$f" filename - # do something on $f - # Remove the codacy and sonarcloud badge as it is not aligned to the release - grep -v "app.codacy.com" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f" - grep -v "sonarcloud.io" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f" - # Change status badges to display explicit version - sed -i -e "s/branch=main/branch=release%2F${version}/g" "./$f" - sed -i -e "s/Testably.Expectations%2Fmain/Testably.Expectations%2Frelease%2F${version}/g" "./$f" - sed -i -e "s/Testably.Expectations%2Fmain/Testably.Expectations%2Frelease%2F${version}/g" "./$f" - sed -i -e "s/Testably.Expectations\/main)/Testably.Expectations\/release\/${version})/g" "./$f" - sed -i -e "s/Testably.Expectations\/actions\/workflows\/build.yml\/badge.svg)/Testably.Expectations\/actions\/workflows\/build.yml\/badge.svg?branch=release\/${version})/g" "./$f" - sed -i -e "s/Testably.Expectations\/actions\/workflows\/build.yml)/Testably.Expectations\/actions\/workflows\/build.yml?query=branch%3Arelease%2F${version})/g" "./$f" - # Add absolute path to example section - sed -i -e 's/\(Examples\/README.md\)/https:\/\/github.com\/Testably\/Testably.Expectations\/blob\/main\/Examples\/README.md/g' "./$f" - done - - name: Build - run: dotnet build --configuration "Release" - - name: Publish - run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} - - name: Create GitHub release - uses: softprops/action-gh-release@v2 - with: - name: ${{ steps.tag.outputs.release_version }} - tag_name: ${{ steps.tag.outputs.release_version }} - token: ${{ secrets.GITHUB_TOKEN }} - generate_release_notes: true + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Tag current commit + id: tag + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + git tag "${version}" + git push origin "${version}" + echo "release_version=${version}" >> "$GITHUB_OUTPUT" + - name: Setup NuGet + uses: NuGet/setup-nuget@v2.0.0 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Prepare README.md + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + # Add changelog badge to README.md + sed -i -e "2 a\[!\[Changelog](https:\/\/img\.shields\.io\/badge\/Changelog-${version}-blue)](https:\/\/github\.com\/Testably\/Testably\.Expectations\/releases\/tag\/${version})" "./README.md" + for f in "README.md" + do + echo "Processing $f" # always double quote "$f" filename + # do something on $f + # Remove the codacy and sonarcloud badge as it is not aligned to the release + grep -v "app.codacy.com" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f" + grep -v "sonarcloud.io" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f" + # Change status badges to display explicit version + sed -i -e "s/branch=main/branch=release%2F${version}/g" "./$f" + sed -i -e "s/Testably.Expectations%2Fmain/Testably.Expectations%2Frelease%2F${version}/g" "./$f" + sed -i -e "s/Testably.Expectations%2Fmain/Testably.Expectations%2Frelease%2F${version}/g" "./$f" + sed -i -e "s/Testably.Expectations\/main)/Testably.Expectations\/release\/${version})/g" "./$f" + sed -i -e "s/Testably.Expectations\/actions\/workflows\/build.yml\/badge.svg)/Testably.Expectations\/actions\/workflows\/build.yml\/badge.svg?branch=release\/${version})/g" "./$f" + sed -i -e "s/Testably.Expectations\/actions\/workflows\/build.yml)/Testably.Expectations\/actions\/workflows\/build.yml?query=branch%3Arelease%2F${version})/g" "./$f" + # Add absolute path to example section + sed -i -e 's/\(Examples\/README.md\)/https:\/\/github.com\/Testably\/Testably.Expectations\/blob\/main\/Examples\/README.md/g' "./$f" + done + - name: Build + run: dotnet build --configuration "Release" + - name: Publish + run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} + - name: Create GitHub release + uses: softprops/action-gh-release@v2 + with: + name: ${{ steps.tag.outputs.release_version }} + tag_name: ${{ steps.tag.outputs.release_version }} + token: ${{ secrets.GITHUB_TOKEN }} + generate_release_notes: true cleanup: name: Cleanup @@ -346,22 +346,22 @@ jobs: runs-on: ubuntu-latest needs: [deploy] steps: - - name: Comment relevant issues and pull requests - uses: apexskier/github-release-commenter@v1.3.6 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - comment-template: | - This is addressed in release {release_link}. - label-template: | - state: released - skip-label: | - state: released - - name: Checkout sources - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Delete release branch - shell: bash - run: | - version="${GITHUB_REF#refs/heads/release/}" - git push origin -d "refs/heads/release/${version}" + - name: Comment relevant issues and pull requests + uses: apexskier/github-release-commenter@v1.3.6 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + comment-template: | + This is addressed in release {release_link}. + label-template: | + state: released + skip-label: | + state: released + - name: Checkout sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Delete release branch + shell: bash + run: | + version="${GITHUB_REF#refs/heads/release/}" + git push origin -d "refs/heads/release/${version}" From 9ad34bb184f577450618b254c50d3d12e1134826 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 16:56:33 +0100 Subject: [PATCH 07/10] Run gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' must provide `--title` and `--body` (or `--fill` or `fill-first` or `--fillverbose`) when not running interactively --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04e1ba71..6641f2ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -273,8 +273,8 @@ jobs: git merge benchmarks git push --set-upstream origin integrate/merge-benchmarks-to-main - name: Create pull request - run: | - gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' + run: | + gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' --fill env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 21c217bcdbcab1aff8bc81a0b3bb403ac26c0ffc Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 17:08:51 +0100 Subject: [PATCH 08/10] Store benchmark only on main branch --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6641f2ac..13993e14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -217,6 +217,7 @@ jobs: run: cd Build/Tests/Testably.Expectations.Benchmarks && dotnet ./Testably.Expectations.Benchmarks.dll --exporters json --filter '*' - name: Store benchmark result uses: rhysd/github-action-benchmark@v1 + if: github.ref == 'refs/heads/main' with: name: Benchmark.Net Benchmark tool: 'benchmarkdotnet' @@ -274,6 +275,7 @@ jobs: git push --set-upstream origin integrate/merge-benchmarks-to-main - name: Create pull request run: | + version="${GITHUB_REF#refs/heads/release/}" gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' --fill env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 62438f782776ae410d9dd2557e53601e92fb1e71 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 17:13:53 +0100 Subject: [PATCH 09/10] Add pull-requests write permission --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13993e14..b026171a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,10 @@ on: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: write - pages: write - id-token: write + contents: write + pages: write + id-token: write + pull-requests: write jobs: test-macos: From 150e2f52dbba3b913b2628e3cf9cc2070fbbcb18 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 17 Nov 2024 17:26:08 +0100 Subject: [PATCH 10/10] fix --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b026171a..bf76d049 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -253,7 +253,7 @@ jobs: prepare-release: name: Prepare Release - # if: startsWith(github.ref, 'refs/heads/release/') + if: startsWith(github.ref, 'refs/heads/release/') runs-on: ubuntu-latest needs: [benchmark] steps: @@ -277,7 +277,7 @@ jobs: - name: Create pull request run: | version="${GITHUB_REF#refs/heads/release/}" - gh pr create -B main -H integrate/merge-benchmarks-to-main --title 'docs: update benchmarks while releasing ${version}' --fill + gh pr create -B main -H integrate/merge-benchmarks-to-main --title "docs: update benchmarks while releasing ${version}" --fill env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}