Skip to content

Commit 1168a80

Browse files
Update nbgv_prepare_release.yml
1 parent d4f23f8 commit 1168a80

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
1-
# shared-workflows/.github/workflows/nbgv_prepare_release.yml
21
name: NBGV Prepare Release
32

43
on:
54
workflow_call:
65
inputs:
76
target_branch:
8-
description: "Branch or tag to release from"
97
type: string
108
required: true
119
default: main
1210
increment:
13-
description: "Version increment (major | minor | patch)"
1411
type: string
1512
required: true
1613
default: patch
1714
secrets:
1815
GH_TOKEN:
19-
description: "GitHub token (falls back to github.token if not provided)"
2016
required: false
2117

2218
jobs:
2319
prep:
2420
runs-on: ubuntu-latest
25-
env:
26-
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
2721
steps:
2822
- name: 📥 Checkout target branch
2923
uses: actions/checkout@v4
3024
with:
3125
ref: ${{ inputs.target_branch }}
3226
fetch-depth: 0
33-
token: ${{ env.GH_TOKEN }}
27+
token: ${{ secrets.GH_TOKEN || github.token }}
3428

35-
- name: ⚙️ Setup .NET 9.0
29+
- name: ⚙️ Setup .NET & restore NBGV
3630
uses: actions/setup-dotnet@v4
3731
with:
3832
dotnet-version: "9.0.x"
33+
- run: dotnet tool restore
3934

40-
- name: 🛠️ Bump version & create branch
41-
id: nbgv
42-
uses: dotnet/nbgv@master
43-
with:
44-
version-increment: ${{ inputs.increment }} # major | minor | patch
45-
version-file: version.json # explicitly point at your file
35+
- name: 🖊️ Inject omitCommitId into version.json
36+
run: |
37+
# Backup and rewrite version.json to include omitCommitId=true
38+
jq '.release +={"omitCommitId": true}' version.json > version.tmp.json
39+
mv version.tmp.json version.json
40+
41+
- name: 🗂️ Prepare release
42+
id: prepare
43+
run: |
44+
git config user.name "release-bot"
45+
git config user.email "release-bot@users.noreply.github.com"
46+
47+
INC=${{ inputs.increment }}
48+
case "$INC" in
49+
major) FLAGS="--versionIncrement major" ;;
50+
minor) FLAGS="--versionIncrement minor" ;;
51+
patch) FLAGS="" ;;
52+
esac
53+
54+
dotnet nbgv prepare-release --project "$GITHUB_WORKSPACE" $FLAGS
55+
56+
echo "release_branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
4657
4758
outputs:
48-
release_branch: ${{ steps.nbgv.outputs.BranchName }}
59+
release_branch: ${{ steps.prepare.outputs.release_branch }}

0 commit comments

Comments
 (0)