mirror of
https://github.com/Empostor/Empostor.git
synced 2026-10-19 15:51:39 +00:00
ci: use nuget.org trusted publishing (OIDC) instead of static key
This commit is contained in:
1 parent
2651a93230
commit
bcd18b7d85
1 file changed
+13
-8
@@ -11,6 +11,9 @@ on:
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -44,21 +47,23 @@ jobs:
|
||||
- name: Pack
|
||||
run: dotnet pack src/Empostor.Api/Empostor.Api.csproj -c Release -p:VersionSuffix=${{ steps.ver.outputs.suffix }} -p:GeneratePackageOnBuild=false -o artifacts --nologo
|
||||
|
||||
# Trusted publishing: exchanges the GitHub OIDC token for a short-lived
|
||||
# nuget.org API key tied to the policy (no secret needed).
|
||||
- name: NuGet login (trusted publishing)
|
||||
uses: NuGet/login@v1
|
||||
id: login
|
||||
with:
|
||||
user: ELinmei
|
||||
|
||||
- name: Push to nuget.org
|
||||
env:
|
||||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ls -la artifacts
|
||||
if [ -z "$NUGET_API_KEY" ]; then
|
||||
echo "::warning::NUGET_API_KEY secret is not set; skipping push."
|
||||
exit 0
|
||||
fi
|
||||
dotnet nuget push "artifacts/Empostor.Api.*.nupkg" \
|
||||
--api-key "$NUGET_API_KEY" \
|
||||
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
|
||||
--source https://api.nuget.org/v3/index.json \
|
||||
--skip-duplicate
|
||||
dotnet nuget push "artifacts/Empostor.Api.*.snupkg" \
|
||||
--api-key "$NUGET_API_KEY" \
|
||||
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
|
||||
--source https://api.nuget.org/v3/index.json \
|
||||
--skip-duplicate || true
|
||||
Reference in new issue
Block a user