forked from airbytehq/abctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-release-builds
executable file
·66 lines (57 loc) · 2.14 KB
/
create-release-builds
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
61
62
63
64
65
66
#!/usr/bin/env bash
# script for automating the releasing of abctl to various hosts
# will eventually be replaced by a github workflow and/or goreleaser
ABCTL_VERSION="${ABCTL_VERSION:-dev}"
# if ABCTL_VERSION is not dev, ensure that it starts with a 'v'
if [ "$ABCTL_VERSION" != "dev" ]; then
if [[ "$ABCTL_VERSION" != v* ]]; then
ABCTL_VERSION="v$ABCTL_VERSION"
fi
fi
echo "creating release builds for ${ABCTL_VERSION}"
readonly release_dir="build/release"
# abtar tars a build binary into a tar.gz archive
# @param goos that the binary was built for
# @param goarch that the binary was built for
abtar() {
local goos=$1
local goarch=$2
pushd "$release_dir" > /dev/null
tar -czf "abctl-$ABCTL_VERSION-$goos-$goarch.tar.gz" "abctl-$ABCTL_VERSION-$goos-$goarch"
popd > /dev/null
}
# abzip zips a build binary into a .zip archive
# @param goos that the binary was built for
# @param goarch that the binary was built for
abzip() {
local goos=$1
local goarch=$2
pushd "$release_dir" > /dev/null
zip -q -r "abctl-$ABCTL_VERSION-$goos-$goarch.zip" "abctl-$ABCTL_VERSION-$goos-$goarch"
popd > /dev/null
}
# abbuild builds a binary
# @param goos to build binary for
# @param goarch to build binary for
# @param compress format either abtar (for tar) or abzip (for zip)
#
# The built binary will be created in the directory in the directory $release_dir/abctl-$ABCTL_VERSION-$goos-$goarch
# (e.g. build/release/abctl-v1.0.0-darwin-arm64). This is done to ensure the directory is unique for the goos/goarch
# and that it can be easily compressed via the abtar or abzip functions.
abbuild() {
local goos=$1
local goarch=$2
local compress=$3
echo " - $goos/$goarch"
GOOS="$goos" GOARCH="$goarch" CGO_ENABLED=0 go build -trimpath -o "$release_dir/abctl-$ABCTL_VERSION-$goos-$goarch/" -ldflags "-w -X github.com/airbytehq/abctl/internal/build.Version=${ABCTL_VERSION}" .
eval $compress "$goos" "$goarch"
}
echo "building darwin"
abbuild "darwin" "amd64" abtar
abbuild "darwin" "arm64" abtar
echo "building linux"
abbuild "linux" "amd64" abtar
abbuild "linux" "arm64" abtar
echo "building windows"
abbuild "windows" "amd64" abzip
echo "completed release builds"