You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.2 KiB

  1. #!/usr/bin/env bash
  2. set -e
  3. # WARN: non hermetic build (people must run this script inside docker to
  4. # produce deterministic binaries).
  5. # Get the version from the environment, or try to figure it out.
  6. if [ -z $VERSION ]; then
  7. VERSION=$(awk -F\" '/Version =/ { print $2; exit }' < version/version.go)
  8. fi
  9. if [ -z "$VERSION" ]; then
  10. echo "Please specify a version."
  11. exit 1
  12. fi
  13. echo "==> Building version $VERSION..."
  14. # Delete the old dir
  15. echo "==> Removing old directory..."
  16. rm -rf build/pkg
  17. mkdir -p build/pkg
  18. # Get the git commit
  19. GIT_COMMIT="$(git rev-parse --short=8 HEAD)"
  20. GIT_IMPORT="github.com/tendermint/tendermint/version"
  21. # Determine the arch/os combos we're building for
  22. XC_ARCH=${XC_ARCH:-"386 amd64 arm"}
  23. XC_OS=${XC_OS:-"solaris darwin freebsd linux windows"}
  24. XC_EXCLUDE=${XC_EXCLUDE:-" darwin/arm solaris/amd64 solaris/386 solaris/arm freebsd/amd64 windows/arm "}
  25. # Make sure build tools are available.
  26. make get_tools
  27. # Get VENDORED dependencies
  28. make get_vendor_deps
  29. # Build!
  30. # ldflags: -s Omit the symbol table and debug information.
  31. # -w Omit the DWARF symbol table.
  32. echo "==> Building..."
  33. IFS=' ' read -ra arch_list <<< "$XC_ARCH"
  34. IFS=' ' read -ra os_list <<< "$XC_OS"
  35. for arch in "${arch_list[@]}"; do
  36. for os in "${os_list[@]}"; do
  37. if [[ "$XC_EXCLUDE" != *" $os/$arch "* ]]; then
  38. echo "--> $os/$arch"
  39. GOOS=${os} GOARCH=${arch} go build -ldflags "-s -w -X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}" -tags="${BUILD_TAGS}" -o "build/pkg/${os}_${arch}/tendermint" ./cmd/tendermint
  40. fi
  41. done
  42. done
  43. # Zip all the files.
  44. echo "==> Packaging..."
  45. for PLATFORM in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type d); do
  46. OSARCH=$(basename "${PLATFORM}")
  47. echo "--> ${OSARCH}"
  48. pushd "$PLATFORM" >/dev/null 2>&1
  49. zip "../${OSARCH}.zip" ./*
  50. popd >/dev/null 2>&1
  51. done
  52. # Add "tendermint" and $VERSION prefix to package name.
  53. rm -rf ./build/dist
  54. mkdir -p ./build/dist
  55. for FILENAME in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type f); do
  56. FILENAME=$(basename "$FILENAME")
  57. cp "./build/pkg/${FILENAME}" "./build/dist/tendermint_${VERSION}_${FILENAME}"
  58. done
  59. # Make the checksums.
  60. pushd ./build/dist
  61. shasum -a256 ./* > "./tendermint_${VERSION}_SHA256SUMS"
  62. popd
  63. # Done
  64. echo
  65. echo "==> Results:"
  66. ls -hl ./build/dist
  67. exit 0