|
| 1 | +name: nbgv_prepare_release |
| 2 | + |
| 3 | +############################################################################### |
| 4 | +# Creates a release branch, bumps version.json, pushes tags/branches, and |
| 5 | +# opens a draft PR release/* ➜ main. |
| 6 | +# |
| 7 | +# Called from consumer repos via: |
| 8 | +# uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_prepare_release.yml@main |
| 9 | +############################################################################### |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_call: |
| 13 | + inputs: |
| 14 | + increment: # REQUIRED: major | minor | patch |
| 15 | + description: "Version part to bump" |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + |
| 19 | + secrets: |
| 20 | + GH_TOKEN: # Optional PAT if default token lacks perms |
| 21 | + description: "Token for pushing branches & creating PR" |
| 22 | + required: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + prepare-release: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + env: |
| 29 | + DOTNET_NOLOGO: true |
| 30 | + GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} |
| 31 | + |
| 32 | + steps: |
| 33 | + # 1️⃣ Checkout full history (commit-height matters) |
| 34 | + - name: ⬇️ Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + token: ${{ env.GH_TOKEN }} |
| 39 | + |
| 40 | + # 2️⃣ .NET SDK & local tools (nbgv) |
| 41 | + - name: 🛠️ Setup .NET |
| 42 | + uses: actions/setup-dotnet@v4 |
| 43 | + with: |
| 44 | + dotnet-version: 9.0.x |
| 45 | + |
| 46 | + - name: 🔧 Restore local tools |
| 47 | + run: dotnet tool restore |
| 48 | + |
| 49 | + # 3️⃣ Run nbgv prepare-release |
| 50 | + - name: 🗂️ Prepare release branch |
| 51 | + id: prep |
| 52 | + run: | |
| 53 | + git config user.name "release-bot" |
| 54 | + git config user.email "release-bot@users.noreply.github.com" |
| 55 | +
|
| 56 | + dotnet nbgv prepare-release --versionIncrement ${{ inputs.increment }} |
| 57 | +
|
| 58 | + echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT" |
| 59 | +
|
| 60 | + # 4️⃣ Push main, release branch, and tags |
| 61 | + - name: 🚀 Push branches & tags |
| 62 | + run: | |
| 63 | + git push --follow-tags origin HEAD |
| 64 | + git push --follow-tags origin ${{ steps.prep.outputs.branch }} |
| 65 | +
|
| 66 | + # 5️⃣ Draft PR: release/* → main |
| 67 | + - name: 💬 Open pull request |
| 68 | + run: | |
| 69 | + gh pr create \ |
| 70 | + --base main \ |
| 71 | + --head ${{ steps.prep.outputs.branch }} \ |
| 72 | + --title "📦 Release ${{ steps.prep.outputs.branch }}" \ |
| 73 | + --body "Auto-generated release PR for **${{ steps.prep.outputs.branch }}**." \ |
| 74 | + --draft |
0 commit comments