Skip to content

Commit 284cc87

Browse files
Update nbgv_prepare_release.yml
1 parent a43de51 commit 284cc87

1 file changed

Lines changed: 14 additions & 37 deletions

File tree

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# shared-workflows/.github/workflows/nbgv_prepare_release.yml
21
name: NBGV Prepare Release
32

43
on:
@@ -16,61 +15,39 @@ on:
1615
default: patch
1716
secrets:
1817
GH_TOKEN:
19-
description: "GitHub token (falls back to github.token)"
18+
description: "GitHub token (falls back to github.token if not provided)"
2019
required: false
2120

2221
jobs:
2322
prep:
2423
runs-on: ubuntu-latest
25-
env:
26-
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
27-
2824
steps:
29-
# 1️⃣ Checkout the code
30-
- name: 📥 Checkout target branch
25+
- name: 📥 Checkout target
3126
uses: actions/checkout@v4
3227
with:
3328
ref: ${{ inputs.target_branch }}
3429
fetch-depth: 0
35-
token: ${{ env.GH_TOKEN }}
30+
token: ${{ secrets.GH_TOKEN || github.token }}
3631

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

45-
# 3️⃣ Inject omitCommitId so your NuGet version has no git‐hash suffix
46-
- name: 🖊️ Inject omitCommitId into version.json
37+
- name: 🖊️ (Optional) Inject omitCommitId
38+
if: always()
4739
run: |
40+
# Only do this if you truly need to suppress the +g<hash> suffix
4841
tmp=$(mktemp)
4942
jq '.release += {"omitCommitId": true}' version.json > "$tmp"
5043
mv "$tmp" version.json
5144
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"
45+
- name: 🛠️ Bump version & create branch
46+
id: nbgv
47+
uses: dotnet/nbgv@master
48+
with:
49+
version-increment: ${{ inputs.increment }}
50+
version-file: version.json
7451

7552
outputs:
76-
release_branch: ${{ steps.prepare.outputs.release_branch }}
53+
release_branch: ${{ steps.nbgv.outputs.BranchName }}

0 commit comments

Comments
 (0)