version bump but still broken

This commit is contained in:
Josh Patra
2025-07-03 15:02:38 -04:00
parent b2ed0fcb41
commit 703658335c
2 changed files with 30 additions and 24 deletions

View File

@@ -11,14 +11,11 @@ TARGET_FILE = "manifest.json"
def zip_folder(output_name, folder, exclude_files, exclude_dirs): def zip_folder(output_name, folder, exclude_files, exclude_dirs):
with zipfile.ZipFile(output_name, "w", zipfile.ZIP_DEFLATED) as zipf: with zipfile.ZipFile(output_name, "w", zipfile.ZIP_DEFLATED) as zipf:
for root, dirs, files in os.walk(folder): for root, dirs, files in os.walk(folder):
# Exclude specified directories
dirs[:] = [ dirs[:] = [
d d
for d in dirs for d in dirs
if os.path.join(root, d).replace(folder + os.sep, "") if os.path.relpath(os.path.join(root, d), folder) not in exclude_dirs
not in exclude_dirs
] ]
for file in files: for file in files:
rel_path = os.path.relpath(os.path.join(root, file), folder) rel_path = os.path.relpath(os.path.join(root, file), folder)
if ( if (
@@ -30,13 +27,11 @@ def zip_folder(output_name, folder, exclude_files, exclude_dirs):
zipf.write(os.path.join(root, file), arcname=rel_path) zipf.write(os.path.join(root, file), arcname=rel_path)
def update_version_line(file_path, new_base_version): def update_version_line(file_path, new_version):
with open(file_path, "r", encoding="utf-8") as f: with open(file_path, "r", encoding="utf-8") as f:
lines = f.readlines() lines = f.readlines()
new_version = f"{new_base_version}.0"
updated = False updated = False
for i, line in enumerate(lines): for i, line in enumerate(lines):
match = re.match(r'\s*"version":\s*"([^"]+)"', line) match = re.match(r'\s*"version":\s*"([^"]+)"', line)
if match: if match:
@@ -45,52 +40,63 @@ def update_version_line(file_path, new_base_version):
r'"version":\s*".+?"', f'"version": "{new_version}"', line r'"version":\s*".+?"', f'"version": "{new_version}"', line
) )
updated = True updated = True
print(f"🛠️ Changed version from {old_version}{new_version}") print(
f"🛠️ Changed version in {file_path} from {old_version}{new_version}"
)
break break
if updated: if updated:
with open(file_path, "w", encoding="utf-8") as f: with open(file_path, "w", encoding="utf-8") as f:
f.writelines(lines) f.writelines(lines)
else: else:
print("⚠️ No version line found to update.") print(f"⚠️ No version line found in {file_path}.")
def main(): def main():
base_version = input("Enter the new base version (e.g., 1.2.2): ").strip() base_version = input("Enter the new base version (e.g., 2.0.1): ").strip()
if not base_version: if not base_version:
print("❌ No version entered. Exiting.") print("❌ No version entered. Exiting.")
return return
firefox_version = f"{base_version}.0"
current_dir = os.getcwd() current_dir = os.getcwd()
manifest_path = os.path.join(current_dir, TARGET_FILE)
# Determine what to exclude
exclude_files = [SCRIPT_NAME] + [ exclude_files = [SCRIPT_NAME] + [
f for f in os.listdir(current_dir) if f.endswith(".xpi") f for f in os.listdir(current_dir) if f.endswith(".xpi")
] ]
exclude_dirs = [".git"] exclude_dirs = [".git"]
# 1. Create videospeed-github.xpi # Step 1: Update manifest.json on disk
if os.path.exists(manifest_path):
update_version_line(manifest_path, base_version)
else:
print(f"{TARGET_FILE} not found. Aborting.")
return
# Step 2: Create GitHub .xpi archive
zip_folder("videospeed-github.xpi", current_dir, exclude_files, exclude_dirs) zip_folder("videospeed-github.xpi", current_dir, exclude_files, exclude_dirs)
print("✅ Created videospeed-github.xpi") print("✅ Created videospeed-github.xpi")
# 2. Prepare temporary folder # Step 3: Prepare Firefox archive with version bumped to .0
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
for item in os.listdir(current_dir): for item in os.listdir(current_dir):
if item in exclude_files or item in exclude_dirs: if item in exclude_files or item in exclude_dirs:
continue continue
s = os.path.join(current_dir, item) src = os.path.join(current_dir, item)
d = os.path.join(temp_dir, item) dst = os.path.join(temp_dir, item)
if os.path.isdir(s): if os.path.isdir(src):
shutil.copytree(s, d) shutil.copytree(src, dst)
else: else:
shutil.copy2(s, d) shutil.copy2(src, dst)
# 3. Modify manifest.json version temp_manifest = os.path.join(temp_dir, TARGET_FILE)
manifest_path = os.path.join(temp_dir, TARGET_FILE) if os.path.exists(temp_manifest):
if os.path.exists(manifest_path): update_version_line(temp_manifest, firefox_version)
update_version_line(manifest_path, base_version)
else: else:
print(f"⚠️ {TARGET_FILE} not found in copied files.") print(f"⚠️ {TARGET_FILE} not found in temp folder.")
# 4. Zip modified files
zip_folder( zip_folder(
"videospeed-firefox.xpi", temp_dir, exclude_files=[], exclude_dirs=[] "videospeed-firefox.xpi", temp_dir, exclude_files=[], exclude_dirs=[]
) )

View File

@@ -1,7 +1,7 @@
{ {
"name": "Video Speed Controller", "name": "Video Speed Controller",
"short_name": "videospeed", "short_name": "videospeed",
"version": "1.2.2", "version": "1.3.0",
"manifest_version": 2, "manifest_version": 2,
"description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts", "description": "Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts",
"homepage_url": "https://github.com/SoPat712/videospeed", "homepage_url": "https://github.com/SoPat712/videospeed",