Compare commits
1 commit
main
...
renovate/n
Author | SHA1 | Date | |
---|---|---|---|
a9f3e107bb |
8 changed files with 27 additions and 118 deletions
|
@ -43,8 +43,6 @@ jobs:
|
||||||
- name: Test
|
- name: Test
|
||||||
id: npm-ci-test
|
id: npm-ci-test
|
||||||
run: npm run ci-test
|
run: npm run ci-test
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
test-action:
|
test-action:
|
||||||
name: GitHub Actions Test
|
name: GitHub Actions Test
|
||||||
|
@ -61,8 +59,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
extended: true
|
extended: true
|
||||||
dart-sass: true
|
dart-sass: true
|
||||||
with-deploy: true
|
|
||||||
github-token: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Test installed tools
|
- name: Test installed tools
|
||||||
id: test-tools
|
id: test-tools
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
20.6.0
|
20.18.1
|
||||||
|
|
|
@ -18,9 +18,7 @@ afterEach(() => {
|
||||||
|
|
||||||
describe('Install Hugo', () => {
|
describe('Install Hugo', () => {
|
||||||
test('Download latest Hugo', async () => {
|
test('Download latest Hugo', async () => {
|
||||||
const releaseLookup = new OctokitReleaseLookup(
|
const releaseLookup = new OctokitReleaseLookup()
|
||||||
process.env.GITHUB_TOKEN || undefined
|
|
||||||
)
|
|
||||||
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
|
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
|
||||||
const hugo = new HugoInstaller(releaseLookup, platformMock)
|
const hugo = new HugoInstaller(releaseLookup, platformMock)
|
||||||
|
|
||||||
|
@ -31,36 +29,4 @@ describe('Install Hugo', () => {
|
||||||
})
|
})
|
||||||
).not.toThrow()
|
).not.toThrow()
|
||||||
}, 30_000)
|
}, 30_000)
|
||||||
|
|
||||||
test('Download latest Hugo - extended', async () => {
|
|
||||||
const releaseLookup = new OctokitReleaseLookup(
|
|
||||||
process.env.GITHUB_TOKEN || undefined
|
|
||||||
)
|
|
||||||
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
|
|
||||||
const hugo = new HugoInstaller(releaseLookup, platformMock)
|
|
||||||
|
|
||||||
expect(
|
|
||||||
async () =>
|
|
||||||
await hugo.install({
|
|
||||||
version: 'latest',
|
|
||||||
extended: true
|
|
||||||
})
|
|
||||||
).not.toThrow()
|
|
||||||
}, 30_000)
|
|
||||||
|
|
||||||
test('Download latest Hugo - with deploy', async () => {
|
|
||||||
const releaseLookup = new OctokitReleaseLookup(
|
|
||||||
process.env.GITHUB_TOKEN || undefined
|
|
||||||
)
|
|
||||||
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
|
|
||||||
const hugo = new HugoInstaller(releaseLookup, platformMock)
|
|
||||||
|
|
||||||
expect(
|
|
||||||
async () =>
|
|
||||||
await hugo.install({
|
|
||||||
version: 'latest',
|
|
||||||
withDeploy: true
|
|
||||||
})
|
|
||||||
).not.toThrow()
|
|
||||||
}, 30_000)
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,12 +15,6 @@ inputs:
|
||||||
description: 'Download (if necessary) dart-sass'
|
description: 'Download (if necessary) dart-sass'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
with-deploy:
|
|
||||||
description:
|
|
||||||
'Fetch a Hugo build that includes the deploy command - if true, will
|
|
||||||
override the extended option'
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
dart-sass-version:
|
dart-sass-version:
|
||||||
description:
|
description:
|
||||||
'The dart-sass version to download.ts (if necessary) and use. Example:
|
'The dart-sass version to download.ts (if necessary) and use. Example:
|
||||||
|
|
40
dist/index.js
vendored
40
dist/index.js
vendored
|
@ -50809,21 +50809,13 @@ class HugoInstaller {
|
||||||
}
|
}
|
||||||
async install(cmd) {
|
async install(cmd) {
|
||||||
const release = await this.releaseLookup.getRelease(Hugo.Org, Hugo.Repo, cmd.version, HugoReleaseTransformer);
|
const release = await this.releaseLookup.getRelease(Hugo.Org, Hugo.Repo, cmd.version, HugoReleaseTransformer);
|
||||||
core.debug(`Hugo extended: ${cmd.extended ?? false}`);
|
core.debug(`Hugo extended: ${cmd.extended}`);
|
||||||
core.debug(`Hugo with deploy: ${cmd.withDeploy ?? false}`);
|
|
||||||
core.debug(`Operating System: ${this.platform.os}`);
|
core.debug(`Operating System: ${this.platform.os}`);
|
||||||
core.debug(`Processor Architecture: ${this.platform.arch}`);
|
core.debug(`Processor Architecture: ${this.platform.arch}`);
|
||||||
const hugoBinName = this.platform.binaryName(Hugo.CmdName);
|
const hugoBinName = this.platform.binaryName(Hugo.CmdName);
|
||||||
const tmpDir = external_node_os_namespaceObject.tmpdir();
|
const tmpDir = external_node_os_namespaceObject.tmpdir();
|
||||||
let versionSpec = release.tag_name;
|
|
||||||
if (cmd.extended) {
|
|
||||||
versionSpec = `${release.tag_name}+extended`;
|
|
||||||
}
|
|
||||||
else if (cmd.withDeploy) {
|
|
||||||
versionSpec = `${release.tag_name}+extended+withdeploy`;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const cachedTool = tool_cache.find(Hugo.Name, versionSpec, this.platform.arch);
|
const cachedTool = tool_cache.find(Hugo.Name, release.tag_name, this.platform.arch);
|
||||||
if (cachedTool) {
|
if (cachedTool) {
|
||||||
core.addPath(cachedTool);
|
core.addPath(cachedTool);
|
||||||
return;
|
return;
|
||||||
|
@ -50832,7 +50824,7 @@ class HugoInstaller {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`);
|
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`);
|
||||||
}
|
}
|
||||||
const toolUrl = release.assetUrl(this.platform, cmd.extended, cmd.withDeploy);
|
const toolUrl = release.assetUrl(this.platform, cmd.extended);
|
||||||
if (!toolUrl) {
|
if (!toolUrl) {
|
||||||
throw new Error('No matching URL detected for given platform');
|
throw new Error('No matching URL detected for given platform');
|
||||||
}
|
}
|
||||||
|
@ -50847,7 +50839,7 @@ class HugoInstaller {
|
||||||
}
|
}
|
||||||
await (0,io.rmRF)(destPath);
|
await (0,io.rmRF)(destPath);
|
||||||
try {
|
try {
|
||||||
const cachedHugoPath = await tool_cache.cacheFile(external_path_default().join(tmpDir, hugoBinName), hugoBinName, Hugo.Name, versionSpec, this.platform.arch);
|
const cachedHugoPath = await tool_cache.cacheFile(external_path_default().join(tmpDir, hugoBinName), hugoBinName, Hugo.Name, release.tag_name, this.platform.arch);
|
||||||
core.addPath(cachedHugoPath);
|
core.addPath(cachedHugoPath);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -50865,21 +50857,16 @@ const HugoReleaseTransformer = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class HugoRelease {
|
class HugoRelease {
|
||||||
static keyReplacementRegex = new RegExp('hugo_(extended_)*(withdeploy_)*(\\d+.\\d+.\\d+)_');
|
static keyReplacementRegex = new RegExp('hugo_(extended_)*(\\d+.\\d+.\\d+)_');
|
||||||
tag_name;
|
tag_name;
|
||||||
defaultAssets;
|
defaultAssets;
|
||||||
extendedAssets;
|
extendedAssets;
|
||||||
withDeployAssets;
|
|
||||||
constructor(tag_name, assets) {
|
constructor(tag_name, assets) {
|
||||||
this.tag_name = tag_name;
|
this.tag_name = tag_name;
|
||||||
this.defaultAssets = new Map();
|
this.defaultAssets = new Map();
|
||||||
this.extendedAssets = new Map();
|
this.extendedAssets = new Map();
|
||||||
this.withDeployAssets = new Map();
|
|
||||||
for (const asset of assets) {
|
for (const asset of assets) {
|
||||||
if (asset.name.includes('extended_withdeploy')) {
|
if (asset.name.includes('extended')) {
|
||||||
this.withDeployAssets.set(asset.name.replace(HugoRelease.keyReplacementRegex, ''), asset.browser_download_url);
|
|
||||||
}
|
|
||||||
else if (asset.name.includes('extended')) {
|
|
||||||
this.extendedAssets.set(asset.name.replace(HugoRelease.keyReplacementRegex, ''), asset.browser_download_url);
|
this.extendedAssets.set(asset.name.replace(HugoRelease.keyReplacementRegex, ''), asset.browser_download_url);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -50887,17 +50874,11 @@ class HugoRelease {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assetUrl(platform, extended, withDeploy) {
|
assetUrl(platform, extended) {
|
||||||
let assets = this.defaultAssets;
|
const src = extended ? this.extendedAssets : this.defaultAssets;
|
||||||
if (extended) {
|
|
||||||
assets = this.extendedAssets;
|
|
||||||
}
|
|
||||||
else if (withDeploy) {
|
|
||||||
assets = this.withDeployAssets;
|
|
||||||
}
|
|
||||||
const arch = platform.os === 'darwin' ? 'universal' : platform.arch;
|
const arch = platform.os === 'darwin' ? 'universal' : platform.arch;
|
||||||
const key = `${platform.os}-${arch}${platform.archiveExtension()}`;
|
const key = `${platform.os}-${arch}${platform.archiveExtension()}`;
|
||||||
return assets.get(key);
|
return src.get(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51025,8 +51006,7 @@ async function run() {
|
||||||
const hugoInstaller = new HugoInstaller(releaseLookup);
|
const hugoInstaller = new HugoInstaller(releaseLookup);
|
||||||
await hugoInstaller.install({
|
await hugoInstaller.install({
|
||||||
version: core.getInput('hugo-version'),
|
version: core.getInput('hugo-version'),
|
||||||
extended: core.getBooleanInput('extended'),
|
extended: core.getBooleanInput('extended')
|
||||||
withDeploy: core.getBooleanInput('with-deploy')
|
|
||||||
});
|
});
|
||||||
if (!core.getBooleanInput('dart-sass'))
|
if (!core.getBooleanInput('dart-sass'))
|
||||||
return;
|
return;
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
52
src/hugo.ts
52
src/hugo.ts
|
@ -13,7 +13,6 @@ import { errorMsg } from './utils/error'
|
||||||
export interface IHugoInstallCommand {
|
export interface IHugoInstallCommand {
|
||||||
version?: string
|
version?: string
|
||||||
extended?: boolean
|
extended?: boolean
|
||||||
withDeploy?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HugoInstaller {
|
export class HugoInstaller {
|
||||||
|
@ -33,23 +32,19 @@ export class HugoInstaller {
|
||||||
HugoReleaseTransformer
|
HugoReleaseTransformer
|
||||||
)
|
)
|
||||||
|
|
||||||
core.debug(`Hugo extended: ${cmd.extended ?? false}`)
|
core.debug(`Hugo extended: ${cmd.extended}`)
|
||||||
core.debug(`Hugo with deploy: ${cmd.withDeploy ?? false}`)
|
|
||||||
core.debug(`Operating System: ${this.platform.os}`)
|
core.debug(`Operating System: ${this.platform.os}`)
|
||||||
core.debug(`Processor Architecture: ${this.platform.arch}`)
|
core.debug(`Processor Architecture: ${this.platform.arch}`)
|
||||||
|
|
||||||
const hugoBinName = this.platform.binaryName(Hugo.CmdName)
|
const hugoBinName = this.platform.binaryName(Hugo.CmdName)
|
||||||
const tmpDir = os.tmpdir()
|
const tmpDir = os.tmpdir()
|
||||||
|
|
||||||
let versionSpec = release.tag_name
|
|
||||||
if (cmd.extended) {
|
|
||||||
versionSpec = `${release.tag_name}+extended`
|
|
||||||
} else if (cmd.withDeploy) {
|
|
||||||
versionSpec = `${release.tag_name}+extended+withdeploy`
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cachedTool = tc.find(Hugo.Name, versionSpec, this.platform.arch)
|
const cachedTool = tc.find(
|
||||||
|
Hugo.Name,
|
||||||
|
release.tag_name,
|
||||||
|
this.platform.arch
|
||||||
|
)
|
||||||
if (cachedTool) {
|
if (cachedTool) {
|
||||||
core.addPath(cachedTool)
|
core.addPath(cachedTool)
|
||||||
return
|
return
|
||||||
|
@ -58,11 +53,7 @@ export class HugoInstaller {
|
||||||
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`)
|
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const toolUrl = release.assetUrl(
|
const toolUrl = release.assetUrl(this.platform, cmd.extended)
|
||||||
this.platform,
|
|
||||||
cmd.extended,
|
|
||||||
cmd.withDeploy
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!toolUrl) {
|
if (!toolUrl) {
|
||||||
throw new Error('No matching URL detected for given platform')
|
throw new Error('No matching URL detected for given platform')
|
||||||
|
@ -88,7 +79,7 @@ export class HugoInstaller {
|
||||||
path.join(tmpDir, hugoBinName),
|
path.join(tmpDir, hugoBinName),
|
||||||
hugoBinName,
|
hugoBinName,
|
||||||
Hugo.Name,
|
Hugo.Name,
|
||||||
versionSpec,
|
release.tag_name,
|
||||||
this.platform.arch
|
this.platform.arch
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -112,14 +103,13 @@ export const HugoReleaseTransformer = {
|
||||||
|
|
||||||
export class HugoRelease implements IGithubRelease {
|
export class HugoRelease implements IGithubRelease {
|
||||||
private static readonly keyReplacementRegex = new RegExp(
|
private static readonly keyReplacementRegex = new RegExp(
|
||||||
'hugo_(extended_)*(withdeploy_)*(\\d+.\\d+.\\d+)_'
|
'hugo_(extended_)*(\\d+.\\d+.\\d+)_'
|
||||||
)
|
)
|
||||||
|
|
||||||
readonly tag_name: string
|
readonly tag_name: string
|
||||||
|
|
||||||
private readonly defaultAssets: Map<string, string>
|
private readonly defaultAssets: Map<string, string>
|
||||||
private readonly extendedAssets: Map<string, string>
|
private readonly extendedAssets: Map<string, string>
|
||||||
private readonly withDeployAssets: Map<string, string>
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
tag_name: string,
|
tag_name: string,
|
||||||
|
@ -128,15 +118,9 @@ export class HugoRelease implements IGithubRelease {
|
||||||
this.tag_name = tag_name
|
this.tag_name = tag_name
|
||||||
this.defaultAssets = new Map<string, string>()
|
this.defaultAssets = new Map<string, string>()
|
||||||
this.extendedAssets = new Map<string, string>()
|
this.extendedAssets = new Map<string, string>()
|
||||||
this.withDeployAssets = new Map<string, string>()
|
|
||||||
|
|
||||||
for (const asset of assets) {
|
for (const asset of assets) {
|
||||||
if (asset.name.includes('extended_withdeploy')) {
|
if (asset.name.includes('extended')) {
|
||||||
this.withDeployAssets.set(
|
|
||||||
asset.name.replace(HugoRelease.keyReplacementRegex, ''),
|
|
||||||
asset.browser_download_url
|
|
||||||
)
|
|
||||||
} else if (asset.name.includes('extended')) {
|
|
||||||
this.extendedAssets.set(
|
this.extendedAssets.set(
|
||||||
asset.name.replace(HugoRelease.keyReplacementRegex, ''),
|
asset.name.replace(HugoRelease.keyReplacementRegex, ''),
|
||||||
asset.browser_download_url
|
asset.browser_download_url
|
||||||
|
@ -150,21 +134,11 @@ export class HugoRelease implements IGithubRelease {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assetUrl(
|
assetUrl(platform: Platform, extended?: boolean): string | undefined {
|
||||||
platform: Platform,
|
const src = extended ? this.extendedAssets : this.defaultAssets
|
||||||
extended?: boolean,
|
|
||||||
withDeploy?: boolean
|
|
||||||
): string | undefined {
|
|
||||||
let assets = this.defaultAssets
|
|
||||||
if (extended) {
|
|
||||||
assets = this.extendedAssets
|
|
||||||
} else if (withDeploy) {
|
|
||||||
assets = this.withDeployAssets
|
|
||||||
}
|
|
||||||
|
|
||||||
const arch = platform.os === 'darwin' ? 'universal' : platform.arch
|
const arch = platform.os === 'darwin' ? 'universal' : platform.arch
|
||||||
const key = `${platform.os}-${arch}${platform.archiveExtension()}`
|
const key = `${platform.os}-${arch}${platform.archiveExtension()}`
|
||||||
|
|
||||||
return assets.get(key)
|
return src.get(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ export async function run(): Promise<void> {
|
||||||
|
|
||||||
await hugoInstaller.install({
|
await hugoInstaller.install({
|
||||||
version: core.getInput('hugo-version'),
|
version: core.getInput('hugo-version'),
|
||||||
extended: core.getBooleanInput('extended'),
|
extended: core.getBooleanInput('extended')
|
||||||
withDeploy: core.getBooleanInput('with-deploy')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!core.getBooleanInput('dart-sass')) return
|
if (!core.getBooleanInput('dart-sass')) return
|
||||||
|
|
Loading…
Reference in a new issue