forked from vitessce/vitessce
-
Notifications
You must be signed in to change notification settings - Fork 3
/
create-release.sh
executable file
·67 lines (49 loc) · 1.76 KB
/
create-release.sh
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
62
63
64
65
66
67
#!/usr/bin/env bash
set -o errexit
set -o pipefail
die() { set +v; echo "$*" 1>&2 ; exit 1; }
git diff --quiet || die 'Uncommitted changes: Stash or commit before pushing.'
(( $# == 1 )) || die "Requires one argument, the NPM version type (major | minor | patch); Instead got $#."
if ! command -v gh &> /dev/null
then
die "Requires the GitHub CLI (gh)."
fi
if ! command -v aws &> /dev/null
then
die "Requires the AWS CLI (aws)."
fi
AWS_ACCT=$(aws iam list-account-aliases --query 'AccountAliases[0]')
if [[ "$AWS_ACCT" != "gehlenborglab" ]]; then
die "Deployment requires authentication with the lab account in the AWS CLI (aws)."
fi
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "$BRANCH" != "main" ]]; then
read -p "You are not on the main branch. Are you sure you want to make a release from this branch? [y/n]" -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Continuing the release"
else
exit
fi
fi
DATE=`date "+%Y-%m-%d"`
# Bump the version.
NEXT_VERSION_WITH_V=$( npm version "$1" --no-git-tag-version )
NEXT_VERSION=${NEXT_VERSION_WITH_V:1}
# Make a new branch for the release.
git checkout -b "release-$NEXT_VERSION_WITH_V"
# Update CHANGELOG
printf '%s\n%s\n' "
### Added
### Changed
## [$NEXT_VERSION](https://www.npmjs.com/package/vitessce/v/$NEXT_VERSION) - $DATE
" "$(cat CHANGELOG.md)" > CHANGELOG.md
git add CHANGELOG.md package.json package-lock.json
git commit -m "Release for $NEXT_VERSION_WITH_V. Commit by create-release.sh"
# Push dev and docs site.
bash ./push-demos.sh
git add src/version.json DEMOS.md DOCS.md
git commit -m "Demo for $NEXT_VERSION_WITH_V. Commit by create-release.sh"
# Make a pull request.
gh pr create --draft --base main --title "Release $NEXT_VERSION_WITH_V"