-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrelease.sh
executable file
·59 lines (42 loc) · 1.36 KB
/
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
#!/bin/bash
set -e
TAG_REGEX="^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$"
VERSION=$1
if [[ ! -z $(git status -s) ]]; then
echo "[ERR] Index contains uncommited changes, please commit or stash them before release!"
exit 1
fi
echo "[INFO] Ensuring that flow is enabled"
# Git-flow settings
git flow init -df
git config gitflow.release.finish.notag true
echo "[INFO] Checking branch name"
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
echo "[DEBUG] Current branch is '$branch_name'"
if [ "$branch_name" != "develop" ]; then
echo "[ERR] Move to delevop branch to start a new release"
exit 1
fi
if [[ -z $(git status -s) ]]; then
echo "tree is clean"
else
echo "tree is dirty, please commit changes before running this"
exit
fi
if [[ ! $VERSION =~ $TAG_REGEX ]]; then
echo "[ERR] Tag $VERSION is invalid, must feat semver regex '$TAG_REGEX' (example: v1.0.0)"
exit 1
fi
echo "[INFO] Version '${VERSION}' is valid, starting release branch"
git flow release start $VERSION
echo "[INFO] Closing release"
git flow release finish $VERSION
echo "[INFO] Switching on master branch"
git checkout master -q
echo "[INFO] Tagging release"
git tag -a "${VERSION}" -m "Release for version $VERSION"
echo "[INFO] Switching on master develop"
git checkout develop -q
echo "[INFO] All done!"