-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathversion.sh
More file actions
executable file
·50 lines (41 loc) · 1.4 KB
/
version.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# Bump package versions for release and submit a PR on GitHub
# Usage: yarn release:version <version>
set -e
VERSION="$1"
BRANCH="release-version-$(date -u +'%Y-%m-%d-%H_%M')"
BASE_BRANCH='master'
if [ -z "$VERSION" ]; then
echo 'Specify a new version.'
exit 1
fi
# Avoid accidentally committing unrelated files
if [[ -n $(git status --porcelain) ]]; then
echo -e '\033[1mPlease stash your work before continuing.\n\033[0m'
git status
exit 1
fi
git switch "$BASE_BRANCH"
git pull
git switch -c "$BRANCH"
node "$(dirname "$0")/version.js" "$VERSION"
# Input could have been major/minor/patch; update the var to the resolved version
VERSION=$(jq -r .version package.json)
VERSION_BUMP_MESSAGE="chore: bump version to $VERSION"
git commit -am "$VERSION_BUMP_MESSAGE"
git push origin HEAD
if which gh 2>/dev/null 1>/dev/null; then
# Use GitHub CLI to create a PR and wait for it to be merged before exiting
gh pr create -t "$VERSION_BUMP_MESSAGE" -b ''
gh pr merge --auto --squash --delete-branch
git switch "$BASE_BRANCH"
git branch -D "$BRANCH"
. "$(dirname "$0")/wait-for-pr.sh" "$BRANCH"
while [ "$(gh pr view "$BRANCH" --json state -q .state)" != 'MERGED' ]; do
sleep 3 # Wait for GitHub to auto-merge the PR
done
else
# Clean up and prompt for manual branch creation
git switch "$BASE_BRANCH"
echo "Open a PR: https://github.com/salesforce/lwc/pull/new/$BRANCH"
fi