Skip to content

Commit cc053b4

Browse files
authored
Merge pull request #122 from Cysharp/ci/nuget
ci: use OIDC for NuGet package push authentication
2 parents 981d550 + 67bed59 commit cc053b4

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/build-debug.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
2020
- run: dotnet build -c Release
2121
- run: dotnet test -c Release --no-build
22-
- run: dotnet pack -c Release --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -o $GITHUB_WORKSPACE/artifacts
22+
- run: dotnet pack -c Release --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -o $GITHUB_WORKSPACE/artifacts

.github/workflows/build-release.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
build-dotnet:
1717
permissions:
1818
contents: read
19+
id-token: write # required for NuGet Trusted Publish
1920
runs-on: ubuntu-24.04
2021
timeout-minutes: 10
2122
steps:
@@ -24,13 +25,27 @@ jobs:
2425
# build and pack
2526
- run: dotnet build -c Release -p:Version=${{ inputs.tag }}
2627
- run: dotnet test -c Release --no-build
27-
- run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -o ./publish
28+
- run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -o ./publish
2829
# Store artifacts.
2930
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
3031
with:
3132
name: nuget
3233
path: ./publish/
3334
retention-days: 1
35+
# push nuget
36+
- name: NuGet login (OIDC)
37+
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
38+
id: login
39+
with:
40+
user: ${{ secrets.NUGET_USER }}
41+
- run: dotnet nuget push "./publish/*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
42+
if: ${{ !inputs.dry-run }}
43+
env:
44+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
45+
- run: dotnet nuget push "./publish/*.snupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
46+
if: ${{ !inputs.dry-run }}
47+
env:
48+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
3449

3550
# release
3651
create-release:
@@ -43,6 +58,6 @@ jobs:
4358
commit-id: ${{ github.sha }}
4459
dry-run: ${{ inputs.dry-run }}
4560
tag: ${{ inputs.tag }}
46-
nuget-push: true
61+
nuget-push: false
4762
release-upload: false
4863
secrets: inherit

0 commit comments

Comments
 (0)