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.

114 lines
3.0 KiB

  1. #!/bin/bash
  2. # Simple bash script to build basic loop tools for all the platforms
  3. # we support with the golang cross-compiler.
  4. #
  5. # Copyright (c) 2016 Company 0, LLC.
  6. # Use of this source code is governed by the ISC
  7. # license.
  8. # Exit on errors.
  9. set -e
  10. # If no tag specified, use date + version otherwise use tag.
  11. if [[ $1x = x ]]; then
  12. DATE=`date +%Y%m%d`
  13. VERSION="01"
  14. TAG=$DATE-$VERSION
  15. else
  16. TAG=$1
  17. # If a tag is specified, ensure that that tag is present and checked out.
  18. if [[ $TAG != $(git describe) ]]; then
  19. echo "tag $TAG not checked out"
  20. exit 1
  21. fi
  22. # Verify that it is signed.
  23. if ! git verify-tag $TAG; then
  24. echo "tag $TAG not signed"
  25. exit 1
  26. fi
  27. # Build loop to extract version.
  28. make
  29. # Extract version command output.
  30. LOOP_VERSION_OUTPUT=`./loopd-debug --version`
  31. # Use a regex to isolate the version string.
  32. LOOP_VERSION_REGEX="version (.+) "
  33. if [[ $LOOP_VERSION_OUTPUT =~ $LOOP_VERSION_REGEX ]]; then
  34. # Prepend 'v' to match git tag naming scheme.
  35. LOOP_VERSION="v${BASH_REMATCH[1]}"
  36. echo "version: $LOOP_VERSION"
  37. # Match git tag with loop version.
  38. if [[ $TAG != $LOOP_VERSION ]]; then
  39. echo "loop version $LOOP_VERSION does not match tag $TAG"
  40. exit 1
  41. fi
  42. else
  43. echo "malformed loop version output"
  44. exit 1
  45. fi
  46. fi
  47. go mod vendor
  48. tar -cvzf vendor.tar.gz vendor
  49. PACKAGE=loop
  50. MAINDIR=$PACKAGE-$TAG
  51. mkdir -p $MAINDIR
  52. cp vendor.tar.gz $MAINDIR/
  53. rm vendor.tar.gz
  54. rm -r vendor
  55. PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar"
  56. git archive -o $PACKAGESRC HEAD
  57. gzip -f $PACKAGESRC > "$PACKAGESRC.gz"
  58. cd $MAINDIR
  59. # If LOOPBUILDSYS is set the default list is ignored. Useful to release
  60. # for a subset of systems/architectures.
  61. SYS=${LOOPBUILDSYS:-"windows-386 windows-amd64 openbsd-386 openbsd-amd64 linux-386 linux-amd64 linux-armv6 linux-armv7 linux-arm64 darwin-amd64 dragonfly-amd64 freebsd-386 freebsd-amd64 freebsd-arm netbsd-386 netbsd-amd64 linux-mips64 linux-mips64le linux-ppc64"}
  62. # Use the first element of $GOPATH in the case where GOPATH is a list
  63. # (something that is totally allowed).
  64. PKG="github.com/lightninglabs/loop"
  65. COMMIT=$(git describe --abbrev=40 --dirty)
  66. COMMITFLAGS="-X $PKG/build.Commit=$COMMIT"
  67. for i in $SYS; do
  68. OS=$(echo $i | cut -f1 -d-)
  69. ARCH=$(echo $i | cut -f2 -d-)
  70. ARM=
  71. if [[ $ARCH = "armv6" ]]; then
  72. ARCH=arm
  73. ARM=6
  74. elif [[ $ARCH = "armv7" ]]; then
  75. ARCH=arm
  76. ARM=7
  77. fi
  78. mkdir $PACKAGE-$i-$TAG
  79. cd $PACKAGE-$i-$TAG
  80. echo "Building:" $OS $ARCH $ARM
  81. env GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -ldflags "$COMMITFLAGS" github.com/lightninglabs/loop/cmd/loop
  82. env GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -ldflags "$COMMITFLAGS" github.com/lightninglabs/loop/cmd/loopd
  83. cd ..
  84. if [[ $OS = "windows" ]]; then
  85. zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG
  86. else
  87. tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG
  88. fi
  89. rm -r $PACKAGE-$i-$TAG
  90. done
  91. shasum -a 256 * > manifest-$TAG.txt