-
Notifications
You must be signed in to change notification settings - Fork 68
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
bc2c0ba
commit f0fc73d
Showing
3 changed files
with
83 additions
and
2 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,80 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# WARN: non hermetic build (people must run this script inside docker to | ||
# produce deterministic binaries). | ||
|
||
# Get the version from the environment, or try to figure it out. | ||
if [ -z $VERSION ]; then | ||
VERSION=$(awk -F\" '/Version =/ { print $2; exit }' < version/version.go) | ||
fi | ||
if [ -z "$VERSION" ]; then | ||
echo "Please specify a version." | ||
exit 1 | ||
fi | ||
echo "==> Building version $VERSION..." | ||
|
||
# Delete the old dir | ||
echo "==> Removing old directory..." | ||
rm -rf build/pkg | ||
mkdir -p build/pkg | ||
|
||
# Get the git commit | ||
GIT_COMMIT="$(git rev-parse --short=8 HEAD)" | ||
GIT_IMPORT="github.com/MinterTeam/minter-go-node/version" | ||
|
||
# Determine the arch/os combos we're building for | ||
XC_ARCH=${XC_ARCH:-"amd64"} | ||
XC_OS=${XC_OS:-"darwin linux windows"} | ||
|
||
# Make sure build tools are available. | ||
make get_tools | ||
|
||
# Get VENDORED dependencies | ||
make get_vendor_deps | ||
|
||
packr | ||
|
||
# Build! | ||
# ldflags: -s Omit the symbol table and debug information. | ||
# -w Omit the DWARF symbol table. | ||
echo "==> Building..." | ||
IFS=' ' read -ra arch_list <<< "$XC_ARCH" | ||
IFS=' ' read -ra os_list <<< "$XC_OS" | ||
for arch in "${arch_list[@]}"; do | ||
for os in "${os_list[@]}"; do | ||
echo "--> $os/$arch" | ||
GOOS=${os} GOARCH=${arch} go build -ldflags "-s -w -X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}" -tags="${BUILD_TAGS}" -o "build/pkg/${os}_${arch}/minter" ./cmd/minter | ||
done | ||
done | ||
|
||
# Zip all the files. | ||
echo "==> Packaging..." | ||
for PLATFORM in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type d); do | ||
OSARCH=$(basename "${PLATFORM}") | ||
echo "--> ${OSARCH}" | ||
|
||
pushd "$PLATFORM" >/dev/null 2>&1 | ||
zip "../${OSARCH}.zip" ./* | ||
popd >/dev/null 2>&1 | ||
done | ||
|
||
# Add "minter" and $VERSION prefix to package name. | ||
rm -rf ./build/dist | ||
mkdir -p ./build/dist | ||
for FILENAME in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type f); do | ||
FILENAME=$(basename "$FILENAME") | ||
cp "./build/pkg/${FILENAME}" "./build/dist/minter_${VERSION}_${FILENAME}" | ||
done | ||
|
||
# Make the checksums. | ||
pushd ./build/dist | ||
shasum -a256 ./* > "./minter_${VERSION}_SHA256SUMS" | ||
popd | ||
|
||
# Done | ||
echo | ||
echo "==> Results:" | ||
ls -hl ./build/dist | ||
|
||
exit 0 |