Skip to content

Commit 3e9f95e

Browse files
committed
ci: add a graduation mode to release please
1 parent 9c56da7 commit 3e9f95e

1 file changed

Lines changed: 73 additions & 5 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ on:
66
- main
77
workflow_dispatch:
88
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
1212
required: false
13-
default: false
13+
default: auto
14+
options:
15+
- auto
16+
- rc
17+
- stable
1418

1519
env:
1620
RELEASE_BRANCH: release-please--branches--main--components--github-actions-magento2
1721

1822
jobs:
1923
release-please:
24+
if: github.event_name != 'workflow_dispatch' || inputs.release-mode != 'stable'
2025
runs-on: ubuntu-latest
2126
permissions:
2227
contents: write
@@ -27,7 +32,7 @@ jobs:
2732
uses: googleapis/release-please-action@v4
2833
with:
2934
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' }}
3136

3237
- name: Check if release branch exists
3338
id: branch-check
@@ -80,6 +85,69 @@ jobs:
8085
git commit -m "chore: pin internal action refs to ${{ steps.pin-refs.outputs.VERSION }}"
8186
git push origin ${{ env.RELEASE_BRANCH }}
8287
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+
83151
pinback:
84152
needs: release-please
85153
if: needs.release-please.outputs.releases_created == 'true'

0 commit comments

Comments
 (0)