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 index 062ac79..4c7e309 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,22 @@ name: Release on: + workflow_dispatch: + inputs: + publish_to_nuget: + description: Publish packages to NuGet + required: true + default: false + type: boolean push: tags: - - 'v*' - workflow_dispatch: + - "v*.*.*" jobs: - publish: + release: runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout @@ -28,16 +36,26 @@ jobs: - name: Build netstandard2.1 run: dotnet build BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --framework netstandard2.1 --no-restore + + - name: Test + run: dotnet test BlockingCollectionExtensions.sln --configuration Release --no-restore - name: Pack run: dotnet pack BlockingCollectionExtensions/BlockingCollectionExtensions.csproj --configuration Release --no-build -p:EnablePackageValidation=true -o artifacts - - name: Publish packages to NuGet - if: startsWith(github.ref, 'refs/tags/v') - run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate - - - name: Upload release 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