fix: cache mise bin (#134)

Fixes #133
This commit is contained in:
jdx 2024-10-23 20:27:00 -05:00 committed by GitHub
parent c1be5dfbbf
commit 1b7ab9b9c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 764 additions and 1831 deletions

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

File diff suppressed because it is too large Load diff

2
dist/cache-save/index.js.map generated vendored

File diff suppressed because one or more lines are too long

929
dist/index.js generated vendored

File diff suppressed because it is too large Load diff

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

20
dist/licenses.txt generated vendored
View file

@ -760,10 +760,22 @@ uuid
MIT
The MIT License (MIT)
Copyright (c) 2010-2020 Robert Kieffer and other contributors
Copyright (c) 2010-2016 Robert Kieffer and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

669
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -52,6 +52,7 @@ async function setEnvVars(): Promise<void> {
async function restoreMiseCache(): Promise<void> {
core.startGroup('Restoring mise cache')
const version = core.getInput('version')
const cachePath = miseDir()
const fileHash = await glob.hashFiles(
[
@ -71,7 +72,10 @@ async function restoreMiseCache(): Promise<void> {
].join('\n')
)
const prefix = core.getInput('cache_key_prefix') || 'mise-v0'
const primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`
let primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`
if (version) {
primaryKey = `${primaryKey}-${version}`
}
core.saveState('CACHE', core.getBooleanInput('cache_save') ?? true)
core.saveState('PRIMARY_KEY', primaryKey)
@ -90,8 +94,13 @@ async function restoreMiseCache(): Promise<void> {
}
async function setupMise(version: string | undefined): Promise<void> {
core.startGroup(version ? `Setup mise@${version}` : 'Setup mise')
const miseBinDir = path.join(miseDir(), 'bin')
const miseBinPath = path.join(
miseBinDir,
getOS() === 'windows' ? 'mise.exe' : 'mise'
)
if (!fs.existsSync(path.join(miseBinPath))) {
core.startGroup(version ? `Download mise@${version}` : 'Setup mise')
await fs.promises.mkdir(miseBinDir, { recursive: true })
const url = version
? `https://mise.jdx.dev/v${version}/mise-v${version}-${getOS()}-${os.arch()}`
@ -100,14 +109,11 @@ async function setupMise(version: string | undefined): Promise<void> {
const zipPath = path.join(os.tmpdir(), 'mise.zip')
await exec.exec('curl', ['-fsSL', `${url}.zip`, '--output', zipPath])
await exec.exec('unzip', [zipPath, '-d', os.tmpdir()])
await io.mv(
path.join(os.tmpdir(), 'mise/bin/mise.exe'),
path.join(miseBinDir, 'mise.exe')
)
await io.mv(path.join(os.tmpdir(), 'mise/bin/mise.exe'), miseBinPath)
} else {
const output = path.join(miseBinDir, 'mise')
await exec.exec('curl', ['-fsSL', url, '--output', output])
await exec.exec('chmod', ['+x', path.join(miseBinDir, 'mise')])
await exec.exec('curl', ['-fsSL', url, '--output', miseBinPath])
await exec.exec('chmod', ['+x', miseBinPath])
}
}
core.addPath(miseBinDir)
}