feat: support with deploy option
Some checks failed
Check Transpiled JavaScript / Check dist/ (push) Failing after 38s
Continuous Integration / GitHub Actions Test (push) Successful in 9s
Continuous Integration / TypeScript Tests (push) Successful in 52s
Renovate / renovate (push) Successful in 56s

This commit is contained in:
Peter 2024-11-27 20:14:56 +01:00
parent 910d150813
commit 10b6b9aa45
Signed by: prskr
GPG key ID: F56BED6903BC5E37
4 changed files with 34 additions and 7 deletions

View file

@ -59,6 +59,7 @@ jobs:
with:
extended: true
dart-sass: true
with-deploy: true
- name: Test installed tools
id: test-tools

View file

@ -15,6 +15,12 @@ inputs:
description: 'Download (if necessary) dart-sass'
required: 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:
description:
'The dart-sass version to download.ts (if necessary) and use. Example:

View file

@ -13,6 +13,7 @@ import { errorMsg } from './utils/error'
export interface IHugoInstallCommand {
version?: string
extended?: boolean
withDeploy?: boolean
}
export class HugoInstaller {
@ -32,7 +33,8 @@ export class HugoInstaller {
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(`Processor Architecture: ${this.platform.arch}`)
@ -103,13 +105,14 @@ export const HugoReleaseTransformer = {
export class HugoRelease implements IGithubRelease {
private static readonly keyReplacementRegex = new RegExp(
'hugo_(extended_)*(\\d+.\\d+.\\d+)_'
'hugo_(extended_)*(withdeploy_)*(\\d+.\\d+.\\d+)_'
)
readonly tag_name: string
private readonly defaultAssets: Map<string, string>
private readonly extendedAssets: Map<string, string>
private readonly withDeployAssets: Map<string, string>
constructor(
tag_name: string,
@ -118,9 +121,15 @@ export class HugoRelease implements IGithubRelease {
this.tag_name = tag_name
this.defaultAssets = new Map<string, string>()
this.extendedAssets = new Map<string, string>()
this.withDeployAssets = new Map<string, string>()
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(
asset.name.replace(HugoRelease.keyReplacementRegex, ''),
asset.browser_download_url
@ -134,11 +143,21 @@ export class HugoRelease implements IGithubRelease {
}
}
assetUrl(platform: Platform, extended?: boolean): string | undefined {
const src = extended ? this.extendedAssets : this.defaultAssets
assetUrl(
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 key = `${platform.os}-${arch}${platform.archiveExtension()}`
return src.get(key)
return assets.get(key)
}
}

View file

@ -11,7 +11,8 @@ export async function run(): Promise<void> {
await hugoInstaller.install({
version: core.getInput('hugo-version'),
extended: core.getBooleanInput('extended')
extended: core.getBooleanInput('extended'),
withDeploy: core.getBooleanInput('with-deploy')
})
if (!core.getBooleanInput('dart-sass')) return