This commit is contained in:
Arnaud Levy 2025-04-13 10:10:22 +00:00 committed by GitHub
commit 3232f95c9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 54 additions and 27 deletions

View File

@ -21,6 +21,9 @@ jobs:
extended: extended:
- true - true
- false - false
withdeploy:
- true
- false
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -29,6 +32,7 @@ jobs:
with: with:
hugo-version: ${{ matrix.hugo-version }} hugo-version: ${{ matrix.hugo-version }}
extended: ${{ matrix.extended }} extended: ${{ matrix.extended }}
withdeploy: ${{ matrix.withdeploy }}
- name: Run hugo version - name: Run hugo version
run: echo "::set-output name=hugo_version::$(hugo version)" run: echo "::set-output name=hugo_version::$(hugo version)"

View File

@ -123,10 +123,23 @@ Set `extended: true` to use a Hugo extended version.
- name: Setup Hugo - name: Setup Hugo
uses: peaceiris/actions-hugo@v3 uses: peaceiris/actions-hugo@v3
with: with:
hugo-version: '0.119.0' hugo-version: '0.137.0'
extended: true extended: true
``` ```
### ⭐️ Use Hugo withdeploy
Set `withdeploy: true` to use a Hugo with deploy feature.
Since [v0.137.0](https://github.com/gohugoio/hugo/releases/tag/v0.137.0), the deploy feature is not in the default archive anymore.
```yaml
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.137.0'
withdeploy: true
```
### ⭐️ Use the latest version of Hugo ### ⭐️ Use the latest version of Hugo
Set `hugo-version: 'latest'` to use the latest version of Hugo. Set `hugo-version: 'latest'` to use the latest version of Hugo.

View File

@ -1,5 +1,5 @@
name: 'Hugo setup' name: 'Hugo setup'
description: 'GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended and Hugo Modules are supported.' description: 'GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended, Hugo deploy and Hugo Modules are supported.'
author: 'peaceiris' author: 'peaceiris'
inputs: inputs:
hugo-version: hugo-version:
@ -10,6 +10,10 @@ inputs:
description: 'Download (if necessary) and use Hugo extended version. Example: true' description: 'Download (if necessary) and use Hugo extended version. Example: true'
required: false required: false
default: 'false' default: 'false'
withdeploy:
description: 'Download (if necessary) and use Hugo deploy feature. Example: true'
required: false
default: 'false'
runs: runs:
using: 'node20' using: 'node20'
main: 'lib/index.js' main: 'lib/index.js'

View File

@ -1,6 +1,6 @@
{ {
"name": "actions-hugo", "name": "actions-hugo",
"version": "3.0.0", "version": "3.0.1",
"description": "GitHub Actions for Hugo", "description": "GitHub Actions for Hugo",
"main": "lib/index.js", "main": "lib/index.js",
"engines": { "engines": {

View File

@ -1,30 +1,30 @@
export default function getURL( export default function getURL(
os: string, system: {
arch: string, os: string,
extended: string, arch: string,
version: string },
options: {
extended: string,
withdeploy: string,
version: string
}
): string { ): string {
const extendedStr = (extended: string): string => { let withdeployStr = '';
if (extended === 'true') { if (options.withdeploy === 'true') {
return 'extended_'; withdeployStr = 'withdeploy_';
} else { }
return ''; let extendedStr = '';
// } else { if (options.extended === 'true' || withdeployStr) {
// throw new Error(`Invalid input (extended): ${extended}`); extendedStr = 'extended_';
} }
}; let ext = 'tar.gz';
if (system.os === 'Windows') {
ext = 'zip';
}
const ext = (os: string): string => { const hugoName = `hugo_${extendedStr}${withdeployStr}${options.version}_${system.os}-${system.arch}`;
if (os === 'Windows') {
return 'zip';
} else {
return 'tar.gz';
}
};
const hugoName = `hugo_${extendedStr(extended)}${version}_${os}-${arch}`;
const baseURL = 'https://github.com/gohugoio/hugo/releases/download'; const baseURL = 'https://github.com/gohugoio/hugo/releases/download';
const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`; const url = `${baseURL}/v${options.version}/${hugoName}.${ext}`;
return url; return url;
} }

View File

@ -47,13 +47,19 @@ 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 withdeploy: string = core.getInput('withdeploy');
core.debug(`Hugo withdeploy: ${withdeploy}`);
const osName: string = getOS(process.platform); const osName: string = getOS(process.platform);
core.debug(`Operating System: ${osName}`); core.debug(`Operating System: ${osName}`);
const archName: string = getArch(process.arch); const archName: string = getArch(process.arch);
core.debug(`Processor Architecture: ${archName}`); core.debug(`Processor Architecture: ${archName}`);
const toolURL: string = getURL(osName, archName, extended, version); const system = { os: osName, arch: archName };
const options = { extended: extended, withdeploy: withdeploy, version: version }
const toolURL: string = getURL(system, options);
core.debug(`toolURL: ${toolURL}`); core.debug(`toolURL: ${toolURL}`);
const workDir = await createWorkDir(); const workDir = await createWorkDir();