Skip to content

Commit cd636ab

Browse files
authored
Updated preview-release.yml to support Trusted Publishing
1 parent 5283590 commit cd636ab

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/preview-release.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ jobs:
88
release-preview:
99
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
1010
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write # enable GitHub OIDC token issuance for this job
1113

1214
steps:
1315
- uses: actions/checkout@v5
16+
- uses: benjlevesque/short-sha@v3.0
17+
id: short-sha
1418
- name: Setup .NET
1519
uses: actions/setup-dotnet@v5
1620
with:
@@ -20,9 +24,15 @@ jobs:
2024
- name: Build TwitchLib.Client
2125
run: dotnet build -c Release --no-restore
2226
- name: Pack TwitchLib.Client
23-
run: dotnet pack TwitchLib.Client.sln -v normal -c Release --no-build --version-suffix "preview.${{ github.run_number }}.${{ github.sha }}"
27+
run: dotnet pack TwitchLib.Client.sln -v normal -c Release --no-build --version-suffix "preview.${{ github.run_number }}.${{ steps.short-sha.outputs.sha }}"
28+
# Get a short-lived NuGet API key
29+
- name: NuGet login (OIDC → temp API key)
30+
uses: NuGet/login@v1
31+
id: login
32+
with:
33+
user: ${{ secrets.NUGET_USER }}
2434
- name: Push to Nuget
25-
run: dotnet nuget push "./artifacts/package/release/*.nupkg" -k ${{ secrets.API_NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json
35+
run: dotnet nuget push "./artifacts/package/release/*.nupkg" --api-key ${{steps.login.outputs.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json
2636
- name: Send Discord Notification
2737
uses: sarisia/actions-status-discord@v1
2838
if: always()

0 commit comments

Comments
 (0)