Skip to content

Commit

Permalink
Automatically create download dir
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Aug 23, 2024
1 parent 67efd41 commit 07977d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
21 changes: 13 additions & 8 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/download/download-latest.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/download/download-version.ts
Original file line number Diff line number Diff line change
@@ -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'

Check failure on line 3 in src/download/download-version.ts

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'path' is defined but never used

Check failure on line 3 in src/download/download-version.ts

View workflow job for this annotation

GitHub Actions / build (macos-14)

'path' is defined but never used

Check failure on line 3 in src/download/download-version.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'path' is defined but never used
import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
import {Architecture, Platform} from '../utils/platforms'
import {validateChecksum} from './checksum/checksum'

Expand Down Expand Up @@ -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)
}

0 comments on commit 07977d0

Please sign in to comment.