Files
navi/scripts/build-macos-arm64.sh
T
M4andCursor 2ad376b49e
ci / test (macos-latest) (push) Waiting to run
ci / test (ubuntu-latest) (push) Waiting to run
ci / test (windows-latest) (push) Waiting to run
Release 3.8.2.5: cheaper idle UI poll and tighter hot paths.
Delta getState by rev, pause when hidden, cancellable background loops,
hostCache bounds, unlock PollUI around engine status, corebin singleflight,
PingAll worker pool.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-01 16:13:59 +03:00

134 lines
4.8 KiB
Bash
Executable File

#!/bin/bash
# Build Navis GUI for Apple Silicon (arm64).
set -euo pipefail
cd "$(dirname "$0")/.."
# Prefer local toolchain if present.
export PATH="$(pwd)/.tools/go/bin:/tmp/go-sdk/go/bin:/usr/local/go/bin:$PATH"
python3 scripts/bump-build.py
VERSION="$(python3 - <<'PY'
import re
from pathlib import Path
t = Path('internal/update/update.go').read_text()
m = re.search(r'CurrentVersion\s*=\s*"([^"]+)"', t)
print(m.group(1) if m else '0.0.0')
PY
)"
BUILD="$(python3 - <<'PY'
import re
from pathlib import Path
t = Path('internal/update/update.go').read_text()
m = re.search(r'const BuildNumber\s*=\s*(\d+)', t)
print(m.group(1) if m else '0')
PY
)"
FULL="${VERSION}.${BUILD}"
echo "Building Navis ${VERSION}+${BUILD} (arm64)..."
OUT="dist/navis-release/darwin-arm64"
mkdir -p "$OUT"
LDFLAGS="-s -w"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \
go build -ldflags="$LDFLAGS" -trimpath -o "$OUT/Navis" ./cmd/vpnapp
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \
go build -ldflags="$LDFLAGS" -trimpath -o "$OUT/Navis-cli" ./cmd/vpnclient
printf '%s\n' "$FULL" > "$OUT/VERSION"
printf '%s\n' "${VERSION}+${BUILD}" > "$OUT/Navis.version"
# Ad-hoc sign CLI/bin; packmac also signs the .app (honors NAVIS_CODESIGN_IDENTITY).
# Set REQUIRE_CODESIGN=1 for release builds (fails without a real Developer ID identity).
if [[ "${REQUIRE_CODESIGN:-}" == "1" ]]; then
if [[ -z "${NAVIS_CODESIGN_IDENTITY:-}" || "${NAVIS_CODESIGN_IDENTITY}" == "-" ]]; then
echo "REQUIRE_CODESIGN=1 requires NAVIS_CODESIGN_IDENTITY (Developer ID Application: …)" >&2
exit 1
fi
fi
if command -v codesign >/dev/null 2>&1; then
if [[ -n "${NAVIS_CODESIGN_IDENTITY:-}" && "${NAVIS_CODESIGN_IDENTITY}" != "-" ]]; then
ID="$NAVIS_CODESIGN_IDENTITY"
codesign -s "$ID" --force --options runtime --timestamp "$OUT/Navis"
codesign -s "$ID" --force --options runtime --timestamp "$OUT/Navis-cli"
else
codesign -s - --force "$OUT/Navis" || true
codesign -s - --force "$OUT/Navis-cli" || true
fi
fi
go run ./tools/packmac -bin "$OUT/Navis" -out "$OUT" -version "$VERSION" -build "$FULL" -arch arm64
cp -f "$OUT/Navis.dmg" "$OUT/Navis-${FULL}-arm64.dmg"
cp -f "$OUT/Navis.app.zip" "$OUT/Navis-${FULL}-arm64.app.zip"
python3 - <<PY
import hashlib, json
from pathlib import Path
ver = "${VERSION}"
build = "${BUILD}"
full = "${FULL}"
out = Path('dist/navis-release/darwin-arm64')
binp = out / 'Navis'
zipp = out / 'Navis.app.zip'
dmgp = out / 'Navis.dmg'
h = hashlib.sha256(binp.read_bytes()).hexdigest()
zh = hashlib.sha256(zipp.read_bytes()).hexdigest() if zipp.exists() else ""
dh = hashlib.sha256(dmgp.read_bytes()).hexdigest() if dmgp.exists() else ""
notes = (
f"Navis {ver}+{build}: delta-poll UI (getState по rev); пауза опроса при скрытом окне; "
f"cancel lifecycle dock/watchdog; invalidate/лимит hostCache; "
f"PollUI без lock на Engine.Running; singleflight corebin; PingAll worker-pool."
)
paths = [
Path('dist/update.json'),
Path('dist/navis-release/update.json'),
Path('server/update.json'),
]
for p in paths:
if not p.exists():
continue
d = json.loads(p.read_text())
d['version'] = ver
d['notes'] = notes
plats = d.setdefault('platforms', {})
if 'darwin-arm64' in plats:
plats['darwin-arm64']['sha256'] = h
if zh:
plats['darwin-arm64']['zip_sha256'] = zh
if dh:
plats['darwin-arm64']['dmg_sha256'] = dh
plats['darwin-arm64'].setdefault(
'zip_url',
'https://git.evilfox.cc/test2/navi/raw/branch/main/dist/navis-release/darwin-arm64/Navis.app.zip',
)
plats['darwin-arm64'].setdefault(
'dmg_url',
'https://git.evilfox.cc/test2/navi/raw/branch/main/dist/navis-release/darwin-arm64/Navis.dmg',
)
# Refresh checksums for any other darwin trees present on disk (amd64/universal).
base = 'https://git.evilfox.cc/test2/navi/raw/branch/main/dist/navis-release'
for key in ('darwin-amd64', 'darwin-universal'):
if key not in plats:
continue
plat_dir = Path('dist/navis-release') / key
bin2 = plat_dir / 'Navis'
zip2 = plat_dir / 'Navis.app.zip'
dmg2 = plat_dir / 'Navis.dmg'
if bin2.exists():
plats[key]['sha256'] = hashlib.sha256(bin2.read_bytes()).hexdigest()
if zip2.exists():
plats[key]['zip_sha256'] = hashlib.sha256(zip2.read_bytes()).hexdigest()
plats[key].setdefault('zip_url', f'{base}/{key}/Navis.app.zip')
if dmg2.exists():
plats[key]['dmg_sha256'] = hashlib.sha256(dmg2.read_bytes()).hexdigest()
plats[key].setdefault('dmg_url', f'{base}/{key}/Navis.dmg')
p.write_text(json.dumps(d, ensure_ascii=False, indent=2) + '\n')
print('updated', p, '->', ver, 'bin', h[:12], 'zip', zh[:12] if zh else '-')
PY
echo ""
echo "Done: Navis ${VERSION}+${BUILD}"
ls -lh "$OUT"