From 153e0fe512e5ed7793f9cc407584103ed340816f Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 5 Nov 2024 08:15:12 +0100 Subject: [PATCH 1/3] rough add withdeploy --- .github/workflows/test-action.yml | 4 ++++ README.md | 15 ++++++++++++++- action.yml | 6 +++++- package.json | 2 +- src/get-url.ts | 13 ++++++++++++- src/installer.ts | 5 ++++- 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 7ca1b43a..0b7abca8 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -21,6 +21,9 @@ jobs: extended: - true - false + withdeploy: + - true + - false steps: - uses: actions/checkout@v4 @@ -29,6 +32,7 @@ jobs: with: hugo-version: ${{ matrix.hugo-version }} extended: ${{ matrix.extended }} + withdeploy: ${{ matrix.withdeploy }} - name: Run hugo version run: echo "::set-output name=hugo_version::$(hugo version)" diff --git a/README.md b/README.md index 9a7750ea..f163d903 100644 --- a/README.md +++ b/README.md @@ -123,10 +123,23 @@ Set `extended: true` to use a Hugo extended version. - name: Setup Hugo uses: peaceiris/actions-hugo@v3 with: - hugo-version: '0.119.0' + hugo-version: '0.137.0' 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 Set `hugo-version: 'latest'` to use the latest version of Hugo. diff --git a/action.yml b/action.yml index 8dcf0cb2..c0bb2854 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ 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' inputs: hugo-version: @@ -10,6 +10,10 @@ inputs: description: 'Download (if necessary) and use Hugo extended version. Example: true' required: false default: 'false' + withdeploy: + description: 'Download (if necessary) and use Hugo deploy feature. Example: true' + required: false + default: 'false' runs: using: 'node20' main: 'lib/index.js' diff --git a/package.json b/package.json index e9ea0251..2de6f69b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "actions-hugo", - "version": "3.0.0", + "version": "3.0.1", "description": "GitHub Actions for Hugo", "main": "lib/index.js", "engines": { diff --git a/src/get-url.ts b/src/get-url.ts index 63f580c7..2a106c42 100644 --- a/src/get-url.ts +++ b/src/get-url.ts @@ -2,6 +2,7 @@ export default function getURL( os: string, arch: string, extended: string, + withdeploy: string, version: string ): string { const extendedStr = (extended: string): string => { @@ -14,6 +15,16 @@ export default function getURL( } }; + const withdeployStr = (withdeploy: string): string => { + if (withdeploy === 'true') { + return 'withdeploy_'; + } else { + return ''; + // } else { + // throw new Error(`Invalid input (withdeploy): ${withdeploy}`); + } + }; + const ext = (os: string): string => { if (os === 'Windows') { return 'zip'; @@ -22,7 +33,7 @@ export default function getURL( } }; - const hugoName = `hugo_${extendedStr(extended)}${version}_${os}-${arch}`; + const hugoName = `hugo_${extendedStr(extended)}${withdeployStr(withdeploy)}${version}_${os}-${arch}`; const baseURL = 'https://github.com/gohugoio/hugo/releases/download'; const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`; diff --git a/src/installer.ts b/src/installer.ts index e3dfd358..9a22f1ef 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -47,13 +47,16 @@ export async function installer(version: string): Promise { const extended: string = core.getInput('extended'); core.debug(`Hugo extended: ${extended}`); + const withdeploy: string = core.getInput('withdeploy'); + core.debug(`Hugo withdeploy: ${withdeploy}`); + const osName: string = getOS(process.platform); core.debug(`Operating System: ${osName}`); const archName: string = getArch(process.arch); core.debug(`Processor Architecture: ${archName}`); - const toolURL: string = getURL(osName, archName, extended, version); + const toolURL: string = getURL(osName, archName, extended, withdeploy, version); core.debug(`toolURL: ${toolURL}`); const workDir = await createWorkDir(); From c6275e7b7cd1d86c2a2bf72134849d0ce9803cb9 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 5 Nov 2024 08:43:45 +0100 Subject: [PATCH 2/3] climate --- src/get-url.ts | 57 +++++++++++++++++++----------------------------- src/installer.ts | 5 ++++- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/get-url.ts b/src/get-url.ts index 2a106c42..f6a07cca 100644 --- a/src/get-url.ts +++ b/src/get-url.ts @@ -1,41 +1,30 @@ export default function getURL( - os: string, - arch: string, - extended: string, - withdeploy: string, - version: string + system: { + os: string, + arch: string, + }, + options: { + extended: string, + withdeploy: string, + version: string + } ): string { - const extendedStr = (extended: string): string => { - if (extended === 'true') { - return 'extended_'; - } else { - return ''; - // } else { - // throw new Error(`Invalid input (extended): ${extended}`); - } - }; + let extendedStr = ''; + if (options.extended === 'true') { + extendedStr = 'extended_'; + } + let withdeployStr = ''; + if (options..withdeploy === 'true') { + withdeployStr = 'withdeploy_'; + } + let ext = 'tar.gz'; + if (system.os === 'Windows') { + ext = 'zip'; + } - const withdeployStr = (withdeploy: string): string => { - if (withdeploy === 'true') { - return 'withdeploy_'; - } else { - return ''; - // } else { - // throw new Error(`Invalid input (withdeploy): ${withdeploy}`); - } - }; - - const ext = (os: string): string => { - if (os === 'Windows') { - return 'zip'; - } else { - return 'tar.gz'; - } - }; - - const hugoName = `hugo_${extendedStr(extended)}${withdeployStr(withdeploy)}${version}_${os}-${arch}`; + const hugoName = `hugo_${extendedStr}${withdeployStr}${options.version}_${system.os}-${system.arch}`; 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; } diff --git a/src/installer.ts b/src/installer.ts index 9a22f1ef..fe761ad3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -56,7 +56,10 @@ export async function installer(version: string): Promise { const archName: string = getArch(process.arch); core.debug(`Processor Architecture: ${archName}`); - const toolURL: string = getURL(osName, archName, extended, withdeploy, 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}`); const workDir = await createWorkDir(); From 6191baf0ccb55697cc1655a2fc5522e3c57c319f Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 5 Nov 2024 09:07:35 +0100 Subject: [PATCH 3/3] Update get-url.ts --- src/get-url.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/get-url.ts b/src/get-url.ts index f6a07cca..b150f493 100644 --- a/src/get-url.ts +++ b/src/get-url.ts @@ -14,7 +14,7 @@ export default function getURL( extendedStr = 'extended_'; } let withdeployStr = ''; - if (options..withdeploy === 'true') { + if (options.withdeploy === 'true') { withdeployStr = 'withdeploy_'; } let ext = 'tar.gz';