Skip to content

Pass API key

Pass API key #185

Workflow file for this run

name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
env:
CI: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 10 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.x"
- name: Install dotnet-coverage
run: dotnet tool install -g dotnet-coverage
- name: Test with coverage
run: dotnet-coverage collect --output coverage.cobertura.xml --output-format cobertura "dotnet test"
- name: Update codecov
if: startsWith(github.repository, 'khellang/')
uses: codecov/codecov-action@v5
with:
files: coverage.cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Pack NuGet package
run: dotnet pack src/Scrutor/Scrutor.csproj --configuration Release --output ./artifacts
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
./artifacts/*.nupkg
./artifacts/*.snupkg
- name: Push to GitHub Packages
if: github.event_name == 'push' && startsWith(github.repository, 'khellang/')
run: dotnet nuget push ./artifacts/*.*nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
publish:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && startsWith(github.repository, 'khellang/')
permissions:
id-token: write
contents: read
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
steps:
- name: Download NuGet package artifact
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./artifacts
- name: Setup .NET 10 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.x"
- name: Authenticate to NuGet.org with OIDC
uses: NuGet/login@v1
id: login
with:
user: khellang
- name: Push to NuGet.org
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate