From 538e130d0153d9169262a7c94433476371408399 Mon Sep 17 00:00:00 2001 From: Jeremy Cantu Date: Sun, 5 Apr 2026 12:15:22 -0500 Subject: [PATCH] Add release workflow --- .github/workflows/ci.yml | 6 ++-- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c13aa9..401f6e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,15 +24,15 @@ jobs: - name: Restore run: dotnet restore BlockingCollectionExtensions.sln + - name: Test + run: dotnet test BlockingCollectionExtensions.sln --configuration Release --no-restore + - name: Build net8.0 run: dotnet build BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --framework net8.0 --no-restore - name: Build netstandard2.1 run: dotnet build BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --framework netstandard2.1 --no-restore - - name: Pack - run: dotnet pack BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --no-build -p:EnablePackageValidation=true -o artifacts - - name: Upload package artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f59be18 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Release + +on: + workflow_dispatch: + inputs: + publish_to_nuget: + description: Publish packages to NuGet + required: true + default: false + type: boolean + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 8.0.x + + - name: Restore + run: dotnet restore BlockingCollectionExtensions.sln + + - name: Test + run: dotnet test BlockingCollectionExtensions.sln --configuration Release --no-restore + + - name: Build net8.0 + run: dotnet build BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --framework net8.0 --no-restore + + - name: Build netstandard2.1 + run: dotnet build BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --framework netstandard2.1 --no-restore + + - name: Pack + run: dotnet pack BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --no-build -p:EnablePackageValidation=true -o artifacts + + - name: Upload package artifacts + uses: actions/upload-artifact@v4 + with: + name: release-packages + path: artifacts/* + + - name: Publish to NuGet + if: startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_nuget + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: | + test -n "$NUGET_API_KEY" + dotnet nuget push "artifacts/*.nupkg" \ + --api-key "$NUGET_API_KEY" \ + --source https://api.nuget.org/v3/index.json \ + --skip-duplicate