-
Notifications
You must be signed in to change notification settings - Fork 155
/
release.sh
executable file
·45 lines (37 loc) · 1.48 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
#!/bin/bash
DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
cd $DIR
set -e
./etc/checkprepared.sh
remote=$(git rev-parse "@{u}") # "@{u}" gets the current upstream branch
local=$(git rev-parse @) # '@' gets the current local branch
# check if local commit syncs with remote
if [ "$remote" != "$local" ]; then
echo "Error: local commit does not match remote. Exiting release script."
exit 1
fi
state=`curl -s https://api.github.com/repos/influxdata/flux/commits/${local}/status | jq -r ".state"`
if [ "$state" != "success" ]; then
echo "Error: commit state is \"$state\". Exiting release script"
exit 1
fi
# remove any excess brackets, space/tab characters and 'origin' branch and sort the tags
git_remote_tags () { git ls-remote --tags origin | grep -v '{}' | sort | tr -d [[:blank:]] ; }
git_local_tags () { git show-ref --tags | grep -v '{}' | grep -v 'origin'| grep -v 'list'| sort | tr -d [[:blank:]] ; }
# check if local tags are different from remote tags
if ! diff -q <(git_remote_tags) <(git_local_tags) &>/dev/null; then
echo "Error: local tags do not match remote. Exiting release script."
diff -u <(git_remote_tags) <(git_local_tags)
exit 1
fi
# cut the next Flux release
version=$1
if [ "$version" == "" ]; then
version=$(./gotool.sh github.com/influxdata/changelog nextver)
fi
if [[ $version != v* ]]; then
echo "Error: invalid tag specified. Tag must be prefixed with 'v'."
exit 1
fi
git tag -s -m "Release $version" "$version"
git push origin "$version"