feat: fetch tarball with zst compression (#153)

This commit is contained in:
jdx 2024-12-23 13:31:53 -06:00 committed by GitHub
parent 5bb8f8c191
commit 370e73c4f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 132 additions and 125 deletions

View file

@ -130,29 +130,30 @@ async function setupMise(version: string): Promise<void> {
if (!fs.existsSync(path.join(miseBinPath))) {
core.startGroup(version ? `Download mise@${version}` : 'Setup mise')
await fs.promises.mkdir(miseBinDir, { recursive: true })
const ext =
getOS() === 'windows'
? '.zip'
: version && version.startsWith('2024')
? ''
: '.tar.zst'
const url = version
? `https://mise.jdx.dev/v${version}/mise-v${version}-${getOS()}-${os.arch()}`
: `https://mise.jdx.dev/mise-latest-${getOS()}-${os.arch()}`
? `https://mise.jdx.dev/v${version}/mise-v${version}-${getOS()}-${os.arch()}${ext}`
: `https://mise.jdx.dev/mise-latest-${getOS()}-${os.arch()}${ext}`
const archivePath = path.join(os.tmpdir(), `mise${ext}`)
if (getOS() === 'windows') {
const zipPath = path.join(os.tmpdir(), 'mise.zip')
await exec.exec('curl', [
'--compressed',
'-fsSL',
`${url}.zip`,
'--output',
zipPath
])
await exec.exec('unzip', [zipPath, '-d', os.tmpdir()])
await exec.exec('curl', ['-fsSL', url, '--output', archivePath])
await exec.exec('unzip', [archivePath, '-d', os.tmpdir()])
await io.mv(path.join(os.tmpdir(), 'mise/bin/mise.exe'), miseBinPath)
} else {
await exec.exec('curl', [
'--compressed',
'-fsSL',
url,
'--output',
miseBinPath
])
await exec.exec('chmod', ['+x', miseBinPath])
if (ext === '') {
await exec.exec('sh', ['-c', `curl -fsSL ${url} > ${miseBinPath}`])
await exec.exec('chmod', ['+x', miseBinPath])
} else {
await exec.exec('sh', [
'-c',
`curl -fsSL ${url} | tar --zstd -xf - -C ${os.tmpdir()} && mv ${os.tmpdir()}/mise/bin/mise ${miseBinPath}`
])
}
}
}
core.addPath(miseBinDir)