Skip to content

Commit 9d83aea

Browse files
committed
chore(release): make version script watch for version PR merged
1 parent 397d818 commit 9d83aea

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

scripts/release/publish.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,14 @@ if which gh >/dev/null; then
3636
git branch -D "$BRANCH"
3737

3838
# Wait for CI to complete
39+
./wait-for-pr.sh "$BRANCH"
3940
if ! gh pr checks --fail-fast --watch; then
4041
echo 'CI failed. Cannot continue with release.'
4142
gh pr view "$BRANCH" --web
4243
exit 1
4344
fi
4445

45-
# Also wait for approvals, if needed
46-
if [ "$(gh pr view "$BRANCH" --json reviewDecision -q .reviewDecision)" != 'APPROVED' ]; then
47-
echo 'Release cannot continue without approval.'
48-
while [ "$(gh pr view "$BRANCH" --json reviewDecision --jq .reviewDecision)" != 'APPROVED' ]; do
49-
sleep 30
50-
done
51-
echo 'PR approved! Continuing...'
52-
else
53-
sleep 10 # Give nucleus time to start the release job
54-
fi
55-
46+
sleep 10 # Give nucleus time to start the release job
5647
RELEASE_JOB=$(gh pr checks "$BRANCH" --json name,link -q '.[]|select(.name=="continuous-integration/nucleus/release").link')
5748
echo "Nucleus release started: $RELEASE_JOB"
5849

scripts/release/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ fi
1515
echo 'Creating version bump PR...'
1616
./version.sh "$1"
1717
echo 'Creating release PR...'
18-
./publish.sh "$2"
18+
./publish.sh "$2"

scripts/release/version.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ if which gh 2>/dev/null 1>/dev/null; then
3737
gh pr merge --auto --squash --delete-branch
3838
git switch "$BASE_BRANCH"
3939
git branch -D "$BRANCH"
40-
if ! gh pr checks --fail-fast --watch "$BRANCH"; then
41-
echo 'CI failed. Cannot continue with release.'
42-
exit 1
43-
fi
40+
41+
./wait-for-pr.sh "$BRANCH"
42+
while [ "$(gh pr view "$BRANCH" --json state -q .state)" != 'MERGED' ]; do
43+
sleep 3 # Wait for GitHub to auto-merge the PR
44+
done
45+
4446
else
4547
# Clean up and prompt for manual branch creation
4648
git switch "$BASE_BRANCH"

scripts/release/wait-for-pr.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env/bash
2+
3+
# Waits until a PR is ready to be merged
4+
# Usage: ./wait-for-pr.sh <branch name or PR number>
5+
# Example: ./wait-for-pr.sh 'my-branch-with-cool-changes'
6+
7+
set -e
8+
9+
BRANCH="$1"
10+
if [ -z "$BRANCH" ]; then
11+
echo 'Please specify a branch name or PR number.'
12+
exit 1
13+
fi
14+
15+
# Wait for CI to complete
16+
if ! gh pr checks --fail-fast --watch; then
17+
echo 'CI failed. Cannot continue with release.'
18+
gh pr view "$BRANCH" --web
19+
exit 1
20+
fi
21+
22+
# Also wait for approvals, if needed
23+
if [ "$(gh pr view "$BRANCH" --json reviewDecision -q .reviewDecision)" != 'APPROVED' ]; then
24+
echo 'Waiting for PR approval.'
25+
while [ "$(gh pr view "$BRANCH" --json reviewDecision --jq .reviewDecision)" != 'APPROVED' ]; do
26+
sleep 30
27+
done
28+
echo 'PR approved! Continuing...'
29+
fi

0 commit comments

Comments
 (0)