Skip to content

Commit 769c4e2

Browse files
Create nbgv_dotnet_pack.yml
1 parent f461005 commit 769c4e2

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: nbgv_dotnet_pack
2+
3+
###############################################################################
4+
# Builds, packs, and (optionally) pushes NuGet packages with deterministic
5+
# Nerdbank.GitVersioning versions. Supports Release / Develop configs and a
6+
# flag to force “-dev” prerelease tags even on main.
7+
#
8+
# Called from consumer repos via:
9+
# uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_dotnet_pack.yml@main
10+
###############################################################################
11+
12+
on:
13+
workflow_call:
14+
inputs:
15+
build_configuration:
16+
description: "MSBuild configuration (Release, Develop, Debug …)"
17+
required: false
18+
type: string
19+
default: "Release"
20+
21+
dotnet_version:
22+
description: ".NET SDK channel"
23+
required: false
24+
type: string
25+
default: "9.0.x"
26+
27+
push_after_pack:
28+
description: "Push the .nupkg to nuget_source?"
29+
required: false
30+
type: boolean
31+
default: false
32+
33+
nuget_source:
34+
description: "Feed URL"
35+
required: false
36+
type: string
37+
default: "https://api.nuget.org/v3/index.json"
38+
39+
force_dev_prerelease:
40+
description: "Force -dev prerelease tag even on main/release branches"
41+
required: false
42+
type: boolean
43+
default: false
44+
45+
secrets:
46+
NUGET_API_KEY:
47+
description: "API key for nuget_source (needed if push_after_pack=true)"
48+
required: false
49+
50+
jobs:
51+
build-pack:
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- name: ⬇️ Checkout
56+
uses: actions/checkout@v4
57+
with: { fetch-depth: 0 }
58+
59+
- name: 🛠️ Setup .NET
60+
uses: actions/setup-dotnet@v4
61+
with:
62+
dotnet-version: ${{ inputs.dotnet_version }}
63+
64+
- name: 🔧 Restore local tools
65+
run: dotnet tool restore
66+
67+
- name: 📜 Compute version (NBGV)
68+
run: dotnet nbgv cloud -v q
69+
70+
- name: 🏗️ Build
71+
run: |
72+
EXTRA=""
73+
if [ "${{ inputs.force_dev_prerelease }}" = "true" ]; then
74+
EXTRA="-p:NBGV_PublicRelease=false"
75+
fi
76+
dotnet build -c ${{ inputs.build_configuration }} $EXTRA
77+
78+
- name: 📦 Pack
79+
run: |
80+
EXTRA=""
81+
if [ "${{ inputs.force_dev_prerelease }}" = "true" ]; then
82+
EXTRA="-p:NBGV_PublicRelease=false"
83+
fi
84+
dotnet pack -c ${{ inputs.build_configuration }} -o output $EXTRA
85+
86+
- name: 🚀 Push to NuGet
87+
if: inputs.push_after_pack == true
88+
run: |
89+
dotnet nuget push "output/*.nupkg" \
90+
--source "${{ inputs.nuget_source }}" \
91+
--api-key "${{ secrets.NUGET_API_KEY }}" \
92+
--skip-duplicate

0 commit comments

Comments
 (0)