#!/usr/bin/env bash # release-firefox-xpi.sh # Builds a signed Firefox XPI, copies it to release/firefox/ with a clean name, # and generates updates.json for self-distributed updates. # Run from repo root. set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT_DIR" if [[ -f ".env" ]]; then set -a source ".env" set +a fi SOURCE_DIR="${WEB_EXT_SOURCE_DIR:-extension-firefox}" ARTIFACTS_DIR="${WEB_EXT_ARTIFACTS_DIR:-web-ext-artifacts}" RELEASE_DIR="release/firefox" UPDATE_BASE_URL="${VERSTAK_FIREFOX_UPDATE_BASE_URL:-https://mirv.top/verstak/firefox}" # Step 1: sign the XPI ./scripts/sign-firefox-xpi.sh # Step 2: read version and addon ID from manifest if [[ ! -f "$SOURCE_DIR/manifest.json" ]]; then echo "ERROR: $SOURCE_DIR/manifest.json not found" >&2 exit 1 fi VERSION="$(node -e "console.log(require('./${SOURCE_DIR}/manifest.json').version)")" if [[ -z "$VERSION" ]]; then echo "ERROR: could not read version from $SOURCE_DIR/manifest.json" >&2 exit 1 fi ADDON_ID="$(node -e "console.log(require('./${SOURCE_DIR}/manifest.json').browser_specific_settings.gecko.id)")" if [[ -z "$ADDON_ID" ]]; then echo "ERROR: could not read browser_specific_settings.gecko.id from $SOURCE_DIR/manifest.json" >&2 exit 1 fi echo "Extension version: $VERSION" echo "Addon ID: $ADDON_ID" # Step 3: locate the signed XPI SIGNED_XPI="$(find "$ARTIFACTS_DIR" -maxdepth 1 -type f -name '*.xpi' | sort | tail -n 1)" if [[ -z "$SIGNED_XPI" ]]; then echo "ERROR: no signed XPI found in $ARTIFACTS_DIR" >&2 exit 1 fi # Step 4: copy to release directory mkdir -p "$RELEASE_DIR" RELEASE_XPI="verstak-firefox-${VERSION}.xpi" cp "$SIGNED_XPI" "$RELEASE_DIR/$RELEASE_XPI" echo "Copied signed XPI to $RELEASE_DIR/$RELEASE_XPI" # Step 5: generate updates.json cat > "$RELEASE_DIR/updates.json" <