|
1 | 1 | name: nbgv_prepare_release |
| 2 | + |
2 | 3 | on: |
3 | 4 | workflow_call: |
4 | 5 | inputs: |
5 | 6 | target_branch: |
6 | | - description: "Branch or tag to release from" |
7 | | - required: false |
8 | 7 | type: string |
| 8 | + description: "Branch / tag to release from" |
9 | 9 | default: main |
| 10 | + required: true |
10 | 11 |
|
11 | | - increment: |
12 | | - description: "Version bump (major, minor, patch)" |
13 | | - required: false |
| 12 | + increment: |
14 | 13 | type: string |
| 14 | + description: "Version increment" |
15 | 15 | default: patch |
| 16 | + required: true |
| 17 | + |
| 18 | + outputs: |
| 19 | + release_branch: |
| 20 | + description: "Name of the new release branch" |
| 21 | + value: ${{ jobs.prep.outputs.release_branch }} |
16 | 22 |
|
17 | 23 | secrets: |
18 | 24 | GH_TOKEN: |
19 | | - description: "PAT if you need extra scopes; default token works in most orgs" |
20 | 25 | required: false |
21 | 26 |
|
22 | 27 | jobs: |
23 | | - prepare-release: |
| 28 | + prep: |
24 | 29 | runs-on: ubuntu-latest |
25 | 30 | env: |
26 | 31 | DOTNET_NOLOGO: true |
27 | 32 | GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} |
28 | 33 |
|
| 34 | + outputs: |
| 35 | + release_branch: ${{ steps.prepare.outputs.release_branch }} |
| 36 | + |
29 | 37 | steps: |
30 | | - # 1️⃣ checkout chosen ref with full history |
31 | | - - name: ⬇️ Checkout |
32 | | - uses: actions/checkout@v4 |
| 38 | + # Checkout the branch/tag supplied by the caller |
| 39 | + - uses: actions/checkout@v4 |
33 | 40 | with: |
34 | 41 | ref: ${{ inputs.target_branch }} |
35 | 42 | fetch-depth: 0 |
36 | 43 | token: ${{ env.GH_TOKEN }} |
37 | 44 |
|
38 | | - # 2️⃣ .NET 9 SDK + nbgv CLI |
39 | | - - name: 🛠️ Setup .NET 9 |
40 | | - uses: actions/setup-dotnet@v4 |
41 | | - with: |
42 | | - dotnet-version: 9.0.x |
43 | | - |
44 | | - - name: 🔧 Restore local tools |
45 | | - run: dotnet tool restore |
| 45 | + # .NET SDK & nbgv CLI |
| 46 | + - uses: actions/setup-dotnet@v4 |
| 47 | + with: { dotnet-version: 9.0.x } |
| 48 | + - run: dotnet tool restore |
46 | 49 |
|
47 | | - # 3️⃣ bump version & create release branch |
| 50 | + # bump version + create release/vX.Y |
48 | 51 | - name: 🗂️ Prepare release |
49 | 52 | id: prepare |
50 | 53 | run: | |
51 | 54 | git config user.name "release-bot" |
52 | 55 | git config user.email "[email protected]" |
53 | 56 |
|
54 | | - # map UI term 'patch' -> CLI term 'revision' |
55 | 57 | INC=${{ inputs.increment }} |
56 | | - [ "$INC" = "patch" ] && INC=revision |
| 58 | + [ "$INC" = "patch" ] && INC=revision # map to CLI terminology |
57 | 59 | dotnet nbgv prepare-release --versionIncrement "$INC" |
| 60 | +
|
58 | 61 | echo "release_branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT" |
59 | 62 |
|
60 | | - # 4️⃣ push both branches + tags |
61 | | - - name: 🚀 Push branches & tags |
62 | | - run: | |
63 | | - git push --follow-tags origin ${{ inputs.target_branch }} |
64 | | - git push --follow-tags origin ${{ steps.prep.outputs.release_branch }} |
| 63 | + # Push branches & tags and open draft PR |
| 64 | + - run: | |
| 65 | + git push --follow-tags origin "${{ inputs.target_branch }}" |
| 66 | + git push --follow-tags origin "${{ steps.prepare.outputs.release_branch }}" |
65 | 67 |
|
66 | | - # 5️⃣ draft PR release/* -> target_branch |
67 | | - - name: 💬 Open pull request |
68 | | - run: | |
| 68 | + - run: | |
69 | 69 | gh pr create \ |
70 | | - --base ${{ inputs.target_branch }} \ |
71 | | - --head ${{ steps.prep.outputs.release_branch }} \ |
72 | | - --title "📦 Release ${{ steps.prep.outputs.release_branch }}" \ |
73 | | - --body "Auto-generated release PR for **${{ steps.prep.outputs.release_branch }}**." \ |
| 70 | + --base "${{ inputs.target_branch }}" \ |
| 71 | + --head "${{ steps.prepare.outputs.release_branch }}" \ |
| 72 | + --title "📦 Release ${steps.prepare.outputs.release_branch}" \ |
| 73 | + --body "Auto-generated release PR." \ |
74 | 74 | --draft |
0 commit comments