-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathcreate-release-pr
executable file
·61 lines (48 loc) · 1.73 KB
/
create-release-pr
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
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -e -o pipefail
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
MAIN_BRANCH="main"
if [[ "${CURRENT_BRANCH}" != "${MAIN_BRANCH}" ]]; then
echo "scripts must be run on the ${MAIN_BRANCH}."
echo "Please checkout the ${MAIN_BRANCH} branch with:"
echo "git checkout ${MAIN_BRANCH}"
exit 1
fi
if !(command -v gh > /dev/null); then
echo "GitHub CLI is required for this release script."
echo "Please install GitHub CLI and try again:"
echo "https://github.com/cli/cli#installation"
exit 1
fi
# hostname is necessary just in case you are logged into the CLI
# GitHub enterprise instance
if !(gh auth status --hostname "github.com" > /dev/null 2>&1); then
echo "Not logged into GitHub".
echo "Please run: gh auth login"
exit 1
fi
git pull --ff-only origin "${MAIN_BRANCH}"
# Create a branch with the unix timestamp of the current second
BRANCH_NAME="release-$(date +%s)"
echo "Creating git branch ${BRANCH_NAME}"
git checkout -b "${BRANCH_NAME}"
echo "Installing dependencies with yarn..."
yarn
echo "Done installing dependencies with yarn"
# remove any oclif manifests. They interfere with doc generation
rm -rf ./packages/*/oclif.manifest.json
echo "Creating new CLI package(s) versions with yarn lerna version..."
yarn lerna version \
--allow-branch ${BRANCH_NAME} \
--no-push \
--no-git-tag-version \
--yes
PACKAGE_VERSION=`node -e "console.log(require('./lerna.json').version)"`
echo "Done creating new CLI package(s) versions"
echo "Updating yarn.lock with new package versions"
yarn
git add . -u
echo "Creating git commit and pushing to GitHub..."
git commit -m "v${PACKAGE_VERSION}"
git push origin "${BRANCH_NAME}"
gh pr create --title="release v${PACKAGE_VERSION}" --body "release v${PACKAGE_VERSION}"