mirror of
https://github.com/jdx/mise-action.git
synced 2026-05-14 22:00:34 +00:00
feat: use self-update to modify version if mise is already installed (#277)
Hello 👋 1st of all thanks for your work on mise, it's really a game changer 😁 ## Why This PR tries to address the issue #165 (mise-action cannot upgrade mise) ## What I've decided to use `mise self-update` if mise is already installed to switch to the desired version Let me know if this is an OK fix for you ## Tests To test this feature, I've run the action on my repo and screenshot the newly created output <img width="591" height="538" alt="Screenshot 2025-10-01 at 22 14 46" src="https://github.com/user-attachments/assets/9a10a33a-d86f-410b-8bdc-71b07b3036f6" /> The sha of the commit was suposed to match the sha of the screenshot, but I've fixup and rebase the PR Happy to do a new one if you want live proof <!-- CURSOR_SUMMARY --> --- > [!NOTE] > When mise is already installed, compare the requested `version` input to the installed version and run `self-update` to align if they differ. > > - **Action Logic (`src/index.ts`)**: > - **Existing Installation Handling**: > - Read `version` input; fetch installed version via `mise version --json`. > - If versions differ, execute `mise self-update <version> -y`; otherwise log that mise is already installed. > - Download path and SHA256 verification remain unchanged. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 941208cb9b7a6e796cdc7e96a8dcf6560d4d207c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This commit is contained in:
parent
1f7944793c
commit
77a964b3e4
3 changed files with 41 additions and 1 deletions
18
dist/index.js
generated
vendored
18
dist/index.js
generated
vendored
|
|
@ -50194,6 +50194,24 @@ async function setupMise(version, fetchFromGitHub = false) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const requestedVersion = 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];
|
||||
if (requestedVersion === version) {
|
||||
core.info(`mise already installed`);
|
||||
}
|
||||
else {
|
||||
core.info(`mise already installed (${version}), but different version requested (${requestedVersion})`);
|
||||
await exec.exec(miseBinPath, ['self-update', requestedVersion, '-y'], {
|
||||
silent: true
|
||||
});
|
||||
core.info(`mise updated to version ${requestedVersion}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// compare with provided hash
|
||||
const want = core.getInput('sha256');
|
||||
if (want) {
|
||||
|
|
|
|||
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
22
src/index.ts
22
src/index.ts
|
|
@ -264,6 +264,28 @@ async function setupMise(
|
|||
await exec.exec('chmod', ['+x', miseBinPath])
|
||||
break
|
||||
}
|
||||
} else {
|
||||
const requestedVersion = 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]
|
||||
if (requestedVersion === version) {
|
||||
core.info(`mise already installed`)
|
||||
} else {
|
||||
core.info(
|
||||
`mise already installed (${version}), but different version requested (${requestedVersion})`
|
||||
)
|
||||
await exec.exec(miseBinPath, ['self-update', requestedVersion, '-y'], {
|
||||
silent: true
|
||||
})
|
||||
core.info(`mise updated to version ${requestedVersion}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
// compare with provided hash
|
||||
const want = core.getInput('sha256')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue