Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support #296

Merged
merged 10 commits into from
Jul 12, 2024
33 changes: 26 additions & 7 deletions dist/save-cache/index.js

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

2 changes: 1 addition & 1 deletion dist/save-cache/index.js.map

Large diffs are not rendered by default.

85 changes: 69 additions & 16 deletions dist/setup/index.js

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

2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions dist/update-default-version/index.js

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

2 changes: 1 addition & 1 deletion dist/update-default-version/index.js.map

Large diffs are not rendered by default.

39 changes: 28 additions & 11 deletions src/download/download-latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,43 @@ import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import * as io from '@actions/io'
import * as exec from '@actions/exec'
import {Architecture, OWNER, REPO, extract, validateChecksum} from '../utils'
import {
Architecture,
OWNER,
Platform,
REPO,
extract,
validateChecksum
} from '../utils'

export async function downloadLatest(
platform: string,
platform: Platform,
arch: Architecture,
checkSum: string | undefined,
githubToken: string | undefined
): Promise<{downloadPath: string; version: string}> {
const binary = `rye-${arch}-${platform}`
const downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${binary}.gz`
let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${binary}`
if (platform === 'windows') {
he0119 marked this conversation as resolved.
Show resolved Hide resolved
downloadUrl += '.exe'
} else {
downloadUrl += '.gz'
}
core.info(`Downloading Rye from "${downloadUrl}" ...`)

const downloadPath = await tc.downloadTool(
downloadUrl,
undefined,
githubToken
)
const pathForValidation = `${downloadPath}_for_validation.gz`
await io.cp(downloadPath, pathForValidation)
await extract(downloadPath)
let downloadPath = await tc.downloadTool(downloadUrl, undefined, githubToken)
let pathForValidation: string
if (platform === 'windows') {
he0119 marked this conversation as resolved.
Show resolved Hide resolved
// On Windows, the downloaded file is an executable, so we don't need to extract it
// but the file must has a valid extension for an executable file.
await io.mv(downloadPath, `${downloadPath}.exe`)
downloadPath = `${downloadPath}.exe`
pathForValidation = downloadPath
} else {
pathForValidation = `${downloadPath}_for_validation.gz`
await io.cp(downloadPath, pathForValidation)
await extract(downloadPath)
}
const version = await getVersion(downloadPath)
await validateChecksum(checkSum, pathForValidation, arch, platform, version)

Expand Down
Loading