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

feat: allow zip files to be downloaded #125

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
version:
required: false
description: 'gh cli version to download'
archive_format:
required: false
description: 'the format of the archive that is published at: github.com/cli/cli/releases (defaults to .tar.gz)'
runs:
using: 'node16'
main: 'dist/index.js'
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as os from 'os'

import {cacheFile, downloadTool, extractTar, find} from '@actions/tool-cache'
import {cacheFile, downloadTool, extractTar, find, extractZip} from '@actions/tool-cache'
import {chmodSync} from 'fs'
import {HttpClient} from '@actions/http-client'

Expand All @@ -26,7 +26,8 @@ async function install(): Promise<void> {
const version = core.getInput('version') || (await getLatestVersion())

const platform = core.getInput('platform') || os.platform()
const packageUrl = `https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${platform}_amd64.tar.gz`
const archive_format = core.getInput('archive_format') || 'tar.gz'
const packageUrl = `https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${platform}_amd64.${archive_format}`

core.info(`Downloading gh cli from ${packageUrl}`)

Expand All @@ -35,7 +36,7 @@ async function install(): Promise<void> {
if (!cliPath) {
const downloadPath = await downloadTool(packageUrl, 'gh_tar')
chmodSync(downloadPath, '755')
cliPath = await extractTar(downloadPath, find(GH_CLI_TOOL_NAME, version))
cliPath = archive_format === 'tar.gz' ? await extractTar(downloadPath, find(GH_CLI_TOOL_NAME, version)) : await extractZip(downloadPath, find(GH_CLI_TOOL_NAME, version))
cliPath = await cacheFile(
`${cliPath}/gh_${version}_${platform}_amd64/bin/gh`,
'gh',
Expand Down
Loading