Skip to content

Commit 5bd2cdc

Browse files
hf-kkleinKonstantin
andauthored
chore(CD): switch from secret API key to Trusted Publishing (#144)
Co-authored-by: Konstantin <[email protected]>
1 parent f11f007 commit 5bd2cdc

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

.github/workflows/dependabot-automerge.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
run: |
1818
curl -s https://github.com/web-flow.gpg | gpg --import
1919
echo "Imported GitHub keys."
20-
20+
2121
echo "Verifying signature of commit: $GITHUB_SHA"
2222
if ! git verify-commit "$GITHUB_SHA"; then
2323
echo "Commit signature verification failed."
@@ -26,4 +26,4 @@ jobs:
2626
- name: Approve a PR
2727
run: gh pr review --approve "$PR_URL"
2828
- name: Enable auto-merge for Dependabot PRs
29-
run: gh pr merge --auto --squash "$PR_URL"
29+
run: gh pr merge --auto --squash "$PR_URL"

.github/workflows/release_nuget.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@ jobs:
3535
push_release:
3636
needs: run_tests
3737
if: startsWith(github.ref, 'refs/tags/v')
38-
runs-on: windows-latest
38+
runs-on: ubuntu-latest
3939
env:
4040
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
41+
environment: "release" # has to match the policy name in the nuget.org Trusted Publishing setup.
42+
# if the environment name is not set here, you'll run into an error message like "Error: Token exchange failed (401): Environment mismatch for policy 'release': expected 'release', actual ''"
43+
# This job is based on the Trusted Publishing Setup.
44+
# See https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing for details.
45+
permissions:
46+
id-token: write # enable GitHub OIDC token issuance for this job
4147
steps:
4248
- uses: actions/checkout@v6
4349
- name: Setup .NET Core
@@ -54,12 +60,13 @@ jobs:
5460
- name: Create Package TransformerBeeClient (dotnet pack)
5561
working-directory: "TransformerBeeClient/TransformerBeeClient"
5662
run: dotnet pack TransformerBeeClient.csproj --configuration Release -p:PackageVersion="${{ steps.tagTBC.outputs.tag }}"
57-
- name: Setup Nuget.exe
58-
uses: warrenbuckley/Setup-Nuget@v1
63+
- name: NuGet login (OIDC → temp API key)
64+
uses: NuGet/login@v1
65+
id: login
66+
with:
67+
user: Hochfrequenz
68+
# because the package is owned by hochfrequenz: https://www.nuget.org/packages/TransformerBeeClient
5969
- name: Nuget push TransformerBeeClient
6070
working-directory: "TransformerBeeClient/TransformerBeeClient"
61-
# token: https://github.com/Hochfrequenz/TransformerBeeClient/settings/secrets/actions/NUGET_ORG_PUSH_TOKEN
62-
# expires 2025-02-01
6371
run: |
64-
nuget setApiKey ${{ secrets.NUGET_ORG_PUSH_TOKEN }}
65-
nuget push .\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -NoSymbols
72+
dotnet nuget push ./bin/Release/*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate

0 commit comments

Comments
 (0)