-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease
executable file
·68 lines (56 loc) · 1.12 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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
main() {
validate
clean
compile
compress
release
}
validate() {
if [[ -n "$(git status --porcelain)" ]]; then
echo 'error: repo has uncomitted changes'
exit 1
fi
if [[ "$(git symbolic-ref --short HEAD)" != master ]]; then
echo 'error: not on the master branch'
exit 1
fi
log 'fetching upstream branches'
git fetch
if [[ "$(git rev-parse master)" != "$(git rev-parse origin/master)" ]]; then
echo 'error: not up to date with origin/master'
exit 1
fi
if ! git describe --tags --exact-match &> /dev/null; then
echo 'error: current commit is not tagged'
exit 1
fi
}
clean() {
log 'cleaning build directory'
rm -rf build
mkdir build
}
compile() {
log 'cross compiling'
(cd build && gox -gocmd=vgo ..)
}
compress() {
log 'compressing binaries'
for file in build/*; do
zip "${file%.*}.zip" "$file"
rm "$file"
done
}
release() {
log 'creating release'
local tag
tag="$(git describe --tags --exact-match)"
ghr -username ooesili -repository partygif "$tag" build
}
log() {
echo "==> $*"
}
main "$@"