Merge 5bb1c1b2dcf76262cdc8c4f8524c0a9b552ac0d9 into 0c5077e51419868618aeaa5fe8019c62421857d6

This commit is contained in:
Lee Trout 2026-06-01 21:51:47 -04:00 committed by GitHub
commit 7517966a5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 179 additions and 151 deletions

View File

@ -81,7 +81,7 @@ If you need to override the download URL, you can use the `bun-download-url` inp
| Name | Description | Default | Examples | | Name | Description | Default | Examples |
| ------------------ | --------------------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------ | | ------------------ | --------------------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------ |
| `bun-version` | The version of Bun to download and install. | Version from `package.json`, or `latest` | `canary`, `1.0.0`, `1.0.x` | | `bun-version` | The version of Bun to download and install. | Version from `package.json`, or `latest` | `canary`, `1.0.0`, `1.0.x` |
| `bun-version-file` | The version of Bun to download and install from file. | `undefined` | `package.json`, `.bun-version`, `.tool-versions` | | `bun-version-file` | The version of Bun to download and install from file. | `undefined` | `package.json`, `.bun-version`, `.tool-versions`, `mise.toml` |
| `bun-download-url` | URL to download .zip file for Bun release | | | | `bun-download-url` | URL to download .zip file for Bun release | | |
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` | | `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` | | `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |

170
dist/cache-save/index.js generated vendored

File diff suppressed because one or more lines are too long

146
dist/setup/index.js generated vendored

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
import { debug, warning } from "@actions/core"; import { debug, warning } from "@actions/core";
import { parse as parseTOML } from "@iarna/toml";
import { info } from "node:console"; import { info } from "node:console";
import { createHash } from "node:crypto"; import { createHash } from "node:crypto";
import { existsSync, readFileSync, renameSync } from "node:fs"; import { existsSync, readFileSync, renameSync } from "node:fs";
@ -118,6 +119,15 @@ export function getAvx2(
return avx2 ?? true; return avx2 ?? true;
} }
const readMiseToml = (content: string) => {
const toml = parseTOML(content);
const tools = toml.tools as Record<string, unknown> | undefined;
if (!tools) return;
const bun = tools.bun;
if (typeof bun === "string") return bun;
if (Array.isArray(bun) && typeof bun[0] === "string") return bun[0];
};
const FILE_VERSION_READERS = { const FILE_VERSION_READERS = {
"package.json": (content: string) => { "package.json": (content: string) => {
const pkg = JSON.parse(content); const pkg = JSON.parse(content);
@ -127,6 +137,8 @@ const FILE_VERSION_READERS = {
content.match(/^bun\s*(?<version>.*?)$/m)?.groups?.version, content.match(/^bun\s*(?<version>.*?)$/m)?.groups?.version,
".bumrc": (content: string) => content, // https://github.com/owenizedd/bum ".bumrc": (content: string) => content, // https://github.com/owenizedd/bum
".bun-version": (content: string) => content, ".bun-version": (content: string) => content,
"mise.toml": readMiseToml,
".mise.toml": readMiseToml,
}; };
export function readVersionFromFile( export function readVersionFromFile(