|  | 
| 1 |  | -# This workflow will build a .NET project | 
| 2 |  | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | 
| 3 |  | - | 
| 4 |  | -name: .NET | 
|  | 1 | +name: Build and Test | 
| 5 | 2 | 
 | 
| 6 | 3 | on: | 
| 7 | 4 |   push: | 
| 8 |  | -    branches: ["main"] | 
|  | 5 | +    branches: [ main ] | 
|  | 6 | +    tags: | 
|  | 7 | +      - '[0-9]+.[0-9]+.[0-9]+*' | 
| 9 | 8 |   pull_request: | 
| 10 |  | -    branches: ["main"] | 
|  | 9 | +    branches: [ main ] | 
| 11 | 10 | 
 | 
| 12 | 11 | jobs: | 
| 13 | 12 |   build: | 
| 14 | 13 |     runs-on: ubuntu-latest | 
| 15 | 14 | 
 | 
| 16 | 15 |     steps: | 
| 17 |  | -      - uses: actions/checkout@v4 | 
| 18 |  | -      - name: Setup .NET | 
| 19 |  | -        uses: actions/setup-dotnet@v4 | 
| 20 |  | -        with: | 
| 21 |  | -          dotnet-version: 8.0.x | 
| 22 |  | -      - name: Restore dependencies | 
| 23 |  | -        run: dotnet restore | 
| 24 |  | -      - name: Build | 
| 25 |  | -        run: dotnet build --no-restore | 
| 26 |  | -      - name: Test | 
| 27 |  | -        run: dotnet test --no-build --verbosity normal | 
|  | 16 | +    - uses: actions/checkout@v3 | 
|  | 17 | +     | 
|  | 18 | +    - name: Setup .NET | 
|  | 19 | +      uses: actions/setup-dotnet@v3 | 
|  | 20 | +      with: | 
|  | 21 | +        dotnet-version: | | 
|  | 22 | +          8.0.x | 
|  | 23 | +          9.0.x | 
|  | 24 | +         | 
|  | 25 | +    - name: Restore dependencies | 
|  | 26 | +      run: dotnet restore | 
|  | 27 | +       | 
|  | 28 | +    - name: Build | 
|  | 29 | +      run: dotnet build --no-restore | 
|  | 30 | +       | 
|  | 31 | +    - name: Test | 
|  | 32 | +      run: dotnet test --no-build --verbosity normal | 
|  | 33 | +       | 
|  | 34 | +    - name: Get version from tag | 
|  | 35 | +      if: startsWith(github.ref, 'refs/tags/') | 
|  | 36 | +      id: get_version | 
|  | 37 | +      run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | 
|  | 38 | +       | 
|  | 39 | +    - name: Build Release configuration | 
|  | 40 | +      if: startsWith(github.ref, 'refs/tags/') | 
|  | 41 | +      run: dotnet build --configuration Release /p:Version=${{ steps.get_version.outputs.VERSION }} --no-restore | 
|  | 42 | +       | 
|  | 43 | +    - name: Pack | 
|  | 44 | +      if: startsWith(github.ref, 'refs/tags/') | 
|  | 45 | +      run: dotnet pack --no-build --configuration Release /p:Version=${{ steps.get_version.outputs.VERSION }} --output ./nupkgs | 
|  | 46 | +       | 
|  | 47 | +    - name: Publish to NuGet | 
|  | 48 | +      if: startsWith(github.ref, 'refs/tags/') | 
|  | 49 | +      run: | | 
|  | 50 | +        dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | 
0 commit comments