Skip to content

Commit 209be75

Browse files
authored
chore(release): adjust scripts to fix minor bugs (#5431)
* chore(release): wait 3 seconds before checking CI so GitHub has time to get it started, otherwise it will fail immediately * chore(scripts): flip logic to flatten indentation * chore(scripts): actually use $BRANCH instead of using default value * chore(scripts): add optional work item var
1 parent 9433efd commit 209be75

File tree

3 files changed

+56
-43
lines changed

3 files changed

+56
-43
lines changed

scripts/release/publish.sh

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
# Find the commit on master that last changed the root package.json version,
44
# then submit a PR to merge that commit onto the release branch and release via nucleus
5+
# Optionally set WORK_ITEM env var to include in commit/PR title
56
# Usage: yarn release:publish [branch=release]
7+
# Example: WORK_ITEM=W-1234567 yarn release:publish
68

79
set -e
810

@@ -28,35 +30,41 @@ VERSION=$(jq -r .version package.json)
2830
git switch -c "$BRANCH" "$VERSION_SHA"
2931
git push origin HEAD
3032

31-
if which gh >/dev/null; then
32-
# Use GitHub CLI to create a PR and wait for CI checks to pass
33-
gh pr create -t "chore: release $VERSION" -B "$RELEASE_BRANCH" -b ''
34-
# Clean up locally
35-
git switch "$BASE_BRANCH"
36-
git branch -D "$BRANCH"
37-
38-
# Wait for CI to complete
39-
. "$(dirname "$0")/wait-for-pr.sh" "$BRANCH"
40-
if ! gh pr checks --fail-fast --watch; then
41-
echo 'CI failed. Cannot continue with release.'
42-
gh pr view "$BRANCH" --web
43-
exit 1
44-
fi
45-
46-
sleep 10 # Give nucleus time to start the release job
47-
RELEASE_JOB=$(gh pr checks "$BRANCH" --json name,link -q '.[]|select(.name=="continuous-integration/nucleus/release").link')
48-
echo "Nucleus release started: $RELEASE_JOB"
49-
50-
# Wait for GitHub release to be created by Nucleus, then open it
51-
echo 'The GitHub release notes must be added manually. You can exit the script now and open GitHub on your own, or wait until the release is created and the script will open the page for you.'
52-
sleep 300 # Nucleus job usually takes ~5 minutes
53-
while ! gh release view "v$VERSION" 1>/dev/null 2>/dev/null; do
54-
sleep 15
55-
done
56-
gh release view "v$VERSION" --web
57-
else
33+
if ! which gh >/dev/null; then
5834
# GitHub CLI not installed - clean up and prompt for manual branch creation
5935
git switch "$BASE_BRANCH"
6036
git branch -D "$BRANCH"
6137
echo "Open a PR: https://github.com/salesforce/lwc/pull/new/$BRANCH"
38+
exit 0
6239
fi
40+
41+
PR_TITLE="chore: release $VERSION"
42+
if [ -n "$WORK_ITEM" ]; then
43+
PR_TITLE+=" @$WORK_ITEM"
44+
fi
45+
# Use GitHub CLI to create a PR and wait for CI checks to pass
46+
gh pr create -t "$PR_TITLE" -b '' -B "$RELEASE_BRANCH" -H "$BRANCH"
47+
# Clean up locally
48+
git switch "$BASE_BRANCH"
49+
git branch -D "$BRANCH"
50+
51+
# Wait for CI to complete
52+
sleep 3 # Give GitHub time to kick off CI
53+
. "$(dirname "$0")/wait-for-pr.sh" "$BRANCH"
54+
if ! gh pr checks --fail-fast --watch; then
55+
echo 'CI failed. Cannot continue with release.'
56+
gh pr view "$BRANCH" --web
57+
exit 1
58+
fi
59+
60+
sleep 10 # Give nucleus time to start the release job
61+
RELEASE_JOB=$(gh pr checks "$BRANCH" --json name,link -q '.[]|select(.name=="continuous-integration/nucleus/release").link')
62+
echo "Nucleus release started: $RELEASE_JOB"
63+
64+
# Wait for GitHub release to be created by Nucleus, then open it
65+
echo 'The GitHub release notes must be added manually. You can exit the script now and open GitHub on your own, or wait until the release is created and the script will open the page for you.'
66+
sleep 300 # Nucleus job usually takes ~5 minutes
67+
while ! gh release view "v$VERSION" >/dev/null; do
68+
sleep 15
69+
done
70+
gh release view "v$VERSION" --web

scripts/release/version.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env bash
22

33
# Bump package versions for release and submit a PR on GitHub
4+
# Optionally set WORK_ITEM env var to include in commit/PR title
45
# Usage: yarn release:version <version>
6+
# Example: WORK_ITEM=W-1234567 yarn release:version patch
57

68
set -e
79

@@ -28,24 +30,27 @@ node "$(dirname "$0")/version.js" "$VERSION"
2830
# Input could have been major/minor/patch; update the var to the resolved version
2931
VERSION=$(jq -r .version package.json)
3032
VERSION_BUMP_MESSAGE="chore: bump version to $VERSION"
33+
if [ -n "$WORK_ITEM" ]; then
34+
VERSION_BUMP_MESSAGE+=" @$WORK_ITEM"
35+
fi
3136
git commit -am "$VERSION_BUMP_MESSAGE"
3237
git push origin HEAD
3338

34-
if which gh 2>/dev/null 1>/dev/null; then
35-
# Use GitHub CLI to create a PR and wait for it to be merged before exiting
36-
gh pr create -t "$VERSION_BUMP_MESSAGE" -b ''
37-
gh pr merge --auto --squash --delete-branch
38-
git switch "$BASE_BRANCH"
39-
git branch -D "$BRANCH"
40-
41-
sleep 3 # Give GitHub time to start CI before we check it
42-
. "$(dirname "$0")/wait-for-pr.sh" "$BRANCH"
43-
while [ "$(gh pr view "$BRANCH" --json state -q .state)" != 'MERGED' ]; do
44-
sleep 3 # Wait for GitHub to auto-merge the PR
45-
done
46-
47-
else
48-
# Clean up and prompt for manual branch creation
39+
if ! gh >/dev/null; then
40+
# No GitHub CLI, gotta do it manually
4941
git switch "$BASE_BRANCH"
5042
echo "Open a PR: https://github.com/salesforce/lwc/pull/new/$BRANCH"
43+
exit 0
5144
fi
45+
46+
# Use GitHub CLI to create a PR and wait for it to be merged before exiting
47+
gh pr create -t "$VERSION_BUMP_MESSAGE" -b ''
48+
gh pr merge --auto --squash --delete-branch
49+
git switch "$BASE_BRANCH"
50+
git branch -D "$BRANCH"
51+
52+
sleep 3 # Give GitHub time to start CI before we check it
53+
. "$(dirname "$0")/wait-for-pr.sh" "$BRANCH"
54+
while [ "$(gh pr view "$BRANCH" --json state -q .state)" != 'MERGED' ]; do
55+
sleep 3 # Wait for GitHub to auto-merge the PR
56+
done

scripts/release/wait-for-pr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if [ -z "$BRANCH" ]; then
1313
fi
1414

1515
# Wait for CI to complete
16-
if ! gh pr checks --fail-fast --watch; then
16+
if ! gh pr checks --fail-fast --watch "$BRANCH"; then
1717
echo 'CI failed. Cannot continue with release.'
1818
gh pr view "$BRANCH" --web
1919
exit 1

0 commit comments

Comments
 (0)