Skip to content

Commit

Permalink
Merge pull request #9 from jacobbednarz/cleanup-executable-names
Browse files Browse the repository at this point in the history
Cleanup build script output
  • Loading branch information
jacobbednarz authored Sep 24, 2020
2 parents 26f886b + 19d0753 commit d55f950
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,42 @@ do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}

mkdir -p "build/${GOOS}"

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}" .
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${GOOS}/cf-vault.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}" .
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${GOOS}/cf-vault" -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

touch build/checksums.txt

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"
tar -czf "build/${output_name}.tar.gz" -C "build/$GOOS" "cf-vault.exe"
else
tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}"
tar -czf "build/${output_name}.tar.gz" -C "build/$GOOS" "cf-vault"
fi

if [ $? -ne 0 ]; then
echo "Creating the tarball has failed!"
exit 1
fi

echo "==> Adding file checksums to build/checksums.txt"
shasum -a 256 build/$GOOS/* >> "build/checksums.txt"
done

echo "==> Generating file checksums to build/checksums.txt"
shasum -a 256 build/* > "build/checksums.txt"
shasum -a 256 build/*.tar.gz >> "build/checksums.txt"

echo "==> Build process complete"

0 comments on commit d55f950

Please sign in to comment.