Skip to content

Commit a43de51

Browse files
Update nbgv_prepare_release.yml
1 parent 591aef3 commit a43de51

1 file changed

Lines changed: 41 additions & 10 deletions

File tree

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shared-workflows/.github/workflows/nbgv_prepare_release.yml
12
name: NBGV Prepare Release
23

34
on:
@@ -15,31 +16,61 @@ on:
1516
default: patch
1617
secrets:
1718
GH_TOKEN:
18-
description: "GitHub token (falls back to github.token if not provided)"
19+
description: "GitHub token (falls back to github.token)"
1920
required: false
2021

2122
jobs:
2223
prep:
2324
runs-on: ubuntu-latest
25+
env:
26+
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
27+
2428
steps:
29+
# 1️⃣ Checkout the code
2530
- name: 📥 Checkout target branch
2631
uses: actions/checkout@v4
2732
with:
2833
ref: ${{ inputs.target_branch }}
2934
fetch-depth: 0
30-
token: ${{ secrets.GH_TOKEN || github.token }}
35+
token: ${{ env.GH_TOKEN }}
3136

32-
- name: ⚙️ Setup .NET 9.x
37+
# 2️⃣ Install .NET & the NBGV tool
38+
- name: ⚙️ Setup .NET & restore NBGV tool
3339
uses: actions/setup-dotnet@v4
3440
with:
3541
dotnet-version: 9.0.x
42+
- name: 🔧 Restore NBGV CLI
43+
run: dotnet tool restore
3644

37-
- name: 🛠️ Bump version & create branch
38-
id: nbgv
39-
uses: dotnet/nbgv@master
40-
with:
41-
version-increment: ${{ inputs.increment }}
42-
version-file: version.json
45+
# 3️⃣ Inject omitCommitId so your NuGet version has no git‐hash suffix
46+
- name: 🖊️ Inject omitCommitId into version.json
47+
run: |
48+
tmp=$(mktemp)
49+
jq '.release += {"omitCommitId": true}' version.json > "$tmp"
50+
mv "$tmp" version.json
51+
52+
# 4️⃣ Bump the version, create the release branch
53+
- name: 🗂️ Prepare release
54+
id: prepare
55+
run: |
56+
cd "$GITHUB_WORKSPACE"
57+
58+
git config user.name "release-bot"
59+
git config user.email "release-bot@users.noreply.github.com"
60+
61+
INC=${{ inputs.increment }}
62+
case "$INC" in
63+
major) FLAGS="--versionIncrement major" ;;
64+
minor) FLAGS="--versionIncrement minor" ;;
65+
patch) FLAGS="" ;; # omit for revision bump
66+
*) echo "Invalid increment: $INC" && exit 1 ;;
67+
esac
68+
69+
# Force Nerdbank to load your version.json (which starts at 1.0.0)
70+
dotnet nbgv prepare-release -p "$GITHUB_WORKSPACE" $FLAGS
71+
72+
# Export the new branch name
73+
echo "release_branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
4374
4475
outputs:
45-
release_branch: ${{ steps.nbgv.outputs.BranchName }}
76+
release_branch: ${{ steps.prepare.outputs.release_branch }}

0 commit comments

Comments
 (0)