build: упаковка расширений в scripts/build.sh

- build.sh: новые команды extensions, chrome, firefox
- Chrome: build/verstak-bridge-chrome.zip
- Firefox: build/verstak-bridge-firefox.xpi
- Архивы содержат только нужные файлы (manifest, background, popup)
- Исключены .DS_Store, Thumbs.db, __MACOSX, .git
This commit is contained in:
mirivlad 2026-06-06 19:15:24 +08:00
parent c5505ee43c
commit f6c61c32e3
1 changed files with 93 additions and 12 deletions

View File

@ -1,7 +1,14 @@
#!/bin/bash #!/bin/bash
set -e set -e
# Individual build scripts # ============================================================
# Verstak build script
# Usage: ./scripts/build.sh [gui|server|extensions|all]
# ============================================================
BUILD_DIR="build"
# --- GUI binary ---
build_gui() { build_gui() {
echo "==> Building GUI binary..." echo "==> Building GUI binary..."
@ -16,31 +23,105 @@ build_gui() {
# Build Go binary with Wails v2 # Build Go binary with Wails v2
# Tags: webkit2_41 required for WebKitGTK 2.41+, desktop/production for Wails # Tags: webkit2_41 required for WebKitGTK 2.41+, desktop/production for Wails
go build -tags "webkit2_41 desktop production" -ldflags="-s -w" -o build/verstak-gui-linux-amd64 ./cmd/verstak-gui/ go build -tags "webkit2_41 desktop production" -ldflags="-s -w" -o "$BUILD_DIR/verstak-gui-linux-amd64" ./cmd/verstak-gui/
echo "==> GUI binary: build/verstak-gui-linux-amd64" echo "==> GUI binary: $BUILD_DIR/verstak-gui-linux-amd64"
} }
# --- Server binary ---
build_server() { build_server() {
echo "==> Building server binary..." echo "==> Building server binary..."
go build -ldflags="-s -w" -o build/verstak-server-linux-amd64 ./cmd/verstak-server/ go build -ldflags="-s -w" -o "$BUILD_DIR/verstak-server-linux-amd64" ./cmd/verstak-server/
echo "==> Server binary: build/verstak-server-linux-amd64" echo "==> Server binary: $BUILD_DIR/verstak-server-linux-amd64"
} }
# --- Chrome extension ---
build_chrome_extension() {
echo "==> Building Chrome extension..."
local ext_dir="extension"
local out_file="$BUILD_DIR/verstak-bridge-chrome.zip"
if [ ! -d "$ext_dir" ]; then
echo "ERROR: $ext_dir/ directory not found"
return 1
fi
# Create a clean zip: manifest.json, background.js, popup/*
# Exclude any hidden files, icons (not needed for dev install), and OS junk
cd "$ext_dir"
zip -r "../$out_file" \
manifest.json \
background.js \
popup/ \
-x "*/.DS_Store" "*/Thumbs.db" "*/__MACOSX/*" "*/.git/*"
cd ..
echo "==> Chrome extension: $out_file"
}
# --- Firefox extension ---
build_firefox_extension() {
echo "==> Building Firefox extension..."
local ext_dir="extension-firefox"
local out_file="$BUILD_DIR/verstak-bridge-firefox.xpi"
if [ ! -d "$ext_dir" ]; then
echo "ERROR: $ext_dir/ directory not found"
return 1
fi
# Firefox xpi is a zip with .xpi extension
# Must include manifest.json at root
cd "$ext_dir"
zip -r "../$out_file" \
manifest.json \
background.js \
popup/ \
-x "*/.DS_Store" "*/Thumbs.db" "*/__MACOSX/*" "*/.git/*"
cd ..
echo "==> Firefox extension: $out_file"
}
# --- All extensions ---
build_extensions() {
mkdir -p "$BUILD_DIR"
build_chrome_extension
build_firefox_extension
echo "==> Extensions built."
ls -lh "$BUILD_DIR"/verstak-bridge-*
}
# --- Everything ---
build_all() { build_all() {
mkdir -p build mkdir -p "$BUILD_DIR"
build_gui build_gui
build_server build_server
echo "==> All binaries built." build_chrome_extension
ls -lh build/ build_firefox_extension
echo ""
echo "==> All builds complete."
ls -lh "$BUILD_DIR/"
} }
# --- Main ---
case "${1:-all}" in case "${1:-all}" in
gui) build_gui ;; gui) build_gui ;;
server) build_server ;; server) build_server ;;
all) build_all ;; extensions) build_extensions ;;
chrome) mkdir -p "$BUILD_DIR"; build_chrome_extension ;;
firefox) mkdir -p "$BUILD_DIR"; build_firefox_extension ;;
all) build_all ;;
*) *)
echo "Usage: $0 [gui|server|all]" echo "Usage: $0 [gui|server|extensions|chrome|firefox|all]"
exit 1 exit 1
;; ;;
esac esac