decred.org/dcrdex@v1.0.5/pkg.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  
     5  # For release, remove pre-release info, and set metadata to "release".
     6  VER="1.0.5" # pre, beta, rc1, etc.
     7  META="release"
     8  
     9  export CGO_ENABLED=0
    10  export GOWORK=off
    11  
    12  # if META set, append "+${META}", otherwise nothing.
    13  LDFLAGS_BASE="-buildid= -s -w -X main.Version=${VER}${META:++${META}}"
    14  
    15  # Build the webpack bundle prior to building the webserver package, which embeds
    16  # the files.
    17  pushd client/webserver/site
    18  go generate # just check, no write
    19  npm ci
    20  npm run build
    21  popd
    22  
    23  rm -rf bin
    24  
    25  build_targets (){
    26    for TARGET in ${TARGETS}; do
    27      OS=${TARGET%%/*}
    28      ARCH=${TARGET##*/}
    29      echo "Building for ${OS}-${ARCH}"
    30  
    31      mkdir -p "bin/bisonw-${OS}-${ARCH}-v${VER}"
    32  
    33      pushd client/cmd/bisonw
    34      GOOS=${OS} GOARCH=${ARCH} go build -trimpath ${TAGS_BISONW:+-tags ${TAGS_BISONW}} -o "../../../bin/bisonw-${OS}-${ARCH}-v${VER}/${BISONW_EXE}" -ldflags "${LDFLAGS_BISONW:-${LDFLAGS_BASE}}"
    35      popd
    36  
    37      pushd client/cmd/bwctl
    38      GOOS=${OS} GOARCH=${ARCH} go build -trimpath -o "../../../bin/bisonw-${OS}-${ARCH}-v${VER}" -ldflags "${LDFLAGS_BASE}"
    39      popd
    40  
    41      pushd bin
    42      if [[ "$OS" == "windows" ]]; then
    43        zip -9 -r -q "bisonw-${OS}-${ARCH}-v${VER}.zip" "bisonw-${OS}-${ARCH}-v${VER}"
    44      else
    45        tar -I 'gzip -9' --owner=0 --group=0 -cf "bisonw-${OS}-${ARCH}-v${VER}.tar.gz" "bisonw-${OS}-${ARCH}-v${VER}"
    46      fi
    47      popd
    48    done
    49  }
    50  
    51  # Vanilla builds on all supported os/arch targets
    52  TARGETS="linux/amd64 linux/arm64 linux/riscv64 darwin/amd64 darwin/arm64 freebsd/amd64 openbsd/amd64 openbsd/arm64"
    53  build_targets
    54  
    55  # Only Windows gets the systray build
    56  TARGETS="windows/amd64"
    57  TAGS_BISONW="systray"
    58  BISONW_EXE="bisonw.exe"
    59  LDFLAGS_BISONW="${LDFLAGS_BASE} -H=windowsgui"
    60  build_targets
    61  
    62  echo "Files embedded in the Go webserver package:"
    63  go list -f '{{ .EmbedFiles }}' decred.org/dcrdex/client/webserver
    64  # NOTE: before embedding, we needed to grab: dist, src/font, src/html, src/img.
    65  
    66  pushd bin
    67  sha256sum *.gz *.zip > bisonw-v${VER}-manifest.txt
    68  popd