Skip to content

Commit

Permalink
Merge pull request #404 from mozilla/Pat/update_beta_link
Browse files Browse the repository at this point in the history
Pat/update beta link
  • Loading branch information
whlpatricia authored Jan 9, 2025
2 parents db2934b + a840fdd commit 9be688c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
steps:
- name: Obtain the latest beta version number
run:
echo "LATEST=$(curl https://product-details.mozilla.org/1.0/firefox_versions.json | jq -r '.FIREFOX_DEVEDITION')" >> "$GITHUB_ENV"
pip install beautifulsoup4
echo "LATEST=$(python3 ./get_beta_version.py)" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if the latest version was tested
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ google-cloud-storage = "2.18.0"
google-auth = "2.32.0"
psutil = "<6.1"
pytest-json-report = "==1.5.0"
beautifulsoup4 = "4.12.3"

[dev-packages]
werkzeug = "==3.0.3"
Expand Down
47 changes: 41 additions & 6 deletions collect_executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from platform import uname
from sys import argv, exit
from time import sleep
from bs4 import BeautifulSoup

import requests

Expand All @@ -16,18 +17,26 @@
def get_fx_platform():
u = uname()
if u.system == "Darwin":
return "osx"
return "mac"
if u.system == "Linux":
if "64" in u.machine:
return "linux64"
return "linux"
return "linux-x86_64"
return "linux-i686"
if u.system == "Windows":
if u.machine == "AMD64" and not environ.get("GITHUB_ACTIONS"):
return "win64-aarch64"
if "64" in u.machine:
return "win64"
return "win"
return "win32"

def get_fx_executable_extension():
u = uname()
if u.system == "Darwin":
return "dmg"
if u.system == "Linux":
return "xz"
if u.system == "Windows":
return "exe"

def get_gd_platform():
u = uname()
Expand Down Expand Up @@ -82,9 +91,35 @@ def get_gd_platform():
channel = "-beta"
elif channel:
channel = f"-{channel.lower()}"

latest_beta_ver = environ.get("LATEST")
if not latest_beta_ver:
prefix = "mac" if get_gd_platform()[:3] in ("mac", "lin") else "win"
with open(f"{prefix}-latest-reported-version") as fh:
latest_beta_ver = fh.read()

language = environ.get("FX_LOCALE")
if not language:
language = "en-US"

fx_download_dir_url = f"https://archive.mozilla.org/pub/firefox/releases/{latest_beta_ver}/{get_fx_platform()}/{language}/"

# Fetch the page
response = requests.get(fx_download_dir_url)
response.raise_for_status()

# Parse the HTML content
soup = BeautifulSoup(response.text, 'html.parser')

fx_download_url = f"https://download.mozilla.org/?product=firefox{channel}-latest-ssl&os={get_fx_platform()}&lang={language}"
print(fx_download_url)
executable_name = ""
# Extract the text of each line
for line in soup.find_all('a'):
line_text = line.getText().split(".")
if not line_text[0]:
continue
# Get the executable name
if line_text[-1] == get_fx_executable_extension():
executable_name = line.getText().replace(" ", "%20")

fx_download_executable_url = rf"{fx_download_dir_url}{executable_name}"
print(fx_download_executable_url)
27 changes: 27 additions & 0 deletions get_beta_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import requests
from bs4 import BeautifulSoup

beta_url = "https://ftp.mozilla.org/pub/firefox/releases/"

# Fetch the page
response = requests.get(beta_url)
response.raise_for_status()

# Parse the HTML content
soup = BeautifulSoup(response.text, 'html.parser')

latest_beta_num = -1
latest_beta_ver = ""

# Extract the text of each line
for line in soup.find_all('a'):
line_text = line.getText().split(".")
if len(line_text) < 2 or not line_text[0]:
continue
beta_num = int(line_text[0])
# Find the latest beta version
if beta_num >= latest_beta_num:
latest_beta_num = beta_num
latest_beta_ver = line.getText()[:-1]

print(latest_beta_ver)

0 comments on commit 9be688c

Please sign in to comment.