keep releases listing dynamically updated

This commit is contained in:
Daniel Micay 2021-02-08 04:19:29 -05:00
parent 07326f706b
commit 7b0fda4129
2 changed files with 36 additions and 26 deletions

View File

@ -4,41 +4,51 @@ const baseUrl = "https://releases.grapheneos.org/";
const versionBaseUrl = "https://github.com/GrapheneOS/platform_manifest/releases/tag/";
const devices = ["redfin", "bramble", "sunfish", "coral", "flame", "bonito", "sargo", "crosshatch", "blueline", "taimen", "walleye"];
const channels = ["stable", "beta"];
const delayMs = 1000 * 60 * 5;
for (const channel of channels) {
for (const device of devices) {
fetch(baseUrl + device + "-" + channel).then(response => {
if (!response.ok) {
return Promise.reject();
}
return response.text();
}).then(text => {
const metadata = text.trim().split(" ");
async function updateReleases() {
const requests = [];
const factoryFilename = device + "-factory-" + metadata[0] + ".zip";
const factoryUrl = baseUrl + factoryFilename;
for (const channel of channels) {
for (const device of devices) {
requests.push(fetch(baseUrl + device + "-" + channel).then(response => {
if (!response.ok) {
return Promise.reject();
}
return response.text();
}).then(text => {
const metadata = text.trim().split(" ");
const updateFilename = device + "-ota_update-" + metadata[0] + ".zip";
const updateUrl = baseUrl + updateFilename;
const factoryFilename = device + "-factory-" + metadata[0] + ".zip";
const factoryUrl = baseUrl + factoryFilename;
const tag = metadata[2] + "." + metadata[0];
const updateFilename = device + "-ota_update-" + metadata[0] + ".zip";
const updateUrl = baseUrl + updateFilename;
const release = document.getElementById(device + "-" + channel);
const links = release.getElementsByTagName("a");
const tag = metadata[2] + "." + metadata[0];
links[1].innerText = tag;
links[1].setAttribute("href", versionBaseUrl + tag);
const release = document.getElementById(device + "-" + channel);
const links = release.getElementsByTagName("a");
links[2].innerText = factoryFilename;
links[2].setAttribute("href", factoryUrl);
links[1].innerText = tag;
links[1].setAttribute("href", versionBaseUrl + tag);
links[3].innerText = factoryFilename + ".sig";
links[3].setAttribute("href", factoryUrl + ".sig");
links[2].innerText = factoryFilename;
links[2].setAttribute("href", factoryUrl);
links[4].innerText = updateFilename;
links[4].setAttribute("href", updateUrl);
});
links[3].innerText = factoryFilename + ".sig";
links[3].setAttribute("href", factoryUrl + ".sig");
links[4].innerText = updateFilename;
links[4].setAttribute("href", updateUrl);
}));
}
}
await Promise.allSettled(requests);
setTimeout(updateReleases, delayMs);
}
updateReleases();
// @license-end

View File

@ -27,7 +27,7 @@
<link rel="stylesheet" href="/grapheneos.css?29"/>
<link rel="manifest" href="/manifest.webmanifest"/>
<link rel="license" href="/LICENSE.txt"/>
<script type="module" src="/js/releases.js?13"></script>
<script type="module" src="/js/releases.js?14"></script>
<script type="module" src="/js/redirect.js?9"></script>
</head>
<body>