Skip to content

Commit 0137b2e

Browse files
committed
Require branch be up-to-date before release
1 parent 7c5309e commit 0137b2e

2 files changed

Lines changed: 42 additions & 14 deletions

File tree

scripts/version-patch.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
# This script can be used for pushing patches not based on master branch
44
# In most cases use scripts/version.sh to do builds, not this one
55

6+
# Determine if branch is up-to-date
7+
# If not exit the script
8+
UPSTREAM=${1:-'@{u}'}
9+
LOCAL=$(git rev-parse @)
10+
REMOTE=$(git rev-parse "$UPSTREAM")
11+
12+
if [ $LOCAL = $REMOTE ]; then
13+
echo "Branch up-to-date"
14+
else
15+
echo "Branch out of date"
16+
exit 1;
17+
fi
18+
19+
# Get relevant directories and ensure script is executed from root of directory
620
SQLPAD_ROOT_DIR=$(pwd)
721
SQLPAD_CLIENT_DIR=$(pwd)/client
822
SQLPAD_SERVER_DIR=$(pwd)/server
@@ -19,17 +33,17 @@ fi
1933
VERSION=$1
2034

2135
cd $SQLPAD_CLIENT_DIR
22-
npm --no-git-tag-version version $VERSION
36+
npm --no-git-tag-version version $VERSION || exit 1
2337

2438
cd $SQLPAD_SERVER_DIR
25-
npm --no-git-tag-version version $VERSION
39+
npm --no-git-tag-version version $VERSION || exit 1
2640

2741
cd $SQLPAD_ROOT_DIR
28-
npm --no-git-tag-version version $VERSION
42+
npm --no-git-tag-version version $VERSION || exit 1
2943

30-
git commit -a -m "v$VERSION"
44+
git commit -a -m "v$VERSION" || exit 1
3145

32-
git tag -a "v$VERSION" -m "v$VERSION"
46+
git tag -a "v$VERSION" -m "v$VERSION" || exit 1
3347

3448
git push origin HEAD
3549
git push origin "v$VERSION"

scripts/version.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
#!/usr/bin/env sh
22

33
BRANCH=$(git rev-parse --abbrev-ref HEAD)
4-
if [[ "$BRANCH" != "master" ]]; then
4+
if [ $BRANCH != "master" ]; then
55
echo 'Branch must be set to master';
66
exit 1;
77
fi
88

9+
# Determine if branch is up-to-date
10+
# If not exit the script
11+
UPSTREAM=${1:-'@{u}'}
12+
LOCAL=$(git rev-parse @)
13+
REMOTE=$(git rev-parse "$UPSTREAM")
14+
15+
if [ $LOCAL = $REMOTE ]; then
16+
echo "Branch up-to-date"
17+
else
18+
echo "Branch out of date"
19+
exit 1;
20+
fi
21+
22+
# Get relevant directories and ensure script is executed from root of directory
923
SQLPAD_ROOT_DIR=$(pwd)
1024
SQLPAD_CLIENT_DIR=$(pwd)/client
1125
SQLPAD_SERVER_DIR=$(pwd)/server
1226
SCRIPTS_DIR=$(pwd)/scripts
1327

14-
if [[ ! -d $SCRIPTS_DIR ]] || \
15-
[[ ! -d $SQLPAD_CLIENT_DIR ]] || \
16-
[[ ! -d $SQLPAD_SERVER_DIR ]]
28+
if [ ! -d $SCRIPTS_DIR ] || \
29+
[ ! -d $SQLPAD_CLIENT_DIR ] || \
30+
[ ! -d $SQLPAD_SERVER_DIR ]
1731
then
1832
echo This script must be executed from the sqlpad project directory
1933
exit 1
@@ -22,17 +36,17 @@ fi
2236
VERSION=$1
2337

2438
cd $SQLPAD_CLIENT_DIR
25-
npm --no-git-tag-version version $VERSION
39+
npm --no-git-tag-version version $VERSION || exit 1
2640

2741
cd $SQLPAD_SERVER_DIR
28-
npm --no-git-tag-version version $VERSION
42+
npm --no-git-tag-version version $VERSION || exit 1
2943

3044
cd $SQLPAD_ROOT_DIR
31-
npm --no-git-tag-version version $VERSION
45+
npm --no-git-tag-version version $VERSION || exit 1
3246

33-
git commit -a -m "v$VERSION"
47+
git commit -a -m "v$VERSION" || exit 1
3448

35-
git tag -a "v$VERSION" -m "v$VERSION"
49+
git tag -a "v$VERSION" -m "v$VERSION" || exit 1
3650

3751
git push origin master
3852
git push origin "v$VERSION"

0 commit comments

Comments
 (0)