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.

78 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\" 'TMCoreSemVer =/ { 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. # Build!
  28. # ldflags: -s Omit the symbol table and debug information.
  29. # -w Omit the DWARF symbol table.
  30. echo "==> Building..."
  31. IFS=' ' read -ra arch_list <<< "$XC_ARCH"
  32. IFS=' ' read -ra os_list <<< "$XC_OS"
  33. for arch in "${arch_list[@]}"; do
  34. for os in "${os_list[@]}"; do
  35. if [[ "$XC_EXCLUDE" != *" $os/$arch "* ]]; then
  36. echo "--> $os/$arch"
  37. 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
  38. fi
  39. done
  40. done
  41. # Zip all the files.
  42. echo "==> Packaging..."
  43. for PLATFORM in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type d); do
  44. OSARCH=$(basename "${PLATFORM}")
  45. echo "--> ${OSARCH}"
  46. pushd "$PLATFORM" >/dev/null 2>&1
  47. zip "../${OSARCH}.zip" ./*
  48. popd >/dev/null 2>&1
  49. done
  50. # Add "tendermint" and $VERSION prefix to package name.
  51. rm -rf ./build/dist
  52. mkdir -p ./build/dist
  53. for FILENAME in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type f); do
  54. FILENAME=$(basename "$FILENAME")
  55. cp "./build/pkg/${FILENAME}" "./build/dist/tendermint_${VERSION}_${FILENAME}"
  56. done
  57. # Make the checksums.
  58. pushd ./build/dist
  59. shasum -a256 ./* > "./tendermint_${VERSION}_SHA256SUMS"
  60. popd
  61. # Done
  62. echo
  63. echo "==> Results:"
  64. ls -hl ./build/dist
  65. exit 0