(GH-608) Fix package url for v0.102.0 & v0.103.0
Prior to this change, the URL building for versions of hugo was deterministic as the URLs for the packages were set to a project-specific standard. That URL creation began to fail for macOS in [0.102.0] and for Windows in [0.103.0]. It does not fail for Linux because the hugo releases for Linux continue to include the old package naming as an alias. This change: - Updates the `get-os` function to take the hugo version as additional input, altering the return value based on the version. - Updates the `get-arch` function to take the operating system name and hugo version as additional input, altering the return value based on both. Including the OS name is required for handling macOS. - Fixes #608 - Fixes #605 [0.102.0]: https://github.com/gohugoio/hugo/releases/tag/v0.102.0 [0.103.0]: https://github.com/gohugoio/hugo/releases/tag/v0.103.0
This commit is contained in:
parent
a2eba60698
commit
e70fd029fa
5 changed files with 101 additions and 19 deletions
|
@ -1,15 +1,63 @@
|
||||||
import getArch from '../src/get-arch';
|
import getArch from '../src/get-arch';
|
||||||
|
|
||||||
describe('getArch', () => {
|
describe('getArch', () => {
|
||||||
test('processor architecture', () => {
|
test('processor architecture < 0.102.0', () => {
|
||||||
expect(getArch('x64')).toBe('64bit');
|
expect(getArch('x64', 'linux', '0.101.0')).toBe('64bit');
|
||||||
expect(getArch('arm')).toBe('ARM');
|
expect(getArch('x64', 'macOS', '0.101.0')).toBe('64bit');
|
||||||
expect(getArch('arm64')).toBe('ARM64');
|
expect(getArch('x64', 'windows', '0.101.0')).toBe('64bit');
|
||||||
|
|
||||||
|
expect(getArch('arm', 'linux', '0.101.0')).toBe('ARM');
|
||||||
|
expect(getArch('arm', 'macOS', '0.101.0')).toBe('ARM');
|
||||||
|
expect(getArch('arm', 'windows', '0.101.0')).toBe('ARM');
|
||||||
|
|
||||||
|
expect(getArch('arm64', 'linux', '0.101.0')).toBe('ARM64');
|
||||||
|
expect(getArch('arm64', 'macOS', '0.101.0')).toBe('ARM64');
|
||||||
|
expect(getArch('arm64', 'windows', '0.101.0')).toBe('ARM64');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processor architecture === 0.102.z', () => {
|
||||||
|
expect(getArch('x64', 'linux', '0.102.0')).toBe('64bit');
|
||||||
|
expect(getArch('x64', 'macOS', '0.102.0')).toBe('universal');
|
||||||
|
expect(getArch('x64', 'windows', '0.102.0')).toBe('64bit');
|
||||||
|
|
||||||
|
expect(getArch('arm', 'macOS', '0.102.0')).toBe('universal');
|
||||||
|
|
||||||
|
expect(getArch('arm64', 'linux', '0.102.0')).toBe('ARM64');
|
||||||
|
expect(getArch('arm64', 'macOS', '0.102.0')).toBe('universal');
|
||||||
|
expect(getArch('arm64', 'windows', '0.102.0')).toBe('ARM64');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processor architecture === 0.103.z', () => {
|
||||||
|
expect(getArch('x64', 'linux', '0.103.0')).toBe('amd64');
|
||||||
|
expect(getArch('x64', 'darwin', '0.103.0')).toBe('universal');
|
||||||
|
expect(getArch('x64', 'windows', '0.103.0')).toBe('amd64');
|
||||||
|
|
||||||
|
expect(getArch('arm', 'darwin', '0.103.0')).toBe('universal');
|
||||||
|
|
||||||
|
expect(getArch('arm64', 'linux', '0.103.0')).toBe('arm64');
|
||||||
|
expect(getArch('arm64', 'darwin', '0.103.0')).toBe('universal');
|
||||||
|
expect(getArch('arm64', 'windows', '0.103.0')).toBe('arm64');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('processor architecture > 0.103.0', () => {
|
||||||
|
expect(getArch('x64', 'linux', '0.104.0')).toBe('amd64');
|
||||||
|
expect(getArch('x64', 'darwin', '0.104.0')).toBe('universal');
|
||||||
|
expect(getArch('x64', 'windows', '0.104.0')).toBe('amd64');
|
||||||
|
|
||||||
|
expect(getArch('arm', 'darwin', '0.104.0')).toBe('universal');
|
||||||
|
|
||||||
|
expect(getArch('arm64', 'linux', '0.104.0')).toBe('arm64');
|
||||||
|
expect(getArch('arm64', 'darwin', '0.104.0')).toBe('universal');
|
||||||
|
expect(getArch('arm64', 'windows', '0.104.0')).toBe('arm64');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exception', () => {
|
test('exception', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
getArch('mips');
|
getArch('mips', 'linux', '0.101.0');
|
||||||
}).toThrowError('mips is not supported');
|
}).toThrowError('mips is not supported');
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
getArch('arm', 'linux', '0.102.0')
|
||||||
|
}).toThrowError('arm is not supported');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,14 +2,26 @@ import getOS from '../src/get-os';
|
||||||
|
|
||||||
describe('getOS', () => {
|
describe('getOS', () => {
|
||||||
test('os type', () => {
|
test('os type', () => {
|
||||||
expect(getOS('linux')).toBe('Linux');
|
expect(getOS('linux', '0.101.0')).toBe('Linux');
|
||||||
expect(getOS('darwin')).toBe('macOS');
|
expect(getOS('darwin', '0.101.0')).toBe('macOS');
|
||||||
expect(getOS('win32')).toBe('Windows');
|
expect(getOS('win32', '0.101.0')).toBe('Windows');
|
||||||
|
|
||||||
|
expect(getOS('linux', '0.102.0')).toBe('Linux');
|
||||||
|
expect(getOS('darwin', '0.102.0')).toBe('darwin');
|
||||||
|
expect(getOS('win32', '0.102.0')).toBe('Windows');
|
||||||
|
|
||||||
|
expect(getOS('linux', '0.103.0')).toBe('linux');
|
||||||
|
expect(getOS('darwin', '0.103.0')).toBe('darwin');
|
||||||
|
expect(getOS('win32', '0.103.0')).toBe('windows');
|
||||||
|
|
||||||
|
expect(getOS('linux', '0.104.0')).toBe('linux');
|
||||||
|
expect(getOS('darwin', '0.104.0')).toBe('darwin');
|
||||||
|
expect(getOS('win32', '0.104.0')).toBe('windows');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exception', () => {
|
test('exception', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
getOS('centos');
|
getOS('centos', '0.101.0');
|
||||||
}).toThrowError('centos is not supported');
|
}).toThrowError('centos is not supported');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,32 @@
|
||||||
export default function getArch(arch: string): string {
|
export default function getArch(arch: string, os: string, version: string): string {
|
||||||
|
const segments = version.split('.').map(s => parseInt(s));
|
||||||
|
|
||||||
|
if (os == 'darwin' || (os == 'macOS' && segments[0] >= 0 && segments[1] >= 102)) {
|
||||||
|
return 'universal'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (segments[0] >= 0 && segments[1] >= 103) {
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case 'x64':
|
case 'x64':
|
||||||
return '64bit';
|
return 'amd64';
|
||||||
case 'arm':
|
|
||||||
return 'ARM';
|
|
||||||
case 'arm64':
|
case 'arm64':
|
||||||
return 'ARM64';
|
return 'arm64';
|
||||||
|
default:
|
||||||
|
throw new Error(`${arch} is not supported`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (arch) {
|
||||||
|
case 'x64':
|
||||||
|
return (segments[0] >= 0 && segments[1] >= 103) ? 'amd64' : '64bit';
|
||||||
|
case 'arm':
|
||||||
|
if (segments[0] >= 0 && segments[1] < 102) {
|
||||||
|
return 'ARM';
|
||||||
|
} else {
|
||||||
|
throw new Error(`${arch} is not supported`);
|
||||||
|
}
|
||||||
|
case 'arm64':
|
||||||
|
return (segments[0] >= 0 && segments[1] >= 103) ? 'arm64' : 'ARM64';
|
||||||
default:
|
default:
|
||||||
throw new Error(`${arch} is not supported`);
|
throw new Error(`${arch} is not supported`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
export default function getOS(platform: string): string {
|
export default function getOS(platform: string, version: string): string {
|
||||||
|
const segments = version.split('.').map(s => parseInt(s));
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return 'Linux';
|
return (segments[0] >= 0 && segments[1] >= 103) ? 'linux' : 'Linux'
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'macOS';
|
return (segments[0] >= 0 && segments[1] >= 102) ? 'darwin' : 'macOS'
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Windows';
|
return (segments[0] >= 0 && segments[1] >= 103) ? 'windows' : 'Windows'
|
||||||
default:
|
default:
|
||||||
throw new Error(`${platform} is not supported`);
|
throw new Error(`${platform} is not supported`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,10 @@ export async function installer(version: string): Promise<void> {
|
||||||
const extended: string = core.getInput('extended');
|
const extended: string = core.getInput('extended');
|
||||||
core.debug(`Hugo extended: ${extended}`);
|
core.debug(`Hugo extended: ${extended}`);
|
||||||
|
|
||||||
const osName: string = getOS(process.platform);
|
const osName: string = getOS(process.platform, version);
|
||||||
core.debug(`Operating System: ${osName}`);
|
core.debug(`Operating System: ${osName}`);
|
||||||
|
|
||||||
const archName: string = getArch(process.arch);
|
const archName: string = getArch(process.arch, osName, version);
|
||||||
core.debug(`Processor Architecture: ${archName}`);
|
core.debug(`Processor Architecture: ${archName}`);
|
||||||
|
|
||||||
const toolURL: string = getURL(osName, archName, extended, version);
|
const toolURL: string = getURL(osName, archName, extended, version);
|
||||||
|
|
Loading…
Reference in a new issue