Skip to content

Commit 77c12e1

Browse files
committed
Add lookup for Mach nominated versions
1 parent 1cc5703 commit 77c12e1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ This will automatically download Zig and install it to `PATH`.
1919

2020
You can use `version` to set a Zig version to download. This may be a release (`0.13.0`), a specific nightly
2121
build (`0.14.0-dev.2+0884a4341`), the string `master` for the latest nightly build, or the string `latest`
22-
for the latest full release. The default is `latest`.
22+
for the latest full release. It can also refer to a [Mach nominated version][mach-nominated], such as
23+
`2024.5.0-mach`. The default is `latest`.
2324

2425
```yaml
2526
- uses: mlugg/setup-zig@v1
@@ -44,6 +45,8 @@ be https://ziglang.org/download to avoid the oggicial websote being hit with lar
4445
If you've experienced issues with a default mirror, please open an issue, and I will communicate with the
4546
mirror's owner or remove it from the list.
4647

48+
[mach-nominated]: https://machengine.org/about/nominated-zig/
49+
4750
## Details
4851

4952
This action attempts to download the requested Zig tarball from a set of mirrors, in a random order. As

common.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const github = require('@actions/github');
55
const exec = require('@actions/exec');
66

77
const VERSIONS_JSON = 'https://ziglang.org/download/index.json';
8+
const MACH_VERSIONS_JSON = 'https://pkg.machengine.org/zig/index.json';
89
const CACHE_PREFIX = "setup-zig-global-cache-";
910

1011
let _cached_version = null;
@@ -49,6 +50,13 @@ async function getVersion() {
4950
}
5051
}
5152
_cached_version = latest;
53+
} else if (raw.includes("mach")) {
54+
const resp = await fetch(MACH_VERSIONS_JSON);
55+
const versions = await resp.json();
56+
if (!(raw in versions)) {
57+
throw new Error(`Mach nominated version '${raw}' not found`);
58+
}
59+
_cached_version = versions[raw].version;
5260
} else {
5361
_cached_version = raw;
5462
}

0 commit comments

Comments
 (0)