fix: sign script retries with incremented patch on version conflict

No timestamp metadata in versions. Uses simple incrementing patch
numbers (0.3.3, 0.3.4, etc.). If Mozilla rejects the version as
already existing, auto-increments and retries up to 10 times.

https://claude.ai/code/session_01Dvgwe7XMoSxnWXkih8p1Cw
This commit is contained in:
Claude
2026-03-26 04:26:25 +00:00
parent 3a9343cab8
commit b89333076f
+35 -19
View File
@@ -20,12 +20,12 @@ if [ ! -f "$ENV_FILE" ]; then
exit 1
fi
# --- Auto-bump version — always unique ---
# Format: MAJOR.YMMDD.HHMM (e.g., 1.60326.1542)
# Each part stays under 65535, guaranteed unique per minute
MAJOR=1
MINOR=$(date +%-m%d) # e.g., 326 for March 26, 1225 for Dec 25
PATCH=$(date +%-H%M) # e.g., 1542 for 3:42 PM
# --- Auto-bump version — always unique, no metadata ---
# Reads current version, increments patch. If already signed,
# keeps incrementing until it works.
CURRENT_VERSION=$(grep -o '"version": "[^"]*"' "$MANIFEST" | head -1 | grep -o '[0-9.]*')
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "Version: $CURRENT_VERSION$NEW_VERSION"
@@ -88,17 +88,33 @@ echo ""
echo "Building Firefox extension..."
"$SCRIPT_DIR/build.sh" firefox
# Sign
echo "Signing v$NEW_VERSION with Mozilla..."
npx web-ext sign \
--no-config-discovery \
--source-dir "$SCRIPT_DIR/dist/firefox" \
--artifacts-dir "$SCRIPT_DIR/dist/firefox-signed" \
--channel unlisted \
--api-key "$API_KEY" \
--api-secret "$API_SECRET"
# Sign — retry with incremented patch if version conflict
MAX_ATTEMPTS=10
for attempt in $(seq 1 $MAX_ATTEMPTS); do
echo "Signing v$NEW_VERSION with Mozilla (attempt $attempt)..."
echo ""
echo "Done! v$NEW_VERSION signed."
echo "Install the .xpi file from dist/firefox-signed/"
echo "Drag it into Firefox or use File → Open File."
if npx web-ext sign \
--no-config-discovery \
--source-dir "$SCRIPT_DIR/dist/firefox" \
--artifacts-dir "$SCRIPT_DIR/dist/firefox-signed" \
--channel unlisted \
--api-key "$API_KEY" \
--api-secret "$API_SECRET" 2>&1; then
echo ""
echo "Done! v$NEW_VERSION signed."
echo "Install the .xpi file from dist/firefox-signed/"
echo "Drag it into Firefox or use File → Open File."
exit 0
fi
# If it failed due to version conflict, bump and rebuild
echo "Version $NEW_VERSION already exists, trying next..."
PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$NEW_VERSION\"/" "$SCRIPT_DIR/dist/firefox/manifest.json"
done
echo "Error: Failed after $MAX_ATTEMPTS attempts."
exit 1