Skip to content

Commit

Permalink
Create release script
Browse files Browse the repository at this point in the history
  • Loading branch information
ooesili committed Feb 24, 2018
1 parent 1f7cea3 commit f44809f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/partygif
/build
68 changes: 68 additions & 0 deletions release
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 "$@"

0 comments on commit f44809f

Please sign in to comment.