Automatically create download dir

This commit is contained in:
Kevin Stillhammer 2024-08-24 00:27:50 +02:00
parent 67efd41074
commit 07977d064c
No known key found for this signature in database
3 changed files with 9 additions and 10 deletions

BIN
dist/setup/index.js generated vendored

Binary file not shown.

View File

@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import * as path from 'path'
import * as exec from '@actions/exec'
import * as path from 'path'
import {Architecture, Platform} from '../utils/platforms'
import {validateChecksum} from './checksum/checksum'
import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
@ -21,10 +21,9 @@ export async function downloadLatest(
}
core.info(`Downloading uv from "${downloadUrl}" ...`)
const downloadDir = `${process.cwd()}${path.sep}uv`
const downloadPath = await tc.downloadTool(
downloadUrl,
downloadDir,
undefined,
githubToken
)
let uvExecutablePath: string
@ -37,7 +36,7 @@ export async function downloadLatest(
uvExecutablePath = path.join(extracted, 'uv')
}
const version = await getVersion(uvExecutablePath)
await validateChecksum(checkSum, downloadPath, arch, platform, version)
await validateChecksum(checkSum, extracted, arch, platform, version)
const cachedToolDir = await tc.cacheDir(
downloadPath,
TOOL_CACHE_NAME,

View File

@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
import path from 'path'
import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
import {Architecture, Platform} from '../utils/platforms'
import {validateChecksum} from './checksum/checksum'
@ -31,18 +31,18 @@ export async function downloadVersion(
}
core.info(`Downloading uv from "${downloadUrl}" ...`)
const downloadDir = `${process.cwd()}${path.sep}uv`
const downloadPath = await tc.downloadTool(
downloadUrl,
downloadDir,
undefined,
githubToken
)
await validateChecksum(checkSum, downloadPath, arch, platform, version)
let extractedDir: string
if (platform === 'pc-windows-msvc') {
await tc.extractZip(downloadPath)
extractedDir = await tc.extractZip(downloadPath)
} else {
tc.extractTar(downloadPath)
extractedDir = await tc.extractTar(downloadPath)
}
return await tc.cacheDir(downloadPath, TOOL_CACHE_NAME, version, arch)
return await tc.cacheDir(extractedDir, TOOL_CACHE_NAME, version, arch)
}