Skip to content

Commit ad9fad3

Browse files
Update nbgv_prepare_release.yml
1 parent b690729 commit ad9fad3

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed
Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,53 @@
1-
name: nbgv_prepare_release
1+
name: "NBGV: Prepare Release"
22

33
on:
44
workflow_call:
55
inputs:
66
target_branch:
77
type: string
8-
description: "Branch / tag to release from"
98
default: main
10-
required: true
11-
129
increment:
13-
description: "Which version component to bump: major, minor, or patch" # (patch means 'revision')
14-
required: true
1510
type: string
16-
11+
default: patch
1712
secrets:
18-
# The caller repo’s GITHUB_TOKEN is passed automatically; override if desired
1913
GH_TOKEN:
20-
description: "Personal-access token if you need extra perms"
2114
required: false
2215

2316
jobs:
24-
prepare-release:
17+
prep:
2518
runs-on: ubuntu-latest
2619
env:
27-
DOTNET_NOLOGO: true
28-
20+
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
2921
steps:
30-
- name: ⬇️ Checkout full history
22+
- name: Checkout
3123
uses: actions/checkout@v4
3224
with:
3325
ref: ${{ inputs.target_branch }}
34-
fetch-depth: 0 # required for commit-height math
35-
token: ${{ secrets.GH_TOKEN || github.token }}
26+
fetch-depth: 0
27+
token: ${{ env.GH_TOKEN }}
3628

37-
- name: 🛠️ Setup .NET SDK
29+
- name: Setup .NET & NBGV
3830
uses: actions/setup-dotnet@v4
3931
with:
4032
dotnet-version: 9.0.x
33+
- run: dotnet tool restore
4134

42-
- name: 🔧 Restore local tools
43-
run: dotnet tool restore
44-
45-
- name: 🗂️ Prepare release branch
46-
id: prep
35+
- name: 🗂️ Prepare release
36+
id: prepare
4737
run: |
48-
# Configure a generic bot identity for the commit
4938
git config user.name "release-bot"
5039
git config user.email "release-bot@users.noreply.github.com"
5140
52-
# ---- create release branch & bump versions ----
53-
dotnet nbgv prepare-release --versionIncrement ${{ inputs.increment }}
41+
INC=${{ inputs.increment }}
42+
case "$INC" in
43+
major) FLAGS="--versionIncrement major" ;;
44+
minor) FLAGS="--versionIncrement minor" ;;
45+
patch) FLAGS="" ;;
46+
*) echo "Invalid increment: $INC" && exit 1 ;;
47+
esac
5448
55-
# Grab the branch name NBGV just created, e.g. release/v1.2
56-
BRANCH=$(git rev-parse --abbrev-ref HEAD)
57-
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
49+
dotnet nbgv prepare-release --project . $FLAGS
50+
echo "release_branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
5851
59-
- name: 🚀 Push changes (main + new release branch + tags)
60-
run: |
61-
# Prepare-release already committed on both branches and tagged the point release.
62-
git push --follow-tags origin "${{ inputs.target_branch }}"
63-
git push --follow-tags origin "${{ steps.prepare.outputs.release_branch }}"
52+
outputs:
53+
release_branch: ${{ steps.prepare.outputs.release_branch }}

0 commit comments

Comments
 (0)