fix: trim "v" prefix on update (#287)

Fixes https://github.com/jdx/mise-action/issues/285
This commit is contained in:
Gregor Zeitlinger 2025-10-06 13:17:50 +02:00 committed by GitHub
parent ec79764013
commit 254003e261
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 11 deletions

View file

@ -79,6 +79,13 @@ jobs:
bun = "1"
- run: which bun
- run: bun -v
- name: Update mise
uses: ./
with:
cache_save: ${{ github.ref_name == 'main' }}
cache_key_prefix: mise-v1
version: v2025.7.3 # should trim the `v`
sha256: d38d4993c5379a680b50661f86287731dc1d1264777880a79b786403af337948
checksum_failure:
runs-on: ubuntu-latest

12
dist/index.js generated vendored
View file

@ -50102,15 +50102,17 @@ async function exportMiseEnv() {
}
core.endGroup();
}
function cleanVersion(version) {
// remove 'v' prefix if present
return version.replace(/^v/, '');
}
function checkMiseSupportsRedacted() {
const version = core.getInput('version');
// If no version is specified, assume latest which supports redacted
if (!version) {
return true;
}
// Parse the version string (remove 'v' prefix if present)
const cleanVersion = version.replace(/^v/, '');
const versionMatch = cleanVersion.match(/^(\d+)\.(\d+)\.(\d+)/);
const versionMatch = cleanVersion(version).match(/^(\d+)\.(\d+)\.(\d+)/);
if (!versionMatch) {
// If we can't parse the version, assume it supports redacted
return true;
@ -50221,11 +50223,11 @@ async function setupMise(version, fetchFromGitHub = false) {
}
}
else {
const requestedVersion = core.getInput('version');
const requestedVersion = cleanVersion(core.getInput('version'));
if (requestedVersion !== '') {
const versionOutput = await exec.getExecOutput(miseBinPath, ['version', '--json'], { silent: true });
const versionJson = JSON.parse(versionOutput.stdout);
const version = versionJson.version.split(' ')[0];
const version = cleanVersion(versionJson.version.split(' ')[0]);
if (requestedVersion === version) {
core.info(`mise already installed`);
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -126,6 +126,11 @@ async function exportMiseEnv(): Promise<void> {
core.endGroup()
}
function cleanVersion(version: string) {
// remove 'v' prefix if present
return version.replace(/^v/, '')
}
function checkMiseSupportsRedacted(): boolean {
const version = core.getInput('version')
@ -134,9 +139,7 @@ function checkMiseSupportsRedacted(): boolean {
return true
}
// Parse the version string (remove 'v' prefix if present)
const cleanVersion = version.replace(/^v/, '')
const versionMatch = cleanVersion.match(/^(\d+)\.(\d+)\.(\d+)/)
const versionMatch = cleanVersion(version).match(/^(\d+)\.(\d+)\.(\d+)/)
if (!versionMatch) {
// If we can't parse the version, assume it supports redacted
@ -265,7 +268,7 @@ async function setupMise(
break
}
} else {
const requestedVersion = core.getInput('version')
const requestedVersion = cleanVersion(core.getInput('version'))
if (requestedVersion !== '') {
const versionOutput = await exec.getExecOutput(
miseBinPath,
@ -273,7 +276,7 @@ async function setupMise(
{ silent: true }
)
const versionJson = JSON.parse(versionOutput.stdout)
const version = versionJson.version.split(' ')[0]
const version = cleanVersion(versionJson.version.split(' ')[0])
if (requestedVersion === version) {
core.info(`mise already installed`)
} else {