Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rough add withdeploy #659

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
extended:
- true
- false
withdeploy:
- true
- false
steps:
- uses: actions/checkout@v4

Expand All @@ -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)"
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
46 changes: 23 additions & 23 deletions src/get-url.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
export default function getURL(
os: string,
arch: string,
extended: 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 ext = (os: string): string => {
if (os === 'Windows') {
return 'zip';
} else {
return 'tar.gz';
}
};

const hugoName = `hugo_${extendedStr(extended)}${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;
}
8 changes: 7 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ export async function installer(version: string): Promise<void> {
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 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();
Expand Down