Release #2
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: "Release" | |
| permissions: | |
| contents: read | |
| packages: write | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' # Triggers on version tags like v1.0.0, v2.1.3, etc. | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 1.0.0)' | |
| required: true | |
| type: string | |
| publish_to_nuget: | |
| description: 'Publish to NuGet.org' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| build: | |
| name: "Builds (.NET ${{ matrix.dotnet-version }})" | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - dotnet-version: '6.0.x' | |
| framework-moniker: 'net6.0' | |
| - dotnet-version: '7.0.x' | |
| framework-moniker: 'net7.0' | |
| - dotnet-version: '8.0.x' | |
| framework-moniker: 'net8.0' | |
| outputs: | |
| version: ${{ steps.determine_version.outputs.version }} | |
| assembly-version: ${{ steps.determine_version.outputs.assembly-version }} | |
| file-version: ${{ steps.determine_version.outputs.file-version }} | |
| informational-version: ${{ steps.determine_version.outputs.informational-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Determine version" | |
| id: determine_version | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| # Manual trigger - use input version | |
| VERSION="${{ github.event.inputs.version }}" | |
| echo "Using manual version: $VERSION" | |
| else | |
| # Tag trigger - extract version from tag | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Extracted version from tag: $VERSION" | |
| fi | |
| # Set version outputs for different version types | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "assembly-version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "file-version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "informational-version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Final version: $VERSION" | |
| - name: "Setup .NET ${{ matrix.dotnet-version }}" | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - name: "Restore" | |
| run: dotnet restore -p:TargetFramework=${{ matrix.framework-moniker }} | |
| - name: "Build" | |
| run: dotnet build -c Release --no-restore --framework ${{ matrix.framework-moniker }} | |
| - name: "Test" | |
| run: dotnet test -c Release --no-restore --no-build --framework ${{ matrix.framework-moniker }} --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.XUnit]*" | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| publish: | |
| name: "Publish Packages" | |
| needs: build | |
| uses: ./.github/workflows/publish-packages.yml | |
| with: | |
| nuget: ${{ github.event_name == 'push' || github.event.inputs.publish_to_nuget == 'true' }} | |
| version: ${{ needs.build.outputs.version }} | |
| assembly-version: ${{ needs.build.outputs.assembly-version }} | |
| file-version: ${{ needs.build.outputs.file-version }} | |
| informational-version: ${{ needs.build.outputs.informational-version }} | |
| clean: | |
| name: "Cleaning Old Packages" | |
| needs: publish | |
| uses: ./.github/workflows/clean-packages.yml |