chore: Release version 3.0.0 #13
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: CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_dispatch: | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_NOLOGO: true | |
| NUGET_DIRECTORY: ${{ github.workspace }}/nuget | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore --configuration Release | |
| - name: Test | |
| run: dotnet test --no-build --configuration Release --verbosity normal --logger "console;verbosity=detailed" --collect:"XPlat Code Coverage" | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: '**/coverage.cobertura.xml' | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| pack: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Get version | |
| id: version | |
| run: | | |
| BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
| VERSION=1.0.0-${BRANCH_NAME}-${GITHUB_SHA::7} | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build and Pack | |
| run: | | |
| dotnet build --configuration Release --no-restore | |
| dotnet pack --configuration Release --no-build /p:Version=${{ steps.version.outputs.VERSION }} --output ${{ env.NUGET_DIRECTORY }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget | |
| if-no-files-found: error | |
| retention-days: 7 | |
| path: ${{ env.NUGET_DIRECTORY }}/*.nupkg | |
| publish-preview: | |
| runs-on: ubuntu-latest | |
| needs: pack | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| permissions: | |
| packages: write | |
| contents: read | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget | |
| path: ${{ env.NUGET_DIRECTORY }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Publish to GitHub Packages | |
| run: | | |
| for file in ${{ env.NUGET_DIRECTORY }}/*.nupkg | |
| do | |
| dotnet nuget push "$file" --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --skip-duplicate | |
| done | |
| - name: Publish to NuGet.org (Preview) | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| continue-on-error: true | |
| run: | | |
| if [ -n "${{ secrets.NUGET_API_KEY }}" ]; then | |
| for file in ${{ env.NUGET_DIRECTORY }}/*.nupkg | |
| do | |
| dotnet nuget push "$file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| done | |
| else | |
| echo "NUGET_API_KEY not set, skipping NuGet.org publish" | |
| fi |