Add lookup for Mach nominated versions

This commit is contained in:
mlugg
2024-06-08 16:58:58 +01:00
parent 1cc5703fe8
commit 77c12e15e1
2 changed files with 12 additions and 1 deletions
+4 -1
View File
@@ -19,7 +19,8 @@ This will automatically download Zig and install it to `PATH`.
You can use `version` to set a Zig version to download. This may be a release (`0.13.0`), a specific nightly
build (`0.14.0-dev.2+0884a4341`), the string `master` for the latest nightly build, or the string `latest`
for the latest full release. The default is `latest`.
for the latest full release. It can also refer to a [Mach nominated version][mach-nominated], such as
`2024.5.0-mach`. The default is `latest`.
```yaml
- uses: mlugg/setup-zig@v1
@@ -44,6 +45,8 @@ be https://ziglang.org/download to avoid the oggicial websote being hit with lar
If you've experienced issues with a default mirror, please open an issue, and I will communicate with the
mirror's owner or remove it from the list.
[mach-nominated]: https://machengine.org/about/nominated-zig/
## Details
This action attempts to download the requested Zig tarball from a set of mirrors, in a random order. As
+8
View File
@@ -5,6 +5,7 @@ const github = require('@actions/github');
const exec = require('@actions/exec');
const VERSIONS_JSON = 'https://ziglang.org/download/index.json';
const MACH_VERSIONS_JSON = 'https://pkg.machengine.org/zig/index.json';
const CACHE_PREFIX = "setup-zig-global-cache-";
let _cached_version = null;
@@ -49,6 +50,13 @@ async function getVersion() {
}
}
_cached_version = latest;
} else if (raw.includes("mach")) {
const resp = await fetch(MACH_VERSIONS_JSON);
const versions = await resp.json();
if (!(raw in versions)) {
throw new Error(`Mach nominated version '${raw}' not found`);
}
_cached_version = versions[raw].version;
} else {
_cached_version = raw;
}