-
-
Save teddywing/69c79df8dd03acff936df23b51c4050c to your computer and use it in GitHub Desktop.
Download the latest unbranded release build from the Firefox Nightly channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# download-nightly2 | |
# Download the latest release build of Firefox Nightly for Mac OS. | |
# | |
# Ported from KwanEsq's JavaScript user script: | |
# https://gist.github.com/KwanEsq/0959333d8c8781f6582fe3988af4d483 | |
macos_type_name='build-macosx64-add-on-devel%2Fopt' | |
fetch_latest_firefox_version() { | |
curl \ | |
--silent \ | |
--location 'https://product-details.mozilla.org/1.0/firefox_versions.json' \ | |
| jq --raw-output '.LATEST_FIREFOX_VERSION' | |
} | |
fetch_rev_for_firefox_version() { | |
local firefox_version="$1" | |
curl \ | |
--silent \ | |
--location "https://hg.mozilla.org/releases/mozilla-release/json-log?rev=FIREFOX_${firefox_version}_RELEASE" \ | |
| jq --raw-output '.node' | |
} | |
fetch_job_id_for_rev() { | |
local firefox_version="$1" | |
curl \ | |
--silent \ | |
--location "https://treeherder.mozilla.org/api/project/mozilla-release/push/?revision=$(fetch_rev_for_firefox_version "$firefox_version")" \ | |
| jq --raw-output '.results[0].id' | |
} | |
fetch_task_id_and_retry_id_for_job_id() { | |
local firefox_version="$1" | |
local job_results="$( | |
curl \ | |
--silent \ | |
--location "https://treeherder.mozilla.org/api/project/mozilla-release/jobs/?result_set_id=$(fetch_job_id_for_rev "$firefox_version")&job_type_name=${macos_type_name}" | |
)" | |
echo "$job_results" | | |
jq --raw-output '.results | |
| .[] | |
| select(.result == "success") | |
| [.task_id, .retry_id] | |
| @tsv' | |
} | |
fetch_artifact_url_of_task_id() { | |
local firefox_version="$1" | |
local task_id_retry_id="$(fetch_task_id_and_retry_id_for_job_id "$firefox_version")" | |
local task_id="$(echo "$task_id_retry_id" | cut -f1)" | |
local retry_id="$(echo "$task_id_retry_id" | cut -f2)" | |
local artifact_url_prefix="https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/${task_id}/runs/${retry_id}/artifacts" | |
local artifact_path="$( | |
curl \ | |
--silent \ | |
--location "$artifact_url_prefix" \ | |
| jq --raw-output '.artifacts | |
| .[] | |
| select(.name | endswith("target.dmg")) | |
| .name' | |
)" | |
echo "$artifact_url_prefix/$artifact_path" | |
} | |
fetch_archive() { | |
local firefox_version="$1" | |
curl \ | |
--output "Firefox Nightly ${firefox_version}.dmg" \ | |
--location "$(fetch_artifact_url_of_task_id "$firefox_version")" | |
} | |
main() { | |
firefox_version="$(fetch_latest_firefox_version)" | |
fetch_archive "$firefox_version" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment