-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_release.sh
executable file
·60 lines (45 loc) · 2.56 KB
/
build_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
54
55
56
57
58
59
60
#! /usr/bin/env bash
#set -e
if [ $# -ne 2 ]; then
echo "need the version number and release comment as argument"
echo "e.g. ${0} 0.4.5 'fix local modules and modules with install_path purging bug #80 #82'"
echo "Aborting..."
exit 1
fi
git pull
#time go test -v
if [ $? -ne 0 ]; then
echo "Tests unsuccessfull"
echo "Aborting..."
exit 1
fi
# try to get the project name from the current working directory
projectname=${PWD##*/}
#sed -i "s/${projectname} version [^ ]*/${projectname} version ${1}/" ${projectname}.go
#git add ${projectname}.go
#git commit -m "bump version to v${1}"
echo "creating git tag v${1}"
git tag v${1}
echo "pushing git tag v${1}"
git push -f --tags
git push
test -z ${GITHUB_TOKEN} || echo "creating github release v${1}"
test -z ${GITHUB_TOKEN} && echo "skipping github-release as GITHUB_TOKEN is not set" || github-release release --user xorpaul --repo ${projectname} --tag v${1} --name "v${1}" --description "${2}"
export CGO_ENABLED=0
export BUILDTIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
export BUILDVERSION=$(git describe --tags)
### macOS Intel
echo "building and uploading ${projectname}-darwin-amd64"
env GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.buildtime=${BUILDTIME} -X main.buildversion=${BUILDVERSION}" && date
zip ${projectname}-darwin-amd64.zip ${projectname}
test -z ${GITHUB_TOKEN} && echo "skipping github-release as GITHUB_TOKEN is not set" || github-release upload --user xorpaul --repo ${projectname} --tag v${1} --name "${projectname}-darwin-amd64.zip" --file ${projectname}-darwin-amd64.zip
### macOS ARM
echo "building and uploading ${projectname}-darwin-arm64"
env GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.buildtime=${BUILDTIME} -X main.buildversion=${BUILDVERSION}" && date
zip ${projectname}-darwin-arm64.zip ${projectname}
test -z ${GITHUB_TOKEN} && echo "skipping github-release as GITHUB_TOKEN is not set" || github-release upload --user xorpaul --repo ${projectname} --tag v${1} --name "${projectname}-darwin-arm64.zip" --file ${projectname}-darwin-arm64.zip
### LINUX
echo "building and uploading ${projectname}-linux-amd64"
go build -ldflags "-X main.buildtime=${BUILDTIME} -X main.buildversion=${BUILDVERSION}" && date && env ${projectname}_cachedir=/tmp/${projectname} ./${projectname} -config test.yaml -branch benchmark 2>&1
zip ${projectname}-linux-amd64.zip ${projectname}
test -z ${GITHUB_TOKEN} && echo "skipping github-release as GITHUB_TOKEN is not set" || github-release upload --user xorpaul --repo ${projectname} --tag v${1} --name "${projectname}-linux-amd64.zip" --file ${projectname}-linux-amd64.zip