-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
135 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Simple script to make sure the current build is on the production branch and | ||
# has the correct version tag. | ||
# This script is used as a check to prevent from deploying a wrong version to | ||
# the docs. | ||
|
||
DIR=$(dirname "$(realpath $0)") | ||
|
||
say() { | ||
printf "[%s] %s\n" "$0" "$*" >&2 | ||
} | ||
|
||
die() { | ||
say "$*" | ||
exit 100 | ||
} | ||
|
||
check_branch() { | ||
if [[ "$CIRCLE_BRANCH" != "master" ]]; then | ||
die "Error: Invalid branch name '$CIRCLE_BRANCH', expected master" | ||
fi | ||
} | ||
|
||
check_tag() { | ||
NPM_VERSION=$(node -p "require('${DIR}/../package.json').version") | ||
DISTANCE=$(git rev-list --count "v$NPM_VERSION..HEAD") | ||
if [[ "$DISTANCE" != "0" ]]; then | ||
die "Error: Production branch must point to the current version tag ($DISTANCE commits ahead)" | ||
fi | ||
} | ||
|
||
check_branch | ||
check_tag | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters