forked from cyberark/conjur
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease
More file actions
executable file
·51 lines (40 loc) · 1.42 KB
/
Copy pathrelease
File metadata and controls
executable file
·51 lines (40 loc) · 1.42 KB
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
#!/bin/bash -e
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
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "Must be on the master branch to releases. Please switch with 'git checkout master'."
exit 1
fi
version="v$(< VERSION)"
last_release=$(git describe --abbrev=0 --tags)
while true ; do
case "$1" in
--revert ) revert_tag $version ; exit 0 ;;
* ) if [ -z "$1" ]; then break; else echo "$1 is not a valid option"; exit 1; fi;;
esac
done
echo "The last release was: $last_release"
echo "The next release will be: $version"
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) ]]; then
echo 'Your Git is clean. Please update the VERSION, CHANGELOG.md, and optionally RELEASE_NOTES.md before releasing. The script will handle commits and pushing.'
exit 1
fi
# Make sure we have the most recent changes, without destroying local changes.
git stash
git pull --rebase origin master
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