forked from messagebird/beanstalkd_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·53 lines (42 loc) · 1.2 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
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# a hack to generate releases like other prometheus projects
# use like this:
# VERSION=1.0.1 ./release.sh
set -e
# github user and repo
USER=messagebird
REPO=beanstalkd_exporter
BIN_PACKAGE=github.com/${USER}/${REPO}
BIN_DIR=bin
if [ -z "$VERSION" ]; then
>&2 echo "missing VERSION=X.X.X"
exit 1
fi
function build_for {
BIN_NAME="bin/${REPO}-${VERSION}.$1-$2"
GOOS=$1 GOARCH=$2 CGO_ENABLED=0 go build -ldflags "-s -w" -o ${BIN_NAME} ${BIN_PACKAGE}
shasum -a 256 ${BIN_NAME} > ${BIN_NAME}.sha256
}
rm -rf ${BIN_DIR}
mkdir -p ${BIN_DIR}
build_for linux amd64
build_for darwin amd64
docker build -t ${USER}/${REPO}:${VERSION} .
git tag -a $VERSION -m "version $VERSION"
github-release release \
--user $USER \
--repo $REPO \
--tag $VERSION \
--name $VERSION \
--description "version $VERSION"
for release_file in $(ls ${BIN_DIR}); do
github-release upload \
--user $USER \
--repo $REPO \
--tag $VERSION \
--name "${release_file}" \
--file "${BIN_DIR}/${release_file}"
done
docker push ${USER}/${REPO}:${VERSION}
docker tag ${USER}/${REPO}:${VERSION} ${USER}/${REPO}:latest
docker push ${USER}/${REPO}:latest