Skip to content

Commit 0e265e7

Browse files
authored
Merge pull request #3 from Cysharp/ci/nuget
ci: use OIDC for NuGet package push authentication
2 parents d19d799 + 4d24e71 commit 0e265e7

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
@@ -20,4 +20,4 @@ jobs:
2020
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
2121
- run: dotnet build -c Release
2222
- run: dotnet test -c Release --no-build
23-
- run: dotnet pack -c Release --no-build -p:IncludeSymbols=true -o $GITHUB_WORKSPACE/artifacts
23+
- 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,12 +25,26 @@ jobs:
2425
- run: dotnet build -c Release -p:Version=${{ inputs.tag }}
2526
- run: dotnet test -c Release --no-build
2627
# pack nuget
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
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
2930
with:
3031
name: nuget
3132
path: ./publish
3233
retention-days: 1
34+
# push nuget
35+
- name: NuGet login (OIDC)
36+
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
37+
id: login
38+
with:
39+
user: ${{ secrets.NUGET_USER }}
40+
- run: dotnet nuget push "./publish/*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
41+
if: ${{ !inputs.dry-run }}
42+
env:
43+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
44+
- run: dotnet nuget push "./publish/*.snupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
45+
if: ${{ !inputs.dry-run }}
46+
env:
47+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
3348

3449
# release
3550
create-release:
@@ -42,5 +57,5 @@ jobs:
4257
commit-id: ${{ github.sha }}
4358
dry-run: ${{ inputs.dry-run }}
4459
tag: ${{ inputs.tag }}
45-
nuget-push: true
60+
nuget-push: false
4661
secrets: inherit

0 commit comments

Comments
 (0)