Skip to content

Commit fa71e98

Browse files
singhpratechclaude
andcommitted
ci: publish-nuget.yml -- nuget.org trusted publishing, mirroring publish-pypi.yml
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QhuLMRciVAQdqKEpyr7Wbo
1 parent 5dd69f8 commit fa71e98

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Copyright 2026 the adbcbridge authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
# Publish a tagged release's NuGet package to nuget.org through trusted
18+
# publishing (short-lived API key from NuGet/login, no stored secret). Needs, on
19+
# nuget.org, a trusted publishing policy for repository owner "singhpratech",
20+
# repository "adbcbridge", workflow "publish-nuget.yml", environment "nuget" --
21+
# and a GitHub environment named "nuget" on this repository. Run by hand with
22+
# the tag once the Release workflow has published that tag; the nuget.org user
23+
# name is the account that owns the policy.
24+
25+
name: Publish to NuGet
26+
27+
on:
28+
workflow_dispatch:
29+
inputs:
30+
tag:
31+
description: "Published release tag, e.g. v0.1.0"
32+
required: true
33+
nuget_user:
34+
description: "nuget.org user name that owns the trusted publishing policy"
35+
required: true
36+
37+
permissions:
38+
contents: read
39+
40+
jobs:
41+
nuget:
42+
name: Publish ${{ inputs.tag }}
43+
runs-on: ubuntu-latest
44+
environment: nuget
45+
permissions:
46+
id-token: write
47+
contents: read
48+
env:
49+
GH_TOKEN: ${{ github.token }}
50+
steps:
51+
- name: Fetch the package from the release
52+
run: |
53+
mkdir -p dist && cd dist
54+
gh release download "${{ inputs.tag }}" --repo "${{ github.repository }}" --pattern '*.nupkg'
55+
ls -l
56+
- uses: actions/setup-dotnet@v4
57+
with:
58+
dotnet-version: '8.0.x'
59+
- name: Get a short-lived API key from nuget.org
60+
id: login
61+
uses: NuGet/login@v1
62+
with:
63+
user: ${{ inputs.nuget_user }}
64+
- name: Push
65+
run: |
66+
dotnet nuget push dist/*.nupkg \
67+
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
68+
--source https://api.nuget.org/v3/index.json \
69+
--skip-duplicate

0 commit comments

Comments
 (0)