diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 24cca3d..2f67904 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -59,6 +59,7 @@ jobs: with: extended: true dart-sass: true + with-deploy: true - name: Test installed tools id: test-tools diff --git a/action.yml b/action.yml index 60d220d..c937289 100644 --- a/action.yml +++ b/action.yml @@ -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: diff --git a/src/hugo.ts b/src/hugo.ts index 2286525..3a8281c 100644 --- a/src/hugo.ts +++ b/src/hugo.ts @@ -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 private readonly extendedAssets: Map + private readonly withDeployAssets: Map constructor( tag_name: string, @@ -118,9 +121,15 @@ export class HugoRelease implements IGithubRelease { this.tag_name = tag_name this.defaultAssets = new Map() this.extendedAssets = new Map() + this.withDeployAssets = new Map() 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) } } diff --git a/src/main.ts b/src/main.ts index 99ec8d2..01906e4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,8 @@ export async function run(): Promise { 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