Skip to content

Commit e9d147e

Browse files
authored
Merge pull request #245 from Cysharp/ci/nuget
ci: use OIDC for NuGet package push authentication
2 parents 7f8ed06 + 7d95d2d commit e9d147e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

.github/workflows/build-debug.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ jobs:
2424
# Native AOT tests
2525
- run: dotnet publish -r linux-x64 tests/ConsoleAppFramework.NativeAotTests/ConsoleAppFramework.NativeAotTests.csproj
2626
- run: tests/ConsoleAppFramework.NativeAotTests/bin/Release/net10.0/linux-x64/publish/ConsoleAppFramework.NativeAotTests
27-
2827
- run: dotnet pack -c Release --no-build -p:IncludeSymbols=true -o $GITHUB_WORKSPACE/artifacts

.github/workflows/build-release.yaml

Lines changed: 14 additions & 3 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:
@@ -26,13 +27,23 @@ jobs:
2627
# Native AOT tests
2728
- run: dotnet publish -r linux-x64 tests/ConsoleAppFramework.NativeAotTests/ConsoleAppFramework.NativeAotTests.csproj
2829
- run: tests/ConsoleAppFramework.NativeAotTests/bin/Release/net10.0/linux-x64/publish/ConsoleAppFramework.NativeAotTests
29-
# pack nuget
30-
- run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -o ./publish
30+
# pack nuget (.nupkg and .symbols.nupkg will be created)
31+
- run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -p:IncludeSymbols=true -o ./publish
3132
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
3233
with:
3334
name: nuget
3435
path: ./publish
3536
retention-days: 1
37+
# push nuget
38+
- name: NuGet login (OIDC)
39+
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
40+
id: login
41+
with:
42+
user: ${{ secrets.NUGET_USER }}
43+
- run: dotnet nuget push "./publish/*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
44+
if: ${{ !inputs.dry-run }}
45+
env:
46+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
3647

3748
# release
3849
create-release:
@@ -45,5 +56,5 @@ jobs:
4556
commit-id: ${{ github.sha }}
4657
dry-run: ${{ inputs.dry-run }}
4758
tag: ${{ inputs.tag }}
48-
nuget-push: true
59+
nuget-push: false
4960
secrets: inherit

0 commit comments

Comments
 (0)