mirror of
https://github.com/jdx/mise-action.git
synced 2026-05-14 13:50:33 +00:00
feat: allow fetching binary from mise.jdx.dev (#227)
THANKS CLOUDFLARE FOR PROJECT ALEXANDRIA
This commit is contained in:
parent
b9799ddc0c
commit
adbb7adcf1
6 changed files with 430 additions and 385 deletions
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
|
|
@ -101,3 +101,21 @@ jobs:
|
|||
echo "Expected failure but the job was ${{ steps.bad.outcome }}"
|
||||
exit 1
|
||||
if: ${{ steps.bad.outcome != 'failure' }}
|
||||
|
||||
fetch_from_github:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
- name: Setup mise from mise.jdx.dev
|
||||
uses: ./
|
||||
with:
|
||||
fetch_from_github: true
|
||||
cache: false
|
||||
cache_save: false
|
||||
mise_toml: |
|
||||
[tools]
|
||||
jq = "1.7.1"
|
||||
- run: mise --version
|
||||
- run: mise x jq -- jq --version
|
||||
- run: which jq
|
||||
- run: jq --version
|
||||
|
|
|
|||
|
|
@ -66,6 +66,10 @@ inputs:
|
|||
GitHub token for API authentication to avoid rate limits when installing GitHub-hosted tools.
|
||||
Defaults to the automatic GitHub token.
|
||||
default: ${{ github.token }}
|
||||
fetch_from_github:
|
||||
required: false
|
||||
default: "true"
|
||||
description: If true (default), fetch the mise binary from GitHub. If false and using the latest version, fetch from mise.jdx.dev instead.
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: A boolean value to indicate if a cache was hit.
|
||||
|
|
|
|||
17
dist/index.js
generated
vendored
17
dist/index.js
generated
vendored
|
|
@ -66544,7 +66544,8 @@ async function run() {
|
|||
core.setOutput('cache-hit', false);
|
||||
}
|
||||
const version = core.getInput('version');
|
||||
await setupMise(version);
|
||||
const fetchFromGitHub = core.getBooleanInput('fetch_from_github');
|
||||
await setupMise(version, fetchFromGitHub);
|
||||
await setEnvVars();
|
||||
if (core.getBooleanInput('reshim')) {
|
||||
await miseReshim();
|
||||
|
|
@ -66653,7 +66654,7 @@ async function restoreMiseCache() {
|
|||
}
|
||||
core.info(`mise cache restored from key: ${cacheKey}`);
|
||||
}
|
||||
async function setupMise(version) {
|
||||
async function setupMise(version, fetchFromGitHub = false) {
|
||||
const miseBinDir = path.join(miseDir(), 'bin');
|
||||
const miseBinPath = path.join(miseBinDir, process.platform === 'win32' ? 'mise.exe' : 'mise');
|
||||
if (!fs.existsSync(path.join(miseBinPath))) {
|
||||
|
|
@ -66666,8 +66667,16 @@ async function setupMise(version) {
|
|||
: (await zstdInstalled())
|
||||
? '.tar.zst'
|
||||
: '.tar.gz';
|
||||
version = (version || (await latestMiseVersion())).replace(/^v/, '');
|
||||
const url = `https://github.com/jdx/mise/releases/download/v${version}/mise-v${version}-${await getTarget()}${ext}`;
|
||||
let resolvedVersion = version || (await latestMiseVersion());
|
||||
resolvedVersion = resolvedVersion.replace(/^v/, '');
|
||||
let url;
|
||||
if (!fetchFromGitHub && !version) {
|
||||
// Only for latest version
|
||||
url = `https://mise.jdx.dev/mise-latest-${await getTarget()}${ext}`;
|
||||
}
|
||||
else {
|
||||
url = `https://github.com/jdx/mise/releases/download/v${resolvedVersion}/mise-v${resolvedVersion}-${await getTarget()}${ext}`;
|
||||
}
|
||||
const archivePath = path.join(os.tmpdir(), `mise${ext}`);
|
||||
switch (ext) {
|
||||
case '.zip':
|
||||
|
|
|
|||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
755
package-lock.json
generated
755
package-lock.json
generated
File diff suppressed because it is too large
Load diff
19
src/index.ts
19
src/index.ts
|
|
@ -21,7 +21,8 @@ async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
const version = core.getInput('version')
|
||||
await setupMise(version)
|
||||
const fetchFromGitHub = core.getBooleanInput('fetch_from_github')
|
||||
await setupMise(version, fetchFromGitHub)
|
||||
await setEnvVars()
|
||||
if (core.getBooleanInput('reshim')) {
|
||||
await miseReshim()
|
||||
|
|
@ -139,7 +140,10 @@ async function restoreMiseCache(): Promise<string | undefined> {
|
|||
core.info(`mise cache restored from key: ${cacheKey}`)
|
||||
}
|
||||
|
||||
async function setupMise(version: string): Promise<void> {
|
||||
async function setupMise(
|
||||
version: string,
|
||||
fetchFromGitHub = false
|
||||
): Promise<void> {
|
||||
const miseBinDir = path.join(miseDir(), 'bin')
|
||||
const miseBinPath = path.join(
|
||||
miseBinDir,
|
||||
|
|
@ -156,8 +160,15 @@ async function setupMise(version: string): Promise<void> {
|
|||
: (await zstdInstalled())
|
||||
? '.tar.zst'
|
||||
: '.tar.gz'
|
||||
version = (version || (await latestMiseVersion())).replace(/^v/, '')
|
||||
const url = `https://github.com/jdx/mise/releases/download/v${version}/mise-v${version}-${await getTarget()}${ext}`
|
||||
let resolvedVersion = version || (await latestMiseVersion())
|
||||
resolvedVersion = resolvedVersion.replace(/^v/, '')
|
||||
let url: string
|
||||
if (!fetchFromGitHub && !version) {
|
||||
// Only for latest version
|
||||
url = `https://mise.jdx.dev/mise-latest-${await getTarget()}${ext}`
|
||||
} else {
|
||||
url = `https://github.com/jdx/mise/releases/download/v${resolvedVersion}/mise-v${resolvedVersion}-${await getTarget()}${ext}`
|
||||
}
|
||||
const archivePath = path.join(os.tmpdir(), `mise${ext}`)
|
||||
switch (ext) {
|
||||
case '.zip':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue