File tree Expand file tree Collapse file tree 1 file changed +74
-0
lines changed
Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ PROJDIR=$( cd ` dirname $0 ` /.. && pwd)
3+
4+ VERSION=" ${1} "
5+ TAG=" v${VERSION} "
6+ USER=" tomnomnom"
7+ REPO=" httprobe"
8+ BINARY=" ${REPO} "
9+
10+ if [[ -z " ${VERSION} " ]]; then
11+ echo " Usage: ${0} <version>"
12+ exit 1
13+ fi
14+
15+ if [[ -z " ${GITHUB_TOKEN} " ]]; then
16+ echo " You forgot to set your GITHUB_TOKEN"
17+ exit 2
18+ fi
19+
20+ cd ${PROJDIR}
21+
22+ # Run the tests
23+ go test
24+ if [ $? -ne 0 ]; then
25+ echo " Tests failed. Aborting."
26+ exit 3
27+ fi
28+
29+ # Check if tag exists
30+ git fetch --tags
31+ git tag | grep " ^${TAG} $"
32+
33+ if [ $? -ne 0 ]; then
34+ github-release release \
35+ --user ${USER} \
36+ --repo ${REPO} \
37+ --tag ${TAG} \
38+ --name " ${REPO} ${TAG} " \
39+ --description " ${TAG} " \
40+ --pre-release
41+ fi
42+
43+
44+ for ARCH in " amd64" " 386" ; do
45+ for OS in " darwin" " linux" " windows" " freebsd" ; do
46+
47+ BINFILE=" ${BINARY} "
48+
49+ if [[ " ${OS} " == " windows" ]]; then
50+ BINFILE=" ${BINFILE} .exe"
51+ fi
52+
53+ rm -f ${BINFILE}
54+
55+ GOOS=${OS} GOARCH=${ARCH} go build github.com/${USER} /${REPO}
56+
57+ if [[ " ${OS} " == " windows" ]]; then
58+ ARCHIVE=" ${BINARY} -${OS} -${ARCH} -${VERSION} .zip"
59+ zip ${ARCHIVE} ${BINFILE}
60+ else
61+ ARCHIVE=" ${BINARY} -${OS} -${ARCH} -${VERSION} .tgz"
62+ tar --create --gzip --file=${ARCHIVE} ${BINFILE}
63+ fi
64+
65+ echo " Uploading ${ARCHIVE} ..."
66+ github-release upload \
67+ --user ${USER} \
68+ --repo ${REPO} \
69+ --tag ${TAG} \
70+ --name " ${ARCHIVE} " \
71+ --file ${PROJDIR} /${ARCHIVE}
72+ done
73+ done
74+
You can’t perform that action at this time.
0 commit comments