name: CI on: push: branches: [main] tags: ["v*"] pull_request: branches: [main] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: dotnet-version: "10.0.x" - name: Restore run: dotnet restore # Directory.Build.props turns warnings into errors, so this also gates style. - name: Build run: dotnet build --configuration Release --no-restore - name: Pack run: dotnet pack src/CertifiEd.Client/CertifiEd.Client.csproj --configuration Release --no-build --output artifacts - name: Upload package artifacts uses: actions/upload-artifact@v3 with: name: nupkg path: artifacts/* publish: # Tag pushes only: v1.2.3 publishes version 1.2.3 to nuget.org. needs: build if: startsWith(gitea.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: dotnet-version: "10.0.x" - name: Derive version from tag id: version run: echo "value=${GITEA_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" env: GITEA_REF: ${{ gitea.ref }} - name: Pack run: > dotnet pack src/CertifiEd.Client/CertifiEd.Client.csproj --configuration Release -p:Version=${{ steps.version.outputs.value }} --output artifacts # NUGET_API_KEY must be added as a repository secret. Without it the step # fails loudly rather than silently shipping nothing. - name: Push to nuget.org run: > dotnet nuget push "artifacts/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY" --skip-duplicate env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}