File size: 1,570 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Build release-style PinchTab binaries into ./dist for the current or requested platform.
set -euo pipefail

cd "$(dirname "$0")/.."

VERSION_VALUE="${VERSION:-dev}"
DIST_DIR="${DIST_DIR:-dist}"
MODE="${1:-current}"

build_one() {
  local goos_value="$1"
  local goarch_value="$2"
  local ext=""

  if [ "$goos_value" = "windows" ]; then
    ext=".exe"
  fi

  local output_path="$DIST_DIR/pinchtab-$goos_value-$goarch_value$ext"

  echo "📦 Building release-style binary..."
  echo "   target: ${goos_value}/${goarch_value}"
  echo "   output: ${output_path}"

  GOCACHE="${GOCACHE:-$PWD/.gocache}" \
  GOOS="$goos_value" \
  GOARCH="$goarch_value" \
  go build \
    -buildvcs=false \
    -ldflags="-s -w -X main.version=${VERSION_VALUE}" \
    -o "$output_path" \
    ./cmd/pinchtab

  if command -v stat >/dev/null 2>&1; then
    if stat -f '%z bytes %N' "$output_path" >/dev/null 2>&1; then
      stat -f '%z bytes %N' "$output_path"
    else
      stat -c '%s bytes %n' "$output_path"
    fi
  fi

  echo "✅ Binary complete: ${output_path}"
}

mkdir -p "$DIST_DIR" .gocache

./scripts/build-dashboard.sh

case "$MODE" in
  all)
    for goos_value in linux darwin windows; do
      for goarch_value in amd64 arm64; do
        build_one "$goos_value" "$goarch_value"
      done
    done
    ;;
  current)
    build_one "${GOOS:-$(go env GOOS)}" "${GOARCH:-$(go env GOARCH)}"
    ;;
  *)
    echo "usage: bash scripts/binary.sh [all]"
    exit 1
    ;;
esac

if [ "$MODE" = "all" ]; then
  echo "✅ All release binaries complete in ${DIST_DIR}/"
fi