feat: Add support for different processor architectures (#518)
ARM, ARM64
This commit is contained in:
parent
65bdbf15ab
commit
6d30a88741
10 changed files with 859 additions and 718 deletions
|
@ -1 +1 @@
|
|||
{"name":"hugo","full_name":"hugo","oldname":null,"aliases":[],"versioned_formulae":[],"desc":"Configurable static site generator","homepage":"https://gohugo.io/","versions":{"stable":"0.62.2","devel":null,"head":"HEAD","bottle":true},"revision":0,"version_scheme":0,"bottle":{"stable":{"rebuild":0,"cellar":":any_skip_relocation","prefix":"/usr/local","root_url":"https://homebrew.bintray.com/bottles","files":{"catalina":{"url":"https://homebrew.bintray.com/bottles/hugo-0.62.2.catalina.bottle.tar.gz","sha256":"354545c2c125e01a8860f83577fb4218d585fa8d38cd7f51e4228a149347fbcf"},"mojave":{"url":"https://homebrew.bintray.com/bottles/hugo-0.62.2.mojave.bottle.tar.gz","sha256":"9645b64fe6290c4c3b7591ef21139247f0fad6e49da1edd01665b3130a8f1d1a"},"high_sierra":{"url":"https://homebrew.bintray.com/bottles/hugo-0.62.2.high_sierra.bottle.tar.gz","sha256":"0ede4cbcc7536dd6b05107376637840356062273d734b4106be98b3d1732d50c"}}}},"keg_only":false,"bottle_disabled":false,"options":[],"build_dependencies":["go"],"dependencies":[],"recommended_dependencies":[],"optional_dependencies":[],"uses_from_macos":[],"requirements":[],"conflicts_with":[],"caveats":null,"installed":[],"linked_keg":null,"pinned":false,"outdated":false,"analytics":{"install":{"30d":{"hugo":24278,"hugo --HEAD":30},"90d":{"hugo":68639,"hugo --HEAD":80},"365d":{"hugo":223748,"hugo --HEAD":321}},"install_on_request":{"30d":{"hugo":23621,"hugo --HEAD":27},"90d":{"hugo":66676,"hugo --HEAD":74},"365d":{"hugo":215985,"hugo --HEAD":305}},"build_error":{"30d":{"hugo":0}}}}
|
||||
{"name":"hugo","full_name":"hugo","tap":"homebrew/core","oldname":null,"aliases":[],"versioned_formulae":[],"desc":"Configurable static site generator","license":"Apache-2.0","homepage":"https://gohugo.io/","versions":{"stable":"0.83.1","head":"HEAD","bottle":true},"urls":{"stable":{"url":"https://github.com/gohugoio/hugo/archive/v0.83.1.tar.gz","tag":null,"revision":null}},"revision":0,"version_scheme":0,"bottle":{"stable":{"rebuild":0,"root_url":"https://ghcr.io/v2/homebrew/core","files":{"arm64_big_sur":{"cellar":":any_skip_relocation","url":"https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:f5997a1858e300787cd6e2e01ff8f87f0d3233f42af4becc040448ce06524d53","sha256":"f5997a1858e300787cd6e2e01ff8f87f0d3233f42af4becc040448ce06524d53"},"big_sur":{"cellar":":any_skip_relocation","url":"https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:32ad322954e9c2962849495c88c88e461d21a0a7d3bfa3aa4892ee34f569bf81","sha256":"32ad322954e9c2962849495c88c88e461d21a0a7d3bfa3aa4892ee34f569bf81"},"catalina":{"cellar":":any_skip_relocation","url":"https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:99078c665152420113fac08aaea7bdf2f8fe230696b724448bb9f2244cfdec55","sha256":"99078c665152420113fac08aaea7bdf2f8fe230696b724448bb9f2244cfdec55"},"mojave":{"cellar":":any_skip_relocation","url":"https://ghcr.io/v2/homebrew/core/hugo/blobs/sha256:a45ae895351a549639b40bdbb2a630e8a11ffb68d78a0aa7577faedce4c011d4","sha256":"a45ae895351a549639b40bdbb2a630e8a11ffb68d78a0aa7577faedce4c011d4"}}}},"keg_only":false,"bottle_disabled":false,"options":[],"build_dependencies":["go"],"dependencies":[],"recommended_dependencies":[],"optional_dependencies":[],"uses_from_macos":[],"requirements":[],"conflicts_with":[],"caveats":null,"installed":[],"linked_keg":null,"pinned":false,"outdated":false,"deprecated":false,"deprecation_date":null,"deprecation_reason":null,"disabled":false,"disable_date":null,"disable_reason":null,"analytics":{"install":{"30d":{"hugo":24137,"hugo --HEAD":16},"90d":{"hugo":61006,"hugo --HEAD":51},"365d":{"hugo":246915,"hugo --HEAD":273}},"install_on_request":{"30d":{"hugo":24100,"hugo --HEAD":16},"90d":{"hugo":60903,"hugo --HEAD":51},"365d":{"hugo":244317,"hugo --HEAD":266}},"build_error":{"30d":{"hugo":0}}},"generated_date":"2021-05-21"}
|
||||
|
|
File diff suppressed because it is too large
Load diff
15
__tests__/get-arch.test.ts
Normal file
15
__tests__/get-arch.test.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import getArch from '../src/get-arch';
|
||||
|
||||
describe('getArch', () => {
|
||||
test('processor architecture', () => {
|
||||
expect(getArch('x64')).toBe('64bit');
|
||||
expect(getArch('arm')).toBe('ARM');
|
||||
expect(getArch('arm64')).toBe('ARM64');
|
||||
});
|
||||
|
||||
test('exception', () => {
|
||||
expect(() => {
|
||||
getArch('mips');
|
||||
}).toThrowError('mips is not supported');
|
||||
});
|
||||
});
|
|
@ -6,13 +6,15 @@ describe('getURL()', () => {
|
|||
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', 'false', '0.58.2')).toBe(urlLinux);
|
||||
expect(getURL('Linux', 'true', '0.58.2')).not.toBe(urlLinux);
|
||||
expect(getURL('MyOS', 'false', '0.58.2')).not.toBe(urlLinux);
|
||||
expect(getURL('Linux', 'false', '0.58.1')).not.toBe(urlLinux);
|
||||
expect(getURL('Linux', 'true', '0.58.2')).toBe(urlLinuxExtended);
|
||||
expect(getURL('macOS', 'false', '0.58.2')).toBe(urlMacOS);
|
||||
expect(getURL('Windows', 'false', '0.58.2')).toBe(urlWindows);
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('Integration testing run()', () => {
|
|||
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
||||
const result: main.ActionResult = await main.run();
|
||||
expect(result.exitcode).toBe(0);
|
||||
expect(result.output).toMatch(`Hugo Static Site Generator v${testVersion}`);
|
||||
expect(result.output).toMatch(`hugo v${testVersion}`);
|
||||
});
|
||||
|
||||
test('succeed in installing a custom extended version', async () => {
|
||||
|
@ -36,7 +36,7 @@ describe('Integration testing run()', () => {
|
|||
process.env['INPUT_EXTENDED'] = 'true';
|
||||
const result: main.ActionResult = await main.run();
|
||||
expect(result.exitcode).toBe(0);
|
||||
expect(result.output).toMatch(`Hugo Static Site Generator v${testVersion}`);
|
||||
expect(result.output).toMatch(`hugo v${testVersion}`);
|
||||
expect(result.output).toMatch(`extended`);
|
||||
});
|
||||
|
||||
|
@ -46,7 +46,7 @@ describe('Integration testing run()', () => {
|
|||
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
|
||||
const result: main.ActionResult = await main.run();
|
||||
expect(result.exitcode).toBe(0);
|
||||
expect(result.output).toMatch(`Hugo Static Site Generator v${Tool.TestVersionLatest}`);
|
||||
expect(result.output).toMatch(`hugo v${Tool.TestVersionLatest}`);
|
||||
});
|
||||
|
||||
test('succeed in installing the latest extended version', async () => {
|
||||
|
@ -56,7 +56,7 @@ describe('Integration testing run()', () => {
|
|||
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
|
||||
const result: main.ActionResult = await main.run();
|
||||
expect(result.exitcode).toBe(0);
|
||||
expect(result.output).toMatch(`Hugo Static Site Generator v${Tool.TestVersionLatest}`);
|
||||
expect(result.output).toMatch(`hugo v${Tool.TestVersionLatest}`);
|
||||
expect(result.output).toMatch(`extended`);
|
||||
});
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ export enum Tool {
|
|||
Repo = 'hugo',
|
||||
CmdName = 'hugo',
|
||||
CmdOptVersion = 'version',
|
||||
TestVersionLatest = '0.62.2',
|
||||
TestVersionSpec = '0.61.0'
|
||||
TestVersionLatest = '0.83.1',
|
||||
TestVersionSpec = '0.82.1'
|
||||
}
|
||||
|
||||
export enum Action {
|
||||
|
|
12
src/get-arch.ts
Normal file
12
src/get-arch.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
export default function getArch(arch: string): string {
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
return '64bit';
|
||||
case 'arm':
|
||||
return 'ARM';
|
||||
case 'arm64':
|
||||
return 'ARM64';
|
||||
default:
|
||||
throw new Error(`${arch} is not supported`);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
export default function getOS(platform: string): string {
|
||||
if (platform === 'linux') {
|
||||
return 'Linux';
|
||||
} else if (platform === 'darwin') {
|
||||
return 'macOS';
|
||||
} else if (platform === 'win32') {
|
||||
return 'Windows';
|
||||
} else {
|
||||
throw new Error(`${platform} is not supported`);
|
||||
switch (platform) {
|
||||
case 'linux':
|
||||
return 'Linux';
|
||||
case 'darwin':
|
||||
return 'macOS';
|
||||
case 'win32':
|
||||
return 'Windows';
|
||||
default:
|
||||
throw new Error(`${platform} is not supported`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export default function getURL(os: string, extended: string, version: string): string {
|
||||
export default function getURL(
|
||||
os: string,
|
||||
arch: string,
|
||||
extended: string,
|
||||
version: string
|
||||
): string {
|
||||
const extendedStr = (extended: string): string => {
|
||||
if (extended === 'true') {
|
||||
return 'extended_';
|
||||
|
@ -17,7 +22,7 @@ export default function getURL(os: string, extended: string, version: string): s
|
|||
}
|
||||
};
|
||||
|
||||
const hugoName = `hugo_${extendedStr(extended)}${version}_${os}-64bit`;
|
||||
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)}`;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||
import * as tc from '@actions/tool-cache';
|
||||
import * as io from '@actions/io';
|
||||
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';
|
||||
|
@ -49,7 +50,10 @@ export async function installer(version: string): Promise<void> {
|
|||
const osName: string = getOS(process.platform);
|
||||
core.debug(`Operating System: ${osName}`);
|
||||
|
||||
const toolURL: string = getURL(osName, extended, version);
|
||||
const archName: string = getArch(process.arch);
|
||||
core.debug(`Processor Architecture: ${archName}`);
|
||||
|
||||
const toolURL: string = getURL(osName, archName, extended, version);
|
||||
core.debug(`toolURL: ${toolURL}`);
|
||||
|
||||
const workDir = await createWorkDir();
|
||||
|
|
Loading…
Reference in a new issue