NuGet Prerelease #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: NuGet Prerelease | |
| on: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-multiplatform: | |
| name: Test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| working-directory: ./src | |
| - name: Build solution | |
| run: dotnet build -c Release --no-restore | |
| working-directory: ./src | |
| - name: Run tests | |
| run: dotnet test -c Release --no-build --no-restore --verbosity normal | |
| working-directory: ./src | |
| publish-prerelease: | |
| runs-on: ubuntu-latest | |
| needs: test-multiplatform | |
| permissions: | |
| contents: read | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: '1' | |
| DOTNET_CLI_TELEMETRY_OPTOUT: '1' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v3 | |
| with: | |
| versionSpec: '6.x' | |
| - name: Calculate version | |
| id: gv | |
| uses: gittools/actions/gitversion/execute@v3 | |
| - name: Log calculated version | |
| run: echo "GitVersion calculated prerelease version ${{ steps.gv.outputs.SemVer }}" | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| working-directory: ./src | |
| - name: Build solution | |
| run: dotnet build -c Release --no-restore -p:Version=${{ steps.gv.outputs.SemVer }} -p:AssemblyVersion=${{ steps.gv.outputs.AssemblySemVer }} -p:FileVersion=${{ steps.gv.outputs.AssemblySemFileVer }} | |
| working-directory: ./src | |
| - name: Run tests | |
| run: dotnet test -c Release --no-build --no-restore --verbosity normal | |
| working-directory: ./src | |
| - name: Pack NuGet packages (incl. symbols) | |
| run: dotnet pack -c Release --no-restore /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg -o ../artifacts -p:Version=${{ steps.gv.outputs.SemVer }} | |
| working-directory: ./src | |
| - name: Ensure packages exist | |
| run: | | |
| shopt -s nullglob | |
| files=(artifacts/*.nupkg artifacts/*.snupkg) | |
| (( ${#files[@]} )) || { echo "::error ::No packages found in artifacts/"; exit 1; } | |
| - name: Upload artifacts (audit) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prerelease-packages-${{ steps.gv.outputs.SemVer }} | |
| path: artifacts | |
| retention-days: 30 | |
| - name: Push prerelease to NuGet.org | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| shopt -s nullglob | |
| for p in artifacts/*.nupkg artifacts/*.snupkg; do | |
| echo "Pushing prerelease package: $p" | |
| dotnet nuget push "$p" --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" --skip-duplicate | |
| done | |