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:
+35
-19
@@ -20,12 +20,12 @@ if [ ! -f "$ENV_FILE" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Auto-bump version — always unique ---
|
# --- Auto-bump version — always unique, no metadata ---
|
||||||
# Format: MAJOR.YMMDD.HHMM (e.g., 1.60326.1542)
|
# Reads current version, increments patch. If already signed,
|
||||||
# Each part stays under 65535, guaranteed unique per minute
|
# keeps incrementing until it works.
|
||||||
MAJOR=1
|
CURRENT_VERSION=$(grep -o '"version": "[^"]*"' "$MANIFEST" | head -1 | grep -o '[0-9.]*')
|
||||||
MINOR=$(date +%-m%d) # e.g., 326 for March 26, 1225 for Dec 25
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
|
||||||
PATCH=$(date +%-H%M) # e.g., 1542 for 3:42 PM
|
PATCH=$((PATCH + 1))
|
||||||
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
|
||||||
|
|
||||||
echo "Version: $CURRENT_VERSION → $NEW_VERSION"
|
echo "Version: $CURRENT_VERSION → $NEW_VERSION"
|
||||||
@@ -88,17 +88,33 @@ echo ""
|
|||||||
echo "Building Firefox extension..."
|
echo "Building Firefox extension..."
|
||||||
"$SCRIPT_DIR/build.sh" firefox
|
"$SCRIPT_DIR/build.sh" firefox
|
||||||
|
|
||||||
# Sign
|
# Sign — retry with incremented patch if version conflict
|
||||||
echo "Signing v$NEW_VERSION with Mozilla..."
|
MAX_ATTEMPTS=10
|
||||||
npx web-ext sign \
|
for attempt in $(seq 1 $MAX_ATTEMPTS); do
|
||||||
--no-config-discovery \
|
echo "Signing v$NEW_VERSION with Mozilla (attempt $attempt)..."
|
||||||
--source-dir "$SCRIPT_DIR/dist/firefox" \
|
|
||||||
--artifacts-dir "$SCRIPT_DIR/dist/firefox-signed" \
|
|
||||||
--channel unlisted \
|
|
||||||
--api-key "$API_KEY" \
|
|
||||||
--api-secret "$API_SECRET"
|
|
||||||
|
|
||||||
echo ""
|
if npx web-ext sign \
|
||||||
echo "Done! v$NEW_VERSION signed."
|
--no-config-discovery \
|
||||||
echo "Install the .xpi file from dist/firefox-signed/"
|
--source-dir "$SCRIPT_DIR/dist/firefox" \
|
||||||
echo "Drag it into Firefox or use File → Open File."
|
--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
|
||||||
|
|||||||
Reference in New Issue
Block a user