mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-06-04 10:38:41 +02:00
feat: support renamed Hugo release assets (#687)
## Summary - Support multiple Hugo release asset names for Linux, macOS, and Windows so renamed upstream assets no longer fail with a plain 404. - Preserve compatibility with legacy Hugo assets that used filename forms such as `hugo_v0.20.3_*`, macOS `.zip` archives, and `Linux_ARM`-style names. - Add retry handling for missing candidate assets and macOS `.pkg` extraction via `pkgutil --expand-full`, with focused URL and installer tests plus the rebuilt `lib/index.js` bundle. ## References - Fixes https://github.com/peaceiris/actions-hugo/issues/652 - `hugo-version: latest` still resolves through Homebrew; this change does not fall back to an older Hugo version when the resolved release has no compatible asset. - Review note: `lib/index.js` is generated by `npm run build` and contains bundled dependency code. ## Test plan - [x] `RUNNER_TEMP=/tmp npm run all` - [x] `npm run build` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Broadened test coverage for asset URL generation, download retry behavior, and extraction across OSes and architectures. * **Bug Fixes** * More resilient installer with multiple candidate download URLs and retry handling for transient failures. * Improved extraction logic to correctly handle platform- and format-specific archives. [](https://app.coderabbit.ai/change-stack/peaceiris/actions-hugo/pull/687) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
+94
-14
@@ -1,20 +1,100 @@
|
||||
import getURL from '../src/get-url';
|
||||
|
||||
describe('getURL()', () => {
|
||||
test('get a URL to an asset for each platform', () => {
|
||||
test('get URLs to Linux assets', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
||||
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
|
||||
const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`;
|
||||
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
|
||||
const urlMacOSExtended = `${baseURL}/hugo_extended_0.58.2_macOS-64bit.tar.gz`;
|
||||
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
|
||||
expect(getURL('Linux', '64bit', 'false', '0.58.2')).toBe(urlLinux);
|
||||
expect(getURL('Linux', '64bit', 'true', '0.58.2')).not.toBe(urlLinux);
|
||||
expect(getURL('MyOS', '64bit', 'false', '0.58.2')).not.toBe(urlLinux);
|
||||
expect(getURL('Linux', '64bit', 'false', '0.58.1')).not.toBe(urlLinux);
|
||||
expect(getURL('Linux', '64bit', 'true', '0.58.2')).toBe(urlLinuxExtended);
|
||||
expect(getURL('macOS', '64bit', 'false', '0.58.2')).toBe(urlMacOS);
|
||||
expect(getURL('macOS', '64bit', 'true', '0.58.2')).toBe(urlMacOSExtended);
|
||||
expect(getURL('Windows', '64bit', 'false', '0.58.2')).toBe(urlWindows);
|
||||
expect(getURL('Linux', '64bit', 'false', '0.58.2')).toEqual([
|
||||
`${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_0.58.2_Linux_64bit.tar.gz`,
|
||||
`${baseURL}/hugo_0.58.2_linux-amd64.tar.gz`,
|
||||
`${baseURL}/hugo_v0.58.2_Linux-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_v0.58.2_Linux_64bit.tar.gz`,
|
||||
`${baseURL}/hugo_v0.58.2_linux-amd64.tar.gz`
|
||||
]);
|
||||
expect(getURL('Linux', 'ARM64', 'true', '0.58.2')).toEqual([
|
||||
`${baseURL}/hugo_extended_0.58.2_Linux-ARM64.tar.gz`,
|
||||
`${baseURL}/hugo_extended_0.58.2_Linux_ARM64.tar.gz`,
|
||||
`${baseURL}/hugo_extended_0.58.2_linux-arm64.tar.gz`,
|
||||
`${baseURL}/hugo_extended_v0.58.2_Linux-ARM64.tar.gz`,
|
||||
`${baseURL}/hugo_extended_v0.58.2_Linux_ARM64.tar.gz`,
|
||||
`${baseURL}/hugo_extended_v0.58.2_linux-arm64.tar.gz`
|
||||
]);
|
||||
});
|
||||
|
||||
test('get URLs to legacy Linux assets', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.20.3';
|
||||
expect(getURL('Linux', '64bit', 'false', '0.20.3')).toEqual([
|
||||
`${baseURL}/hugo_0.20.3_Linux-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_0.20.3_Linux_64bit.tar.gz`,
|
||||
`${baseURL}/hugo_0.20.3_linux-amd64.tar.gz`,
|
||||
`${baseURL}/hugo_v0.20.3_Linux-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_v0.20.3_Linux_64bit.tar.gz`,
|
||||
`${baseURL}/hugo_v0.20.3_linux-amd64.tar.gz`
|
||||
]);
|
||||
});
|
||||
|
||||
test('get URLs to macOS assets', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.161.1';
|
||||
expect(getURL('macOS', '64bit', 'true', '0.161.1')).toEqual([
|
||||
`${baseURL}/hugo_extended_0.161.1_macOS-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_extended_0.161.1_macOS-64bit.zip`,
|
||||
`${baseURL}/hugo_extended_0.161.1_macOS-all.tar.gz`,
|
||||
`${baseURL}/hugo_extended_0.161.1_darwin-universal.tar.gz`,
|
||||
`${baseURL}/hugo_extended_0.161.1_darwin-universal.pkg`,
|
||||
`${baseURL}/hugo_extended_v0.161.1_macOS-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_extended_v0.161.1_macOS-64bit.zip`,
|
||||
`${baseURL}/hugo_extended_v0.161.1_macOS-all.tar.gz`,
|
||||
`${baseURL}/hugo_extended_v0.161.1_darwin-universal.tar.gz`,
|
||||
`${baseURL}/hugo_extended_v0.161.1_darwin-universal.pkg`
|
||||
]);
|
||||
});
|
||||
|
||||
test('get URLs to legacy macOS assets', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.20.2';
|
||||
expect(getURL('macOS', '64bit', 'false', '0.20.2')).toEqual([
|
||||
`${baseURL}/hugo_0.20.2_macOS-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_0.20.2_macOS-64bit.zip`,
|
||||
`${baseURL}/hugo_0.20.2_macOS-all.tar.gz`,
|
||||
`${baseURL}/hugo_0.20.2_darwin-universal.tar.gz`,
|
||||
`${baseURL}/hugo_0.20.2_darwin-universal.pkg`,
|
||||
`${baseURL}/hugo_v0.20.2_macOS-64bit.tar.gz`,
|
||||
`${baseURL}/hugo_v0.20.2_macOS-64bit.zip`,
|
||||
`${baseURL}/hugo_v0.20.2_macOS-all.tar.gz`,
|
||||
`${baseURL}/hugo_v0.20.2_darwin-universal.tar.gz`,
|
||||
`${baseURL}/hugo_v0.20.2_darwin-universal.pkg`
|
||||
]);
|
||||
});
|
||||
|
||||
test('get URLs to Windows assets', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
||||
expect(getURL('Windows', '64bit', 'false', '0.58.2')).toEqual([
|
||||
`${baseURL}/hugo_0.58.2_Windows-64bit.zip`,
|
||||
`${baseURL}/hugo_0.58.2_windows-amd64.zip`,
|
||||
`${baseURL}/hugo_v0.58.2_Windows-64bit.zip`,
|
||||
`${baseURL}/hugo_v0.58.2_windows-amd64.zip`
|
||||
]);
|
||||
expect(getURL('Windows', 'ARM64', 'true', '0.58.2')).toEqual([
|
||||
`${baseURL}/hugo_extended_0.58.2_Windows-ARM64.zip`,
|
||||
`${baseURL}/hugo_extended_0.58.2_windows-arm64.zip`,
|
||||
`${baseURL}/hugo_extended_v0.58.2_Windows-ARM64.zip`,
|
||||
`${baseURL}/hugo_extended_v0.58.2_windows-arm64.zip`
|
||||
]);
|
||||
});
|
||||
|
||||
test('get URLs to legacy Windows assets', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.20.3';
|
||||
expect(getURL('Windows', '64bit', 'false', '0.20.3')).toEqual([
|
||||
`${baseURL}/hugo_0.20.3_Windows-64bit.zip`,
|
||||
`${baseURL}/hugo_0.20.3_windows-amd64.zip`,
|
||||
`${baseURL}/hugo_v0.20.3_Windows-64bit.zip`,
|
||||
`${baseURL}/hugo_v0.20.3_windows-amd64.zip`
|
||||
]);
|
||||
});
|
||||
|
||||
test('get a fallback URL to an unknown OS asset', () => {
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
||||
expect(getURL('MyOS', '64bit', 'false', '0.58.2')).toEqual([
|
||||
`${baseURL}/hugo_0.58.2_MyOS-64bit.tar.gz`
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as io from '@actions/io';
|
||||
import * as exec from '@actions/exec';
|
||||
import path from 'path';
|
||||
import {downloadHugoAsset, extractHugoAsset, isWindowsAsset} from '../src/installer';
|
||||
|
||||
jest.mock('@actions/tool-cache', () => ({
|
||||
downloadTool: jest.fn(),
|
||||
extractTar: jest.fn(),
|
||||
extractZip: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('@actions/io', () => ({
|
||||
mv: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('@actions/exec', () => ({
|
||||
exec: jest.fn()
|
||||
}));
|
||||
|
||||
describe('downloadHugoAsset()', () => {
|
||||
const mockedTC = tc as jest.Mocked<typeof tc>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test('retry 404 candidates and return the first downloaded asset', async () => {
|
||||
mockedTC.downloadTool
|
||||
.mockRejectedValueOnce(new Error('Unexpected HTTP response: 404'))
|
||||
.mockResolvedValueOnce('/tmp/hugo');
|
||||
|
||||
const result = await downloadHugoAsset([
|
||||
'https://example.com/missing.tar.gz',
|
||||
'https://example.com/hugo.tar.gz'
|
||||
]);
|
||||
|
||||
expect(result).toEqual({
|
||||
path: '/tmp/hugo',
|
||||
url: 'https://example.com/hugo.tar.gz'
|
||||
});
|
||||
expect(mockedTC.downloadTool).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('throw a clear error when all candidates return 404', async () => {
|
||||
mockedTC.downloadTool.mockRejectedValue(new Error('Unexpected HTTP response: 404'));
|
||||
|
||||
await expect(
|
||||
downloadHugoAsset([
|
||||
'https://example.com/missing-1.tar.gz',
|
||||
'https://example.com/missing-2.tar.gz'
|
||||
])
|
||||
).rejects.toThrow('Unable to find a compatible Hugo release asset');
|
||||
});
|
||||
|
||||
test('rethrow non-404 download failures without retrying', async () => {
|
||||
const error = new Error('socket hang up');
|
||||
mockedTC.downloadTool.mockRejectedValueOnce(error);
|
||||
|
||||
await expect(
|
||||
downloadHugoAsset(['https://example.com/hugo.tar.gz', 'https://example.com/fallback.tar.gz'])
|
||||
).rejects.toBe(error);
|
||||
expect(mockedTC.downloadTool).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('extractHugoAsset()', () => {
|
||||
const mockedTC = tc as jest.Mocked<typeof tc>;
|
||||
const mockedIO = io as jest.Mocked<typeof io>;
|
||||
const mockedExec = exec as jest.Mocked<typeof exec>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test('extract a tar.gz asset', async () => {
|
||||
mockedTC.extractTar.mockResolvedValue('/tmp/extracted');
|
||||
|
||||
await extractHugoAsset('/tmp/tool', 'https://example.com/hugo.tar.gz', '/tmp/temp', '/tmp/bin');
|
||||
|
||||
expect(mockedTC.extractTar).toHaveBeenCalledWith('/tmp/tool', '/tmp/temp');
|
||||
expect(mockedIO.mv).toHaveBeenCalledWith(path.join('/tmp/extracted', 'hugo'), '/tmp/bin');
|
||||
});
|
||||
|
||||
test('extract a zip asset', async () => {
|
||||
mockedTC.extractZip.mockResolvedValue('/tmp/extracted');
|
||||
|
||||
await extractHugoAsset(
|
||||
'/tmp/tool',
|
||||
'https://example.com/hugo_0.58.2_Windows-64bit.zip',
|
||||
'/tmp/temp',
|
||||
'/tmp/bin'
|
||||
);
|
||||
|
||||
expect(mockedTC.extractZip).toHaveBeenCalledWith('/tmp/tool', '/tmp/temp');
|
||||
expect(mockedIO.mv).toHaveBeenCalledWith(path.join('/tmp/extracted', 'hugo.exe'), '/tmp/bin');
|
||||
});
|
||||
|
||||
test('extract a macOS zip asset', async () => {
|
||||
mockedTC.extractZip.mockResolvedValue('/tmp/extracted');
|
||||
|
||||
await extractHugoAsset(
|
||||
'/tmp/tool',
|
||||
'https://example.com/hugo_0.20.2_macOS-64bit.zip',
|
||||
'/tmp/temp',
|
||||
'/tmp/bin'
|
||||
);
|
||||
|
||||
expect(mockedTC.extractZip).toHaveBeenCalledWith('/tmp/tool', '/tmp/temp');
|
||||
expect(mockedIO.mv).toHaveBeenCalledWith(path.join('/tmp/extracted', 'hugo'), '/tmp/bin');
|
||||
});
|
||||
|
||||
test('extract a macOS pkg asset', async () => {
|
||||
mockedExec.exec.mockResolvedValue(0);
|
||||
|
||||
await extractHugoAsset('/tmp/tool', 'https://example.com/hugo.pkg', '/tmp/temp', '/tmp/bin');
|
||||
|
||||
expect(mockedExec.exec).toHaveBeenCalledWith('pkgutil', [
|
||||
'--expand-full',
|
||||
'/tmp/tool',
|
||||
path.join('/tmp/temp', 'pkg')
|
||||
]);
|
||||
expect(mockedIO.mv).toHaveBeenCalledWith(
|
||||
path.join('/tmp/temp', 'pkg', 'Payload', 'hugo'),
|
||||
'/tmp/bin'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isWindowsAsset()', () => {
|
||||
test('detect Windows asset URLs', () => {
|
||||
expect(isWindowsAsset('https://example.com/hugo_0.58.2_Windows-64bit.zip')).toBe(true);
|
||||
expect(isWindowsAsset('https://example.com/hugo_0.119.0_windows-amd64.zip')).toBe(true);
|
||||
expect(isWindowsAsset('https://example.com/hugo_0.20.2_macOS-64bit.zip')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -19,6 +19,7 @@ describe('Integration testing run()', () => {
|
||||
await io.rmRF(workDir);
|
||||
|
||||
delete process.env['INPUT_HUGO-VERSION'];
|
||||
delete process.env['INPUT_EXTENDED'];
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
|
||||
+11802
File diff suppressed because one or more lines are too long
+51
-9
@@ -3,7 +3,7 @@ export default function getURL(
|
||||
arch: string,
|
||||
extended: string,
|
||||
version: string
|
||||
): string {
|
||||
): string[] {
|
||||
const extendedStr = (extended: string): string => {
|
||||
if (extended === 'true') {
|
||||
return 'extended_';
|
||||
@@ -14,17 +14,59 @@ export default function getURL(
|
||||
}
|
||||
};
|
||||
|
||||
const ext = (os: string): string => {
|
||||
if (os === 'Windows') {
|
||||
return 'zip';
|
||||
} else {
|
||||
return 'tar.gz';
|
||||
const lowerArch = (arch: string): string => {
|
||||
switch (arch) {
|
||||
case '64bit':
|
||||
return 'amd64';
|
||||
case 'ARM':
|
||||
return 'arm';
|
||||
case 'ARM64':
|
||||
return 'arm64';
|
||||
default:
|
||||
return arch.toLowerCase();
|
||||
}
|
||||
};
|
||||
|
||||
const hugoName = `hugo_${extendedStr(extended)}${version}_${os}-${arch}`;
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download';
|
||||
const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
|
||||
const assetBase = `hugo_${extendedStr(extended)}${version}_`;
|
||||
const legacyVersionedAssetBase = `hugo_${extendedStr(extended)}v${version}_`;
|
||||
const assetBases = [assetBase, legacyVersionedAssetBase];
|
||||
const assetURLs = (assetNames: string[]): string[] => {
|
||||
return Array.from(new Set(assetNames)).map(assetName => {
|
||||
return `${baseURL}/v${version}/${assetName}`;
|
||||
});
|
||||
};
|
||||
|
||||
return url;
|
||||
if (os === 'macOS') {
|
||||
return assetURLs(
|
||||
assetBases.flatMap(assetBase => [
|
||||
`${assetBase}macOS-${arch}.tar.gz`,
|
||||
`${assetBase}macOS-${arch}.zip`,
|
||||
`${assetBase}macOS-all.tar.gz`,
|
||||
`${assetBase}darwin-universal.tar.gz`,
|
||||
`${assetBase}darwin-universal.pkg`
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
if (os === 'Windows') {
|
||||
return assetURLs(
|
||||
assetBases.flatMap(assetBase => [
|
||||
`${assetBase}Windows-${arch}.zip`,
|
||||
`${assetBase}windows-${lowerArch(arch)}.zip`
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
if (os === 'Linux') {
|
||||
return assetURLs(
|
||||
assetBases.flatMap(assetBase => [
|
||||
`${assetBase}Linux-${arch}.tar.gz`,
|
||||
`${assetBase}Linux_${arch}.tar.gz`,
|
||||
`${assetBase}linux-${lowerArch(arch)}.tar.gz`
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
return assetURLs([`${assetBase}${os}-${arch}.tar.gz`]);
|
||||
}
|
||||
|
||||
+69
-12
@@ -1,12 +1,18 @@
|
||||
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 getOS from './get-os';
|
||||
import getArch from './get-arch';
|
||||
import getURL from './get-url';
|
||||
import * as path from 'path';
|
||||
import {Tool, Action} from './constants';
|
||||
|
||||
export interface DownloadedAsset {
|
||||
path: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export function getHomeDir(): string {
|
||||
let homedir = '';
|
||||
|
||||
@@ -43,6 +49,66 @@ export async function createBinDir(workDir: string): Promise<string> {
|
||||
return binDir;
|
||||
}
|
||||
|
||||
export function isRetryableDownloadError(error: unknown): boolean {
|
||||
const message = error instanceof Error ? error.message : `${error}`;
|
||||
return (
|
||||
message.includes('Unexpected HTTP response: 404') ||
|
||||
message.includes('Code(404)') ||
|
||||
(message.includes('404') && message.includes('Not Found'))
|
||||
);
|
||||
}
|
||||
|
||||
export function isWindowsAsset(assetURL: string): boolean {
|
||||
return /(?:Windows[-_]|windows[-_])/.test(assetURL);
|
||||
}
|
||||
|
||||
export async function downloadHugoAsset(toolURLs: string[]): Promise<DownloadedAsset> {
|
||||
for (const toolURL of toolURLs) {
|
||||
core.debug(`toolURL: ${toolURL}`);
|
||||
|
||||
try {
|
||||
return {
|
||||
path: await tc.downloadTool(toolURL),
|
||||
url: toolURL
|
||||
};
|
||||
} catch (error) {
|
||||
if (!isRetryableDownloadError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
core.debug(`Hugo asset not found at ${toolURL}`);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Unable to find a compatible Hugo release asset for this runner. Tried:\n${toolURLs.join('\n')}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function extractHugoAsset(
|
||||
assetPath: string,
|
||||
assetURL: string,
|
||||
tempDir: string,
|
||||
binDir: string
|
||||
): Promise<void> {
|
||||
let toolBin = '';
|
||||
|
||||
if (assetURL.endsWith('.zip')) {
|
||||
const toolExtractedFolder: string = await tc.extractZip(assetPath, tempDir);
|
||||
const toolCmd = isWindowsAsset(assetURL) ? `${Tool.CmdName}.exe` : Tool.CmdName;
|
||||
toolBin = path.join(toolExtractedFolder, toolCmd);
|
||||
} else if (assetURL.endsWith('.pkg')) {
|
||||
const pkgExtractedFolder = path.join(tempDir, 'pkg');
|
||||
await exec.exec('pkgutil', ['--expand-full', assetPath, pkgExtractedFolder]);
|
||||
toolBin = path.join(pkgExtractedFolder, 'Payload', Tool.CmdName);
|
||||
} else {
|
||||
const toolExtractedFolder: string = await tc.extractTar(assetPath, tempDir);
|
||||
toolBin = path.join(toolExtractedFolder, Tool.CmdName);
|
||||
}
|
||||
|
||||
await io.mv(toolBin, binDir);
|
||||
}
|
||||
|
||||
export async function installer(version: string): Promise<void> {
|
||||
const extended: string = core.getInput('extended');
|
||||
core.debug(`Hugo extended: ${extended}`);
|
||||
@@ -53,21 +119,12 @@ export async function installer(version: string): Promise<void> {
|
||||
const archName: string = getArch(process.arch);
|
||||
core.debug(`Processor Architecture: ${archName}`);
|
||||
|
||||
const toolURL: string = getURL(osName, archName, extended, version);
|
||||
core.debug(`toolURL: ${toolURL}`);
|
||||
const toolURLs: string[] = getURL(osName, archName, extended, version);
|
||||
|
||||
const workDir = await createWorkDir();
|
||||
const binDir = await createBinDir(workDir);
|
||||
const tempDir = await createTempDir(workDir);
|
||||
|
||||
const toolAssets: string = await tc.downloadTool(toolURL);
|
||||
let toolBin = '';
|
||||
if (process.platform === 'win32') {
|
||||
const toolExtractedFolder: string = await tc.extractZip(toolAssets, tempDir);
|
||||
toolBin = `${toolExtractedFolder}/${Tool.CmdName}.exe`;
|
||||
} else {
|
||||
const toolExtractedFolder: string = await tc.extractTar(toolAssets, tempDir);
|
||||
toolBin = `${toolExtractedFolder}/${Tool.CmdName}`;
|
||||
}
|
||||
await io.mv(toolBin, binDir);
|
||||
const toolAsset: DownloadedAsset = await downloadHugoAsset(toolURLs);
|
||||
await extractHugoAsset(toolAsset.path, toolAsset.url, tempDir, binDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user