diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 495de05a7..6ba1bf1c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,16 +8,30 @@ on: jobs: publish-nuget-package: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # lets NuGet/login request a GitHub OIDC token for trusted publishing steps: - uses: actions/checkout@v3 - name: Setup .NET Core SDK uses: actions/setup-dotnet@v2.1.1 - - name: Upload to Nuget - env: - NUGET_DEPLOY_KEY: ${{ secrets.NUGET_DEPLOY_KEY }} + - name: Pack run: | cd websocket-sharp/websocket-sharp-netstandard dotnet pack altwebsocket-sharp.csproj -c release - dotnet nuget push bin/release/AltWebSocketSharp.1.0.10.nupkg --api-key $NUGET_DEPLOY_KEY --source https://api.nuget.org/v3/index.json + + # Exchanges the OIDC token for a short-lived API key, using the trusted + # publishing policy on nuget.org. NUGET_USER is the nuget.org profile + # name (not the email) of the account that created that policy. + - name: NuGet login + uses: NuGet/login@v1 + id: nuget-login + with: + user: ${{ secrets.NUGET_USER }} + + - name: Upload to Nuget + run: | + cd websocket-sharp/websocket-sharp-netstandard + dotnet nuget push bin/release/AltWebSocketSharp.1.0.10.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json