From a4085dd259f7f5bceb517392a036366d1e302f16 Mon Sep 17 00:00:00 2001 From: Joe Harvey Date: Fri, 30 Oct 2026 10:56:40 +0000 Subject: [PATCH 1/3] update workflow to build on tags --- .github/workflows/dotnet.yml | 59 ++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index cbbc3db..49e6e74 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,40 +1,47 @@ +# Builds the project, runs tests and creates NuGet packages. +# Triggers on pushes to main and version tags, and pull requests targeting main. + name: .NET on: push: - branches: [ main ] + branches: + - main + tags: + - '[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+-*' pull_request: - branches: [ main ] + branches: + - main + workflow_dispatch: jobs: build: - - strategy: + strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup .NET 10 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '10.0.x' - - name: Restore - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore - - name: Test - run: dotnet test --no-restore --verbosity normal - - name: Pack - if: matrix.os == 'ubuntu-latest' - run: dotnet pack -c Release - - name: upload artifact - if: matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v4 - with: - name: nupkg - path: '**/*.nupkg' + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup .NET 10 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: Run build script + run: bash ./build.sh + + - name: Upload NuGet packages + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: nuget-packages + path: nuget/ + if-no-files-found: error \ No newline at end of file From 48c04900bad0dcab1c99422815fcaebb381ebaba Mon Sep 17 00:00:00 2001 From: Joe Harvey Date: Fri, 30 Oct 2026 12:18:46 +0000 Subject: [PATCH 2/3] update workflow to build on tags --- .github/workflows/dotnet.yml | 43 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 49e6e74..7bc4318 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -24,24 +24,25 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - name: Setup .NET 10 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 10.0.x - - - name: Run build script - run: bash ./build.sh - - - name: Upload NuGet packages - if: matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v4 - with: - name: nuget-packages - path: nuget/ - if-no-files-found: error \ No newline at end of file + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup .NET 10 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + - name: Restore + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test + run: dotnet test --no-restore --verbosity normal + - name: Pack + if: matrix.os == 'ubuntu-latest' + run: dotnet pack -c Release + - name: upload artifact + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: nupkg + path: '**/*.nupkg' From 0bbcf5932c452043ad40b5cac71a9a2f83038e18 Mon Sep 17 00:00:00 2001 From: Patrick Allwood Date: Fri, 30 Oct 2026 14:07:40 +0000 Subject: [PATCH 3/3] Add nuget publish workflow --- .github/workflows/nuget-publish.yml | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/nuget-publish.yml diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml new file mode 100644 index 0000000..2b62db8 --- /dev/null +++ b/.github/workflows/nuget-publish.yml @@ -0,0 +1,66 @@ +# Publishes NuGet packages to NuGet.org using trusted publishing. +# Triggers when a version tag push causes the .NET CI workflow to complete successfully. +# Requires reviewer approval for the nuget-publish environment + +name: Publish NuGet Packages + +on: + workflow_run: + workflows: [".NET"] + types: [completed] + +jobs: + check-tag: + name: Check version tag + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' + outputs: + is-version-tag: ${{ steps.check.outputs.is-version-tag }} + steps: + - name: Check if triggered by a version tag + id: check + run: | + if [[ "${{ github.event.workflow_run.head_branch }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then + echo "is-version-tag=true" >> "$GITHUB_OUTPUT" + else + echo "is-version-tag=false" >> "$GITHUB_OUTPUT" + fi + + publish: + name: Publish to NuGet.org + runs-on: ubuntu-latest + needs: check-tag + if: needs.check-tag.outputs.is-version-tag == 'true' + + environment: nuget-publish + + permissions: + id-token: write + contents: read + + steps: + - name: Download NuGet packages artifact + uses: actions/download-artifact@v4 + with: + name: nupkg + path: nuget/ + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: NuGet login + uses: NuGet/login@v1 + id: login + with: + user: ${{ secrets.NUGET_USER }} + + - name: NuGet push + run: | + dotnet nuget push "nuget/**/*.nupkg" \ + --api-key ${{steps.login.outputs.NUGET_API_KEY}} \ + --source "https://api.nuget.org/v3/index.json" \ + --skip-duplicate