mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-07 20:39:59 +02:00
Update README and surfer.json for Firefox RC 134.0.1; enhance update scripts
This commit is contained in:
parent
98c5f0efb7
commit
922e909a7f
5 changed files with 47 additions and 91 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
Zen is currently built using firefox version `134.0`! 🚀
|
||||
|
||||
- [`Zen Twilight`](https://zen-browser.app/download?twilight) - Is currently built using firefox version `RC 134.0.1`!
|
||||
- Check out the latest [release notes](https://zen-browser.app/release-notes)!
|
||||
- Part of our mission is to keep Zen up-to-date with the latest version of Firefox, so you can enjoy the latest features and security updates!
|
||||
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
"update-ff": "python3 scripts/update_ff.py",
|
||||
"update-ff:raw": "surfer update",
|
||||
"update-newtab": "python3 scripts/update_newtab.py",
|
||||
"update-ff:rc": "python3 scripts/update_ff.py --rc",
|
||||
"pretty": "prettier . --write && autopep8 -r --in-place scripts/ src/",
|
||||
"lint": "npx prettier . --check && autopep8 --diff scripts/ src/",
|
||||
"prepare": "husky"
|
||||
"prepare": "husky",
|
||||
"reset-ff": "surfer reset"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
from typing import Optional
|
||||
|
||||
RESPONSE_FILENAME = "rc-response.json"
|
||||
METADATA_FILENAME = "surfer.json"
|
||||
|
||||
|
||||
def get_current_version() -> Optional[str]:
|
||||
"""Retrieve the current version from the metadata file."""
|
||||
try:
|
||||
with open(METADATA_FILENAME) as f:
|
||||
metadata = json.load(f)
|
||||
return metadata["version"]["candidate"]
|
||||
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||
print(f"Error reading current version: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def get_rc_response() -> Optional[str]:
|
||||
"""Get the release candidate response from the response file."""
|
||||
try:
|
||||
with open(RESPONSE_FILENAME) as f:
|
||||
data = json.load(f)
|
||||
for tag_dict in data["tags"]:
|
||||
tag = tag_dict["tag"]
|
||||
if (tag.startswith("FIREFOX") and tag.endswith("_BUILD1")
|
||||
and "ESR" not in tag and "b" not in tag):
|
||||
return (tag.replace("FIREFOX_", "").replace("_BUILD1",
|
||||
"").replace("_", "."))
|
||||
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||
print(f"Error reading RC response: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def get_pings() -> str:
|
||||
"""Build a string of Discord user IDs for mentions."""
|
||||
ping_ids = os.getenv("DISCORD_PING_IDS", "")
|
||||
return " ".join(f"<@{ping.strip()}>" for ping in ping_ids.split(",")
|
||||
if ping.strip())
|
||||
|
||||
|
||||
def send_webhook(rc: str) -> None:
|
||||
"""Send a message to the Discord webhook."""
|
||||
text = f"||{get_pings()}|| New Firefox RC version is available: **{rc}**"
|
||||
webhook_url = os.getenv("DISCORD_WEBHOOK_URL")
|
||||
|
||||
if webhook_url:
|
||||
message = {
|
||||
"content": text,
|
||||
"username": "Firefox RC Checker",
|
||||
}
|
||||
try:
|
||||
response = requests.post(webhook_url, json=message)
|
||||
response.raise_for_status() # Raise an error for bad responses
|
||||
except requests.RequestException as e:
|
||||
print(f"Error sending webhook: {e}")
|
||||
else:
|
||||
print("Webhook URL not set.")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
current_version = get_current_version()
|
||||
rc_response = get_rc_response()
|
||||
|
||||
if rc_response and rc_response != current_version:
|
||||
send_webhook(rc_response)
|
||||
return 0
|
||||
|
||||
print(f"Current version: {current_version}, RC version: {rc_response}")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,30 +1,52 @@
|
|||
import os
|
||||
import json
|
||||
import argparse
|
||||
import shutil
|
||||
|
||||
from check_rc_response import get_rc_response, rc_should_be_updated
|
||||
|
||||
def update_rc(last_version: str):
|
||||
rc_version = get_rc_response()
|
||||
if rc_should_be_updated(rc_version, last_version):
|
||||
print(f"New Firefox RC version is available: {rc_version}")
|
||||
print("Removing engine directory and updating surfer.json.")
|
||||
if os.path.exists("engine"):
|
||||
shutil.rmtree("engine")
|
||||
with open("surfer.json", "r") as f:
|
||||
data = json.load(f)
|
||||
with open("surfer.json", "w") as f:
|
||||
data["version"]["candidate"] = rc_version
|
||||
json.dump(data, f, indent=2)
|
||||
else:
|
||||
print("No new Firefox RC version available.")
|
||||
|
||||
|
||||
def update_ff():
|
||||
def update_ff(is_rc: bool = False, last_version: str = ""):
|
||||
"""Runs the npm command to update the 'ff' component."""
|
||||
result = os.system("npm run update-ff:raw")
|
||||
if is_rc:
|
||||
return update_rc(last_version)
|
||||
result = os.system("pnpm update-ff:raw")
|
||||
if result != 0:
|
||||
raise RuntimeError("Failed to update 'ff' component.")
|
||||
|
||||
|
||||
def get_version_from_file(filename):
|
||||
def get_version_from_file(filename, is_rc):
|
||||
"""Retrieves the version from the specified JSON file."""
|
||||
try:
|
||||
with open(filename, "r") as f:
|
||||
data = json.load(f)
|
||||
return data["version"]["version"]
|
||||
return data["version"]["version"] if not is_rc else data["version"]["candidate"]
|
||||
except (FileNotFoundError, json.JSONDecodeError) as e:
|
||||
raise RuntimeError(f"Error reading version from {filename}: {e}")
|
||||
|
||||
|
||||
def update_readme(last_version, new_version):
|
||||
def update_readme(last_version, new_version, is_rc = False):
|
||||
"""Updates the README.md file to reflect the new version."""
|
||||
prefix = "RC " if is_rc else ""
|
||||
try:
|
||||
with open("README.md", "r") as f:
|
||||
data = f.read()
|
||||
updated_data = data.replace(last_version, new_version)
|
||||
updated_data = data.replace(prefix + last_version, prefix + new_version)
|
||||
|
||||
with open("README.md", "w") as f:
|
||||
f.write(updated_data)
|
||||
|
@ -34,11 +56,17 @@ def update_readme(last_version, new_version):
|
|||
|
||||
def main():
|
||||
"""Main function to update versions and README."""
|
||||
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument(
|
||||
"--rc", help="Indicates that this is a release candidate.", default=False, action="store_true")
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
try:
|
||||
last_version = get_version_from_file("surfer.json")
|
||||
update_ff()
|
||||
new_version = get_version_from_file("surfer.json")
|
||||
update_readme(last_version, new_version)
|
||||
last_version = get_version_from_file("surfer.json", args.rc)
|
||||
update_ff(args.rc, last_version)
|
||||
new_version = get_version_from_file("surfer.json", args.rc)
|
||||
update_readme(last_version, new_version, args.rc)
|
||||
print(
|
||||
f"Updated version from {last_version} to {new_version} in README.md.")
|
||||
except Exception as e:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"version": {
|
||||
"product": "firefox",
|
||||
"version": "134.0",
|
||||
"candidate": "134.0"
|
||||
"candidate": "134.0.1"
|
||||
},
|
||||
"buildOptions": {
|
||||
"generateBranding": true
|
||||
|
@ -47,8 +47,10 @@
|
|||
}
|
||||
},
|
||||
"license": {
|
||||
"ignoredFiles": [".*\\.json"],
|
||||
"ignoredFiles": [
|
||||
".*\\.json"
|
||||
],
|
||||
"licenseType": "MPL-2.0"
|
||||
},
|
||||
"updateHostname": "updates.zen-browser.app"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue