-
Notifications
You must be signed in to change notification settings - Fork 124
/
release
executable file
·76 lines (55 loc) · 1.92 KB
/
release
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
68
69
70
71
72
73
74
75
76
#!/bin/bash -e
function print_help() {
cat << EOF
Creates an Appliance release
Usage: start [options]
-h, --help Shows this help message.
-r, --revert Removes the current version tags. This allows the appliance
to be re-released.
-f, --force Release even if there are no changes. This is necessary
after a revert.
EOF
}
function revert_tag {
local tag="$1"
echo "Revert tag: $tag"
git tag -d $tag
git push origin :refs/tags/$tag
echo "Successfully reverted release: $tag"
}
git fetch --tags
version="v$(< VERSION)"
last_release=$(git describe --abbrev=0 --tags)
FORCE_RELEASE=false
while true ; do
case "$1" in
-r | --revert ) revert_tag $version ; exit 0 ;;
-h | --help ) print_help ; exit 0 ;;
-f | --force ) FORCE_RELEASE=true ; shift ;;
* ) if [ -z "$1" ]; then break; else echo "$1 is not a valid option"; exit 1; fi;;
esac
done
if [ "$version" = "$last_release" ]; then
echo 'To release, the VERSION file must be incremented to the latest release number.'
exit 1
fi
if [[ ! $(git status --porcelain) && $FORCE_RELEASE = false ]]; then
cat << EOF
Your Git is clean. Please update the VERSION, CHANGELOG.md, and optionally
RELEASE_NOTES.md before releasing. The script will handle commits and pushing.
If you reverted a release, and are simply updating tags, the force tag can be used:
release --force
EOF
exit 1
fi
echo "The last release was: $last_release"
echo "The next release will be: $version"
# Make sure we have the most recent changes, without destroying local changes.
git stash
git pull --rebase origin $(git rev-parse --abbrev-ref HEAD)
git stash pop
# Perform a commit, tag, and push. The tag needs to be present before the commit
# to insure Jenkins has what it needs to make a decision about a release.
git commit -am "$version"
git tag -a "$version" -m "$version release"
git push --follow-tags