From 77c12e15e1cd2cfa471786d2479af4c0fa0fc0da Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 8 Jun 2024 16:38:17 +0100 Subject: [PATCH] Add lookup for Mach nominated versions --- README.md | 5 ++++- common.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 697ac1c..c3cfa41 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/common.js b/common.js index e1acc2b..43ec2a9 100644 --- a/common.js +++ b/common.js @@ -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; }