Skip to content

Commit e5acc10

Browse files
authored
Merge pull request #715 from Cysharp/ci/nuget
ci: use OIDC for NuGet package push authentication
2 parents 2e993ff + b0d26be commit e5acc10

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

.github/workflows/build-release.yaml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
with:
3636
ref: ${{ needs.update-packagejson.outputs.sha }}
3737
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
38-
# build and pack
38+
# build and pack nuget (.nupkg and .symbols.nupkg will be created)
3939
- run: dotnet build -c Release -p:Version=${{ inputs.tag }}
4040
- run: dotnet test -c Release --no-build
41-
- run: dotnet pack ./src/UniTask.NetCore/UniTask.NetCore.csproj -c Release --no-build -p:Version=${{ inputs.tag }} -o ./publish
41+
- run: dotnet pack ./src/UniTask.NetCore/UniTask.NetCore.csproj -c Release --no-build -p:Version=${{ inputs.tag }} -p:IncludeSymbols=true -o ./publish
4242
# Store artifacts.
4343
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
4444
with:
@@ -96,9 +96,32 @@ jobs:
9696
path: ./src/UniTask/UniTask.${{ inputs.tag }}.unitypackage
9797
retention-days: 1
9898

99+
# publish
100+
publish:
101+
name: "Publish NuGet packages"
102+
needs: [build-dotnet, build-unity]
103+
permissions:
104+
contents: read
105+
id-token: write # required for NuGet Trusted Publish
106+
runs-on: ubuntu-24.04
107+
timeout-minutes: 10
108+
steps:
109+
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
110+
- uses: Cysharp/Actions/.github/actions/download-artifact@main
111+
# push nuget
112+
- name: NuGet login (OIDC)
113+
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
114+
id: login
115+
with:
116+
user: ${{ secrets.NUGET_USER }}
117+
- run: dotnet nuget push "./nuget/*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
118+
if: ${{ !inputs.dry-run }}
119+
env:
120+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
121+
99122
# release
100123
create-release:
101-
needs: [update-packagejson, build-dotnet, build-unity]
124+
needs: [update-packagejson, publish]
102125
permissions:
103126
contents: write
104127
id-token: write # required for NuGet Trusted Publish
@@ -107,14 +130,14 @@ jobs:
107130
commit-id: ${{ needs.update-packagejson.outputs.sha }}
108131
dry-run: ${{ inputs.dry-run }}
109132
tag: ${{ inputs.tag }}
110-
nuget-push: true
133+
nuget-push: false
111134
release-upload: true
112135
release-asset-path: ./UniTask.${{ inputs.tag }}.unitypackage/UniTask.${{ inputs.tag }}.unitypackage
113136
secrets: inherit
114137

115138
cleanup:
116139
if: ${{ needs.update-packagejson.outputs.is-branch-created == 'true' }}
117-
needs: [update-packagejson, build-dotnet, build-unity]
140+
needs: [update-packagejson, create-release]
118141
permissions:
119142
contents: write
120143
uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main

0 commit comments

Comments
 (0)