Skip to content

Commit eacbe82

Browse files
Publish to NuGet.org
Publish NuGet packages built from tags to NuGet.org.
1 parent d418b5a commit eacbe82

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,45 @@ jobs:
119119
Write-Output "::error::$invalidPackages NuGet package(s) failed validation."
120120
exit 1
121121
}
122+
123+
publish-nuget:
124+
needs: [ build-test, validate-packages ]
125+
runs-on: ubuntu-latest
126+
if: |
127+
github.event.repository.fork == false &&
128+
startsWith(github.ref, 'refs/tags/')
129+
130+
environment:
131+
name: NuGet.org
132+
url: https://www.nuget.org/profiles/Grafana
133+
134+
permissions:
135+
contents: read
136+
id-token: write
137+
138+
steps:
139+
140+
- name: Download packages
141+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
142+
with:
143+
name: packages-windows
144+
145+
- name: Setup .NET SDK
146+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
147+
with:
148+
dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }}
149+
150+
# TODO Store the NuGet token in Vault
151+
- uses: grafana/shared-workflows/actions/get-vault-secrets@9f37f656e063f0ad0b0bfc38d49894b57d363936 # get-vault-secrets/v1.2.1
152+
id: get-token
153+
with:
154+
export_env: false
155+
repo_secrets: |
156+
token=nuget:token
157+
158+
- name: Push NuGet packages to NuGet.org
159+
shell: bash
160+
env:
161+
API_KEY: ${{ fromJSON(steps.get-token.outputs.secrets).token }}
162+
SOURCE: 'https://api.nuget.org/v3/index.json'
163+
run: dotnet nuget push "*.nupkg" --api-key "${API_KEY}" --skip-duplicate --source "${SOURCE}"

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ jobs:
2424
- name: Review dependencies
2525
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
2626
with:
27+
allow-dependencies-licenses: 'pkg:githubactions/grafana/shared-workflows/actions/get-vault-secrets'
2728
allow-licenses: 'Apache-2.0,BSD-3-Clause,MIT'

0 commit comments

Comments
 (0)