Update PackageReference conditions for CSharp #1643
Workflow file for this run
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: .NET Build, Test, and Publish Nuget Package | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| pull_request: | |
| branches: | |
| - "**" | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| VERSION: 0.0.0 | |
| defaults: | |
| run: | |
| working-directory: ./ | |
| jobs: | |
| build-test-and-publish: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| dotnet-version: [10.0.x, 8.0.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set Version Variable | |
| if: ${{ github.ref_type == 'tag' }} | |
| env: | |
| TAG: ${{ github.ref_name }} | |
| run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v2 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore --verbosity normal /p:Version=$VERSION | |
| - name: Test | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack and Publish NuGet Package | |
| if: ${{ matrix.dotnet-version == '10.0.x' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') }} | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| dotnet pack --configuration Release --output nupkgs --no-restore --no-build --verbosity normal /p:PackageVersion=$VERSION && \ | |
| dotnet nuget push nupkgs/*.nupkg -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json |