Skip to content

Commit

Permalink
Add lookup for Mach nominated versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mlugg committed Jun 8, 2024
1 parent 1cc5703 commit 77c12e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 77c12e1

Please sign in to comment.