Skip to content

Commit 47c24ba

Browse files
feat(actions): add nuget trusted publishing
1 parent 715c554 commit 47c24ba

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ jobs:
272272
if: github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/v2')
273273
runs-on: ubuntu-latest
274274
needs: [ validate-nuget, run-test, validate-template, validate-docs ]
275+
permissions:
276+
id-token: write
275277
steps:
276278
- uses: actions/download-artifact@v5
277279
with:
@@ -284,5 +286,11 @@ jobs:
284286
- name: 🛠️ Upload library to GitHub Package Repository
285287
run: dotnet nuget push ${{ env.NUGET_DIRECTORY }}/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bunit-dev/index.json --skip-duplicate --no-symbols
286288

289+
- name: 🛠️ NuGet login
290+
uses: NuGet/login@v1
291+
id: nuget-login
292+
with:
293+
user: ${{ secrets.NUGET_USER }}
294+
287295
- name: 🛠️ Upload library to NuGet.org repository
288-
run: dotnet nuget push ${{ env.NUGET_DIRECTORY }}/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
296+
run: dotnet nuget push ${{ env.NUGET_DIRECTORY }}/*.nupkg -k ${{ steps.nuget-login.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ jobs:
101101
dotnet pack src/bunit.web.query/ -c Release --property:PackageOutputPath=${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true
102102
dotnet pack src/bunit.generators/ -c Release --property:PackageOutputPath=${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true
103103
104+
- name: 🛠️ NuGet login
105+
uses: NuGet/login@v1
106+
id: nuget-login
107+
with:
108+
user: ${{ secrets.NUGET_USER }}
109+
104110
- name: 🛠️ Upload library to NuGet.org repository
105111
run: |
106-
dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
112+
dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ steps.nuget-login.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
107113
108114
- name: ⏩ Push stable branch
109115
run: git push origin stable

0 commit comments

Comments
 (0)