build-release.sh raw

   1  #!/bin/sh
   2  # Build the gateway for every supported platform and sign a release manifest.
   3  #
   4  # The signing key is read from a file and never leaves this machine; the artifacts and the signed
   5  # manifest are what get published. Usage:
   6  #
   7  #   NOSTRINO_RELEASE_KEY=~/.config/nostrino/release.key \
   8  #   ./scripts/build-release.sh 0.3.0 https://downloads.example/nostrino
   9  #
  10  set -eu
  11  
  12  VERSION=${1:?usage: build-release.sh <version> <base-url>}
  13  BASE=${2:?usage: build-release.sh <version> <base-url>}
  14  KEY=${NOSTRINO_RELEASE_KEY:?set NOSTRINO_RELEASE_KEY to the Ed25519 private key file}
  15  OUT=${OUT:-dist}
  16  
  17  rm -rf "$OUT"
  18  mkdir -p "$OUT"
  19  
  20  for platform in linux/amd64 linux/arm64; do
  21  	os=${platform%%/*}
  22  	arch=${platform##*/}
  23  	echo "building $os/$arch"
  24  	CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \
  25  		-ldflags "-s -w -X main.version=$VERSION" \
  26  		-o "$OUT/nostrino-gateway-$VERSION-$os-$arch" ./cmd/nostrino-bridge
  27  
  28  	# The operator CLI is shipped beside the gateway: a gateway that updates itself is only
  29  	# useful if the operator has a way to send the command, and asking an operator to install a
  30  	# Go toolchain on a Start9 box to do it is not a way. It is not in the manifest (the gateway
  31  	# is the only thing that installs itself); the release notes name its digest.
  32  	CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \
  33  		-ldflags "-s -w -X main.version=$VERSION" \
  34  		-o "$OUT/nostrino-admin-$VERSION-$os-$arch" ./cmd/nostrino-admin
  35  done
  36  
  37  echo "signing manifest"
  38  go run ./cmd/nostrino-release \
  39  	-artifacts "$OUT" -version "$VERSION" -key "$(cat "$KEY")" \
  40  	-base-url "$BASE" -out "$OUT/manifest.json" ${NOTES:+-notes "$NOTES"}
  41  
  42  echo "release $VERSION is in $OUT"
  43  ls -l "$OUT"
  44