|
7 | 7 | workflow_dispatch: |
8 | 8 | inputs: |
9 | 9 | release-mode: |
10 | | - description: 'auto = follow conventional commits; rc = bump the rc suffix; graduate = graduate the current rc to a stable release.' |
| 10 | + description: 'auto = follow conventional commits; rc = bump the rc suffix; stable = open a PR that graduates the current rc to a stable release.' |
11 | 11 | type: choice |
12 | 12 | required: false |
13 | 13 | default: auto |
14 | 14 | options: |
15 | 15 | - auto |
16 | 16 | - rc |
17 | | - - graduate |
| 17 | + - stable |
18 | 18 |
|
19 | 19 | env: |
20 | 20 | NPM_VERSION: 11 |
21 | 21 |
|
22 | 22 | jobs: |
23 | 23 | release-please: |
| 24 | + if: github.event_name != 'workflow_dispatch' || inputs.release-mode != 'stable' |
24 | 25 | runs-on: ubuntu-latest |
25 | 26 | strategy: |
26 | 27 | matrix: |
|
29 | 30 | - uses: googleapis/release-please-action@v5 |
30 | 31 | with: |
31 | 32 | token: ${{ secrets.GRAYCORE_GITHUB_TOKEN }} |
32 | | - config-file: ${{ inputs.release-mode == 'rc' && 'release-please-config.rc.json' || (inputs.release-mode == 'graduate' && 'release-please-config.graduate.json' || 'release-please-config.json') }} |
| 33 | + config-file: ${{ inputs.release-mode == 'rc' && 'release-please-config.rc.json' || 'release-please-config.json' }} |
33 | 34 | target-branch: develop |
34 | 35 |
|
35 | 36 | - uses: actions/checkout@v6 |
|
55 | 56 | git add ../.. |
56 | 57 | git commit -m 'docs: annotate deprecation messages' || true |
57 | 58 | git push |
| 59 | +
|
| 60 | + graduate: |
| 61 | + if: github.event_name == 'workflow_dispatch' && inputs.release-mode == 'stable' |
| 62 | + runs-on: ubuntu-latest |
| 63 | + permissions: |
| 64 | + contents: write |
| 65 | + pull-requests: write |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v6 |
| 68 | + with: |
| 69 | + ref: main |
| 70 | + token: ${{ secrets.GRAYCORE_GITHUB_TOKEN }} |
| 71 | + |
| 72 | + - name: Compute graduate version |
| 73 | + id: graduate |
| 74 | + run: | |
| 75 | + CURRENT=$(jq -r '."."' .release-please-manifest.json) |
| 76 | + STABLE="${CURRENT%%-*}" |
| 77 | + if [ "$CURRENT" = "$STABLE" ]; then |
| 78 | + echo "::error::Manifest version ${CURRENT} has no prerelease suffix; nothing to graduate." |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | + echo "CURRENT=${CURRENT}" >> $GITHUB_OUTPUT |
| 82 | + echo "STABLE=${STABLE}" >> $GITHUB_OUTPUT |
| 83 | +
|
| 84 | + - name: Open graduate PR |
| 85 | + env: |
| 86 | + GRAYBOT_GPG_KEY: ${{ secrets.GRAYBOT_GPG_KEY }} |
| 87 | + GH_TOKEN: ${{ secrets.GRAYCORE_GITHUB_TOKEN }} |
| 88 | + CURRENT: ${{ steps.graduate.outputs.CURRENT }} |
| 89 | + STABLE: ${{ steps.graduate.outputs.STABLE }} |
| 90 | + run: | |
| 91 | + echo "$GRAYBOT_GPG_KEY" | gpg --batch --import |
| 92 | + export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d/ -f2) |
| 93 | + git config --global user.signingkey $GPG_KEY_ID |
| 94 | + git config --global commit.gpgSign true |
| 95 | + git config --global user.email "automation@graycore.io" |
| 96 | + git config --global user.name "Beep Boop" |
| 97 | + BRANCH="chore/graduate-v${STABLE}" |
| 98 | + git checkout -b "$BRANCH" |
| 99 | + git commit --allow-empty \ |
| 100 | + -m "chore: graduate ${CURRENT} to ${STABLE}" \ |
| 101 | + -m "Release-As: ${STABLE}" |
| 102 | + git push --force origin "$BRANCH" |
| 103 | + EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty') |
| 104 | + PR_BODY=$(cat <<EOF |
| 105 | + Graduates the release line from \`${CURRENT}\` to a stable \`${STABLE}\`. |
| 106 | +
|
| 107 | + When this PR is merged to \`main\`, release-please will pick up the \`Release-As\` footer below and open a release PR for \`v${STABLE}\`. |
| 108 | +
|
| 109 | + Release-As: ${STABLE} |
| 110 | + EOF |
| 111 | + ) |
| 112 | + if [ -z "$EXISTING" ]; then |
| 113 | + gh pr create \ |
| 114 | + --base main \ |
| 115 | + --head "$BRANCH" \ |
| 116 | + --title "chore: graduate ${CURRENT} → ${STABLE}" \ |
| 117 | + --body "$PR_BODY" |
| 118 | + else |
| 119 | + gh pr edit "$EXISTING" --body "$PR_BODY" |
| 120 | + echo "PR #$EXISTING already exists for $BRANCH — updated body" |
| 121 | + fi |
0 commit comments