-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b8eee7
commit ad6e1cb
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
version=$1 | ||
|
||
if [[ -z "$version" ]]; then | ||
echo "usage: $0 <version-number>" | ||
exit 1 | ||
fi | ||
|
||
git_sha=`git rev-parse --short HEAD` | ||
version_with_sha="${version}+${git_sha}" | ||
|
||
if [ -d build ]; then | ||
rm -rf build | ||
fi | ||
mkdir -p build | ||
|
||
platforms=("windows/amd64" "linux/amd64" "darwin/amd64") | ||
|
||
echo "==> Build started for v${version}" | ||
|
||
for platform in "${platforms[@]}" | ||
do | ||
platform_split=(${platform//\// }) | ||
GOOS=${platform_split[0]} | ||
GOARCH=${platform_split[1]} | ||
output_name="cf-vault_${version}_${GOOS}_${GOARCH}" | ||
|
||
printf "==> Building %s\t%s\n" "$platform" "build/$output_name" | expand -t 30 | ||
|
||
|
||
if [ $GOOS = "windows" ]; then | ||
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}.exe" -ldflags "-X github.com/jacobbednarz/cf-vault/cmd.Rev=${version_with_sha}" . | ||
else | ||
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}" -ldflags "-X github.com/jacobbednarz/cf-vault/cmd.Rev=${version_with_sha}" . | ||
fi | ||
if [ $? -ne 0 ]; then | ||
echo "Building the binary has failed!" | ||
exit 1 | ||
fi | ||
|
||
printf "==> Tarballing %s\t%s\n" "$platform" "build/${output_name}.tar.gz" | expand -t 30 | ||
if [ $GOOS = "windows" ]; then | ||
tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}.exe" | ||
else | ||
tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}" | ||
fi | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Creating the tarball has failed!" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "==> Generating file checksums to build/checksums.txt" | ||
shasum -a 256 build/* > "build/checksums.txt" | ||
|
||
echo "==> Build process complete" |