feat: Add support for different processor architectures (#518)

ARM, ARM64
This commit is contained in:
Steve Teuber
2021-05-27 06:03:38 +02:00
committed by GitHub
parent 65bdbf15ab
commit 6d30a88741
10 changed files with 859 additions and 718 deletions

View File

@@ -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
View 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`);
}
}

View File

@@ -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`);
}
}

View File

@@ -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)}`;

View File

@@ -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();