feat: support with deploy option
This commit is contained in:
parent
910d150813
commit
10b6b9aa45
4 changed files with 34 additions and 7 deletions
|
@ -59,6 +59,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
extended: true
|
extended: true
|
||||||
dart-sass: true
|
dart-sass: true
|
||||||
|
with-deploy: true
|
||||||
|
|
||||||
- name: Test installed tools
|
- name: Test installed tools
|
||||||
id: test-tools
|
id: test-tools
|
||||||
|
|
|
@ -15,6 +15,12 @@ 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:
|
||||||
|
|
31
src/hugo.ts
31
src/hugo.ts
|
@ -13,6 +13,7 @@ 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 {
|
||||||
|
@ -32,7 +33,8 @@ export class HugoInstaller {
|
||||||
HugoReleaseTransformer
|
HugoReleaseTransformer
|
||||||
)
|
)
|
||||||
|
|
||||||
core.debug(`Hugo extended: ${cmd.extended}`)
|
core.debug(`Hugo extended: ${cmd.extended ?? false}`)
|
||||||
|
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}`)
|
||||||
|
|
||||||
|
@ -103,13 +105,14 @@ 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_)*(\\d+.\\d+.\\d+)_'
|
'hugo_(extended_)*(withdeploy_)*(\\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,
|
||||||
|
@ -118,9 +121,15 @@ 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')) {
|
if (asset.name.includes('extended_withdeploy')) {
|
||||||
|
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
|
||||||
|
@ -134,11 +143,21 @@ export class HugoRelease implements IGithubRelease {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assetUrl(platform: Platform, extended?: boolean): string | undefined {
|
assetUrl(
|
||||||
const src = extended ? this.extendedAssets : this.defaultAssets
|
platform: Platform,
|
||||||
|
extended?: boolean,
|
||||||
|
withDeploy?: boolean
|
||||||
|
): string | undefined {
|
||||||
|
let assets = this.defaultAssets
|
||||||
|
if (withDeploy) {
|
||||||
|
assets = this.withDeployAssets
|
||||||
|
} else if (extended) {
|
||||||
|
assets = this.extendedAssets
|
||||||
|
}
|
||||||
|
|
||||||
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 src.get(key)
|
return assets.get(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ 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