-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathbuild
executable file
·50 lines (40 loc) · 1.51 KB
/
build
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
#!/bin/bash
set -eu
header() {
echo
echo "================================================================================"
echo "$1"
echo "--------------------------------------------------------------------------------"
echo
}
bail() {
echo >&2 "$* Did you misconfigure Concourse?"
exit 2
}
test -n "${APP_NAME:-}" || bail "APP_NAME must be set to the name of this package."
test -n "${MODULE:-}" || bail "MODULE must be set to the Go Module path of this package."
test -n "${GOPATH:-}" || bail "Expecting GOPATH to be set -- make sure correct image is specified."
test -f "${VERSION_FROM}" || bail "Version file (${VERSION_FROM}) not found."
VERSION=$(cat "${VERSION_FROM}")
test -n "${VERSION}" || bail "Version file (${VERSION_FROM}) was empty."
# Resource Directories
export ROOT_PATH="$(pwd)"
mkdir -p "$(dirname ${GOPATH}/src/${MODULE})"
mv ${ROOT_PATH}/git "${GOPATH}/src/${MODULE}
ln -snf "${GOPATH}/src/${MODULE} ${ROOT_PATH}/git
export PATH=${PATH}:${GOPATH}/bin
export REPO_ROOT="${GOPATH}/src/${MODULE}"
export BUILD_ROOT="${ROOT_PATH}/build"
export CI_ROOT="${ROOT_PATH}/git-ci"
export VERSION_FROM="version/number"
export RELEASE_ROOT="${REPO_ROOT}/artifacts"
header "Building $APP_NAME v$VERSION..."
cd "$REPO_ROOT"
go version; echo; echo
make clean release VERSION="$VERSION"
cd "$RELEASE_ROOT"
tar -zcvf "$BUILD_ROOT/$APP_NAME-$VERSION.tar.gz" "$APP_NAME-"*
echo
echo "================================================================================"
echo "SUCCESS!"
exit 0