Files
navi/scripts/build-macos-arm64.sh
T
M4andCursor 6b6c13c933 Release 3.8.1.1: lighter idle UI poll, core cache, multicore ping.
Reduce idle CPU (cheap PollUI, binary cache, logbuf cap, DOM fingerprint),
speed ping/AWG HostPort, CopyBuffer pool; ship arm64 build and update notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 02:27:17 +03:00

105 lines
3.5 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/sync-version.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).
if command -v codesign >/dev/null 2>&1; then
ID="${NAVIS_CODESIGN_IDENTITY:--}"
codesign -s "$ID" --force "$OUT/Navis" || codesign -s - --force "$OUT/Navis"
codesign -s "$ID" --force "$OUT/Navis-cli" || codesign -s - --force "$OUT/Navis-cli"
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}: меньше нагрузки в простое (лёгкий опрос UI, кэш ядер, "
f"список серверов не мигает); быстрее пинг; стабильнее логи и AWG-прокси; "
f"параллельная работа на нескольких ядрах CPU."
)
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',
)
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"