|
1 | | -name: nbgv_prepare_release |
| 1 | +name: "NBGV: Prepare Release" |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_call: |
5 | 5 | inputs: |
6 | 6 | target_branch: |
7 | 7 | type: string |
8 | | - description: "Branch / tag to release from" |
9 | 8 | default: main |
10 | | - required: true |
11 | | - |
12 | 9 | increment: |
13 | | - description: "Which version component to bump: major, minor, or patch" # (patch means 'revision') |
14 | | - required: true |
15 | 10 | type: string |
16 | | - |
| 11 | + default: patch |
17 | 12 | secrets: |
18 | | - # The caller repo’s GITHUB_TOKEN is passed automatically; override if desired |
19 | 13 | GH_TOKEN: |
20 | | - description: "Personal-access token if you need extra perms" |
21 | 14 | required: false |
22 | 15 |
|
23 | 16 | jobs: |
24 | | - prepare-release: |
| 17 | + prep: |
25 | 18 | runs-on: ubuntu-latest |
26 | 19 | env: |
27 | | - DOTNET_NOLOGO: true |
28 | | - |
| 20 | + GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} |
29 | 21 | steps: |
30 | | - - name: ⬇️ Checkout full history |
| 22 | + - name: Checkout |
31 | 23 | uses: actions/checkout@v4 |
32 | 24 | with: |
33 | 25 | 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 }} |
36 | 28 |
|
37 | | - - name: 🛠️ Setup .NET SDK |
| 29 | + - name: Setup .NET & NBGV |
38 | 30 | uses: actions/setup-dotnet@v4 |
39 | 31 | with: |
40 | 32 | dotnet-version: 9.0.x |
| 33 | + - run: dotnet tool restore |
41 | 34 |
|
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 |
47 | 37 | run: | |
48 | | - # Configure a generic bot identity for the commit |
49 | 38 | git config user.name "release-bot" |
50 | 39 | git config user.email "release-bot@users.noreply.github.com" |
51 | 40 |
|
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 |
54 | 48 |
|
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" |
58 | 51 |
|
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