Skip to content

Commit 475c97b

Browse files
committed
main: fix canonical URL
1 parent df54020 commit 475c97b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const minisign = require('./minisign');
1111
const MINISIGN_KEY = 'RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U';
1212

1313
// The base URL of the official builds of Zig. This is only used as a fallback, if all mirrors fail.
14-
const CANONICAL = 'https://ziglang.org/builds';
14+
const CANONICAL_DEV = 'https://ziglang.org/builds';
15+
const CANONICAL_RELEASE = 'https://ziglang.org/download';
1516

1617
// The URL of the mirror list. This should be an ASCII-encoded text file, with one mirror per LF-separated line.
1718
const MIRRORS_URL = 'https://ziglang.org/download/community-mirrors.txt';
@@ -74,8 +75,12 @@ async function downloadTarball(tarball_filename) {
7475
// continue loop to next mirror
7576
}
7677
}
77-
core.info(`Attempting official: ${CANONICAL}`);
78-
return await downloadFromMirror(CANONICAL, tarball_filename);
78+
79+
// As a fallback, attempt ziglang.org.
80+
const zig_version = tarball_filename.match(/\d+\.\d+\.\d+(-dev\.\d+\+[0-9a-f]+)?/)[0];
81+
const canonical = zig_version.includes("-dev") ? CANONICAL_DEV : `${CANONICAL_RELEASE}/${zig_version}`;
82+
core.info(`Attempting official: ${canonical}`);
83+
return await downloadFromMirror(canonical, tarball_filename);
7984
}
8085

8186
async function retrieveTarball(tarball_name, tarball_ext) {

0 commit comments

Comments
 (0)