Skip to content

Commit 4d6f0d6

Browse files
authored
ci: add graduation flow via PR to release please (#4484)
* Revert "ci: adjust release-please to allow graduating from rc to stable" This reverts commit 53ba8c2. * ci: add graduation flow to release please
1 parent 89a2616 commit 4d6f0d6

2 files changed

Lines changed: 67 additions & 22 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ on:
77
workflow_dispatch:
88
inputs:
99
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.'
1111
type: choice
1212
required: false
1313
default: auto
1414
options:
1515
- auto
1616
- rc
17-
- graduate
17+
- stable
1818

1919
env:
2020
NPM_VERSION: 11
2121

2222
jobs:
2323
release-please:
24+
if: github.event_name != 'workflow_dispatch' || inputs.release-mode != 'stable'
2425
runs-on: ubuntu-latest
2526
strategy:
2627
matrix:
@@ -29,7 +30,7 @@ jobs:
2930
- uses: googleapis/release-please-action@v5
3031
with:
3132
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' }}
3334
target-branch: develop
3435

3536
- uses: actions/checkout@v6
@@ -55,3 +56,66 @@ jobs:
5556
git add ../..
5657
git commit -m 'docs: annotate deprecation messages' || true
5758
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

release-please-config.graduate.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)