cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

cat/module-path
012 / scripts / dist.sh
dist.sh 1.9K executable
1#!/usr/bin/env bash2# dist.sh - what `make dist VERSION=v1.2.3` does: cross-compile 012 as3# pure Go for each platform into dist/, stamped with the version, one4# archive per platform (tar.gz, zip for Windows) and a SHA256SUMS file.5# Nothing is uploaded. See docs/contributing/releasing.md.6#7# VERSION=v1.2.3 required, a semantic version tag8# PLATFORMS="darwin/arm64 linux/amd64" narrow the list9set -euo pipefail1011root=$(cd "$(dirname "$0")/.." && pwd)12cd "$root"1314version=${VERSION:-}15if ! [[ $version =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then16 echo "dist: VERSION must be a version like v1.2.3 (got '${version}')" >&217 exit 118fi19if [ -n "$(git status --porcelain --untracked-files=no 2>/dev/null)" ]; then20 echo "dist: warning: the working tree has uncommitted changes; the binaries include them" >&221fi22if tag=$(git rev-parse -q --verify "refs/tags/$version^{commit}" 2>/dev/null) && [ "$tag" != "$(git rev-parse HEAD)" ]; then23 echo "dist: $version is tagged at another commit; check out the tag first" >&224 exit 125fi26platforms=${PLATFORMS:-"darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64"}2728out="$root/dist"29rm -rf "$out"30mkdir -p "$out"3132for p in $platforms; do33 goos=${p%/*}34 goarch=${p#*/}35 name="012_${version#v}_${goos}_${goarch}"36 dir="$out/$name"37 exe=01238 if [ "$goos" = windows ]; then39 exe=012.exe40 fi41 mkdir -p "$dir"42 echo "dist: $name"43 CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch go build -trimpath \44 -ldflags "-s -w -X main.version=$version" -o "$dir/$exe" ./cmd/01245 cp LICENSE NOTICE README.md "$dir/"46 if [ "$goos" = windows ]; then47 (cd "$out" && zip -qrX "$name.zip" "$name")48 else49 tar -C "$out" -czf "$out/$name.tar.gz" "$name"50 fi51 rm -rf "$dir"52done5354(55 cd "$out"56 if command -v sha256sum >/dev/null 2>&1; then57 sha256sum -- 012_* >SHA256SUMS58 else59 shasum -a 256 -- 012_* >SHA256SUMS60 fi61)62echo "dist: $(find "$out" -type f | wc -l | tr -d ' ') files in dist/"63cat "$out/SHA256SUMS"