|
6 | 6 | - main |
7 | 7 | workflow_dispatch: |
8 | 8 | inputs: |
9 | | - release-candidate: |
10 | | - description: 'Cut a release-candidate (prerelease) instead of a normal release.' |
11 | | - type: boolean |
| 9 | + release-mode: |
| 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 | + type: choice |
12 | 12 | required: false |
13 | | - default: false |
| 13 | + default: auto |
| 14 | + options: |
| 15 | + - auto |
| 16 | + - rc |
| 17 | + - stable |
14 | 18 |
|
15 | 19 | env: |
16 | 20 | RELEASE_BRANCH: release-please--branches--main--components--github-actions-magento2 |
17 | 21 |
|
18 | 22 | jobs: |
19 | 23 | release-please: |
| 24 | + if: github.event_name != 'workflow_dispatch' || inputs.release-mode != 'stable' |
20 | 25 | runs-on: ubuntu-latest |
21 | 26 | permissions: |
22 | 27 | contents: write |
|
27 | 32 | uses: googleapis/release-please-action@v4 |
28 | 33 | with: |
29 | 34 | token: ${{ secrets.GRAYCORE_GITHUB_TOKEN }} |
30 | | - config-file: ${{ inputs.release-candidate && 'release-please-config.rc.json' || 'release-please-config.json' }} |
| 35 | + config-file: ${{ inputs.release-mode == 'rc' && 'release-please-config.rc.json' || 'release-please-config.json' }} |
31 | 36 |
|
32 | 37 | - name: Check if release branch exists |
33 | 38 | id: branch-check |
|
80 | 85 | git commit -m "chore: pin internal action refs to ${{ steps.pin-refs.outputs.VERSION }}" |
81 | 86 | git push origin ${{ env.RELEASE_BRANCH }} |
82 | 87 |
|
| 88 | + graduate: |
| 89 | + if: github.event_name == 'workflow_dispatch' && inputs.release-mode == 'stable' |
| 90 | + runs-on: ubuntu-latest |
| 91 | + permissions: |
| 92 | + contents: write |
| 93 | + pull-requests: write |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v6 |
| 96 | + with: |
| 97 | + ref: main |
| 98 | + token: ${{ secrets.GRAYBOT_PIN_BACK_PAT }} |
| 99 | + |
| 100 | + - name: Compute graduate version |
| 101 | + id: graduate |
| 102 | + run: | |
| 103 | + CURRENT=$(jq -r '."."' .release-please-manifest.json) |
| 104 | + STABLE="${CURRENT%%-*}" |
| 105 | + if [ "$CURRENT" = "$STABLE" ]; then |
| 106 | + echo "::error::Manifest version ${CURRENT} has no prerelease suffix; nothing to graduate." |
| 107 | + exit 1 |
| 108 | + fi |
| 109 | + echo "CURRENT=${CURRENT}" >> $GITHUB_OUTPUT |
| 110 | + echo "STABLE=${STABLE}" >> $GITHUB_OUTPUT |
| 111 | +
|
| 112 | + - name: Open graduate PR |
| 113 | + env: |
| 114 | + GRAYBOT_GPG_KEY: ${{ secrets.GRAYBOT_GPG_KEY }} |
| 115 | + GH_TOKEN: ${{ secrets.GRAYBOT_PIN_BACK_PAT }} |
| 116 | + CURRENT: ${{ steps.graduate.outputs.CURRENT }} |
| 117 | + STABLE: ${{ steps.graduate.outputs.STABLE }} |
| 118 | + run: | |
| 119 | + echo "$GRAYBOT_GPG_KEY" | gpg --batch --import |
| 120 | + export GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d/ -f2) |
| 121 | + git config --global user.signingkey $GPG_KEY_ID |
| 122 | + git config --global commit.gpgSign true |
| 123 | + git config --global user.email "automation@graycore.io" |
| 124 | + git config --global user.name "Beep Boop" |
| 125 | + BRANCH="chore/graduate-v${STABLE}" |
| 126 | + git checkout -b "$BRANCH" |
| 127 | + git commit --allow-empty \ |
| 128 | + -m "chore: graduate ${CURRENT} to ${STABLE}" \ |
| 129 | + -m "Release-As: ${STABLE}" |
| 130 | + git push --force origin "$BRANCH" |
| 131 | + EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty') |
| 132 | + PR_BODY=$(cat <<EOF |
| 133 | + Graduates the release line from \`${CURRENT}\` to a stable \`${STABLE}\`. |
| 134 | +
|
| 135 | + 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}\`. |
| 136 | +
|
| 137 | + Release-As: ${STABLE} |
| 138 | + EOF |
| 139 | + ) |
| 140 | + if [ -z "$EXISTING" ]; then |
| 141 | + gh pr create \ |
| 142 | + --base main \ |
| 143 | + --head "$BRANCH" \ |
| 144 | + --title "chore: graduate ${CURRENT} → ${STABLE}" \ |
| 145 | + --body "$PR_BODY" |
| 146 | + else |
| 147 | + gh pr edit "$EXISTING" --body "$PR_BODY" |
| 148 | + echo "PR #$EXISTING already exists for $BRANCH — updated body" |
| 149 | + fi |
| 150 | +
|
83 | 151 | pinback: |
84 | 152 | needs: release-please |
85 | 153 | if: needs.release-please.outputs.releases_created == 'true' |
|
0 commit comments