mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-09-22 19:25:01 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b7aa41d20 |
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"commonjs": true,
|
||||||
|
"es6": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:jest/recommended"
|
||||||
|
],
|
||||||
|
"globals": {
|
||||||
|
"Atomics": "readonly",
|
||||||
|
"SharedArrayBuffer": "readonly"
|
||||||
|
},
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaVersion": 2019
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
## Summary
|
|
||||||
|
|
||||||
<!-- Describe what this pull request changes and why. -->
|
|
||||||
|
|
||||||
## Changes
|
|
||||||
|
|
||||||
<!-- List the notable changes. -->
|
|
||||||
|
|
||||||
-
|
|
||||||
|
|
||||||
## Checklist
|
|
||||||
|
|
||||||
- [ ] I have read the latest README and followed the instructions.
|
|
||||||
- [ ] I have added or updated tests for behavior changes.
|
|
||||||
- [ ] I have updated README.md and action.yml when inputs or runtime behavior changed.
|
|
||||||
- [ ] I have run the relevant verification commands.
|
|
||||||
|
|
||||||
## Verification
|
|
||||||
|
|
||||||
<!-- List the commands you ran and their results. -->
|
|
||||||
|
|
||||||
- [ ] `npm run all`
|
|
||||||
- [ ] `npm run build`
|
|
||||||
@@ -6,23 +6,24 @@ on:
|
|||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
security-events: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
CodeQL-Build:
|
CodeQL-Build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
uses: github/codeql-action/init@1521896cd211af95be3f02edf6f436e10b819c27 # v3.35.4
|
||||||
with:
|
with:
|
||||||
languages: javascript
|
languages: javascript
|
||||||
|
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
uses: github/codeql-action/autobuild@1521896cd211af95be3f02edf6f436e10b819c27 # v3.35.4
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
uses: github/codeql-action/analyze@1521896cd211af95be3f02edf6f436e10b819c27 # v3.35.4
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
dependency-review:
|
dependency-review:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 5
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
- uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
|
||||||
|
|||||||
@@ -21,14 +21,15 @@ on:
|
|||||||
- 'Dockerfile'
|
- 'Dockerfile'
|
||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
dev-image-test:
|
dev-image-test:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 20
|
timeout-minutes: 30
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
- run: make build
|
- run: make build
|
||||||
- run: make cirun cmd="npm ci"
|
- run: make cirun cmd="npm ci"
|
||||||
# - run: make ciall
|
# - run: make ciall
|
||||||
|
|||||||
@@ -10,20 +10,21 @@ on:
|
|||||||
# - labeled
|
# - labeled
|
||||||
# - unlabeled
|
# - unlabeled
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
comment:
|
comment:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 5
|
timeout-minutes: 10
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
issues: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
- name: Label Commenter
|
- name: Label Commenter
|
||||||
uses: peaceiris/actions-label-commenter@f0dbbef043eb1b150b566db36b0bdc8b7f505579 # v1.10.0
|
uses: peaceiris/actions-label-commenter@c74c602750041f04c2bb68d200fc2fdae169a044 # v1.10.0
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# config_file: .github/label-commenter-config.yml
|
# config_file: .github/label-commenter-config.yml
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '4 18 * * */7'
|
- cron: '4 18 * * */7'
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
purge:
|
purge:
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
permissions: {}
|
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- name: Purge README image cache
|
||||||
|
run: >
|
||||||
curl -sL "https://github.com/${GITHUB_REPOSITORY}" |
|
curl -sL "https://github.com/${GITHUB_REPOSITORY}" |
|
||||||
grep -oE '<img src="https?://camo.githubusercontent.com/[^"]+' |
|
grep -oE '<img src="https?://camo.githubusercontent.com/[^"]+' |
|
||||||
sed -e 's/<img src="//' |
|
sed -e 's/<img src="//' |
|
||||||
xargs -r -I % curl -sX PURGE %
|
xargs -I % curl -sX PURGE %
|
||||||
|
|||||||
@@ -5,24 +5,15 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Dump GitHub context
|
|
||||||
env:
|
|
||||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
||||||
run: echo "${GITHUB_CONTEXT}"
|
|
||||||
|
|
||||||
- name: Install github/hub
|
|
||||||
run: |
|
|
||||||
export HUB_VERSION="2.14.2"
|
|
||||||
curl -fsSL https://github.com/github/hub/raw/8d91904208171b013f9a9d1175f4ab39068db047/script/get | bash -s "${HUB_VERSION}"
|
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
@@ -32,8 +23,8 @@ jobs:
|
|||||||
echo "See [CHANGELOG.md](https://github.com/${GITHUB_REPOSITORY}/blob/${TAG_NAME}/CHANGELOG.md) for more details." > ./release_notes.md
|
echo "See [CHANGELOG.md](https://github.com/${GITHUB_REPOSITORY}/blob/${TAG_NAME}/CHANGELOG.md) for more details." > ./release_notes.md
|
||||||
RELEASE_NAME="$(jq -r '.name' ./package.json)"
|
RELEASE_NAME="$(jq -r '.name' ./package.json)"
|
||||||
sed -i "1i${RELEASE_NAME} ${TAG_NAME}\n" ./release_notes.md
|
sed -i "1i${RELEASE_NAME} ${TAG_NAME}\n" ./release_notes.md
|
||||||
./bin/hub release create \
|
gh release create "${TAG_NAME}" \
|
||||||
--draft \
|
--draft \
|
||||||
--prerelease \
|
--prerelease \
|
||||||
--file ./release_notes.md \
|
--notes-file ./release_notes.md \
|
||||||
"${TAG_NAME}"
|
--title "${RELEASE_NAME} ${TAG_NAME}"
|
||||||
|
|||||||
@@ -6,21 +6,31 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 10
|
timeout-minutes: 20
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
hugo-version: ['latest', '0.160.1']
|
hugo-version: ['latest', '0.160.1']
|
||||||
extended: [true, false]
|
extended: [true, false]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
|
||||||
|
- run: npm run build
|
||||||
|
|
||||||
- name: Setup Hugo
|
- name: Setup Hugo
|
||||||
uses: peaceiris/actions-hugo@2752ce1d29631191ea3f27c23495fa06139a5b78 # v3.2.1
|
uses: ./
|
||||||
with:
|
with:
|
||||||
hugo-version: ${{ matrix.hugo-version }}
|
hugo-version: ${{ matrix.hugo-version }}
|
||||||
extended: ${{ matrix.extended }}
|
extended: ${{ matrix.extended }}
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 20
|
timeout-minutes: 30
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -24,9 +25,9 @@ jobs:
|
|||||||
- 'macos-latest'
|
- 'macos-latest'
|
||||||
- 'windows-latest'
|
- 'windows-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version-file: '.nvmrc'
|
node-version-file: '.nvmrc'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
@@ -48,9 +49,9 @@ jobs:
|
|||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
||||||
- name: Upload test coverage as artifact
|
- name: Upload test coverage as artifact
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: coverage-${{ matrix.os }}
|
name: coverage-${{ matrix.os }}
|
||||||
path: coverage
|
path: coverage
|
||||||
|
|
||||||
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
- uses: codecov/codecov-action@aa56896cf108bd10b5eb883cd1d24196da57f695 # v5.5.4
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ on:
|
|||||||
release:
|
release:
|
||||||
types: [released]
|
types: [released]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Update major tag
|
- name: Update major tag
|
||||||
run: |
|
run: |
|
||||||
git config user.name "${GITHUB_ACTOR}"
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
|
|
||||||
export TAG_NAME="${GITHUB_REF##refs/tags/}"
|
export TAG_NAME="${GITHUB_REF##refs/tags/}"
|
||||||
export TAG_MAJOR="${TAG_NAME%%.*}"
|
export TAG_MAJOR="${TAG_NAME%%.*}"
|
||||||
git tag --force -a "${TAG_MAJOR}" -m "Release ${TAG_NAME}"
|
git tag --force -a "${TAG_MAJOR}" -m "Release ${TAG_NAME}"
|
||||||
|
|||||||
@@ -4,4 +4,3 @@ coverage
|
|||||||
.eslintcache
|
.eslintcache
|
||||||
.env
|
.env
|
||||||
node_modules
|
node_modules
|
||||||
.codex/
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ This repository contains a TypeScript GitHub Action for installing Hugo. Runtime
|
|||||||
- `npm test`: run Jest with coverage and verbose output.
|
- `npm test`: run Jest with coverage and verbose output.
|
||||||
- `npm run lint` / `npm run lint:fix`: check or fix TypeScript lint issues.
|
- `npm run lint` / `npm run lint:fix`: check or fix TypeScript lint issues.
|
||||||
- `npm run format:check` / `npm run format`: check or apply Prettier formatting for `*.ts`.
|
- `npm run format:check` / `npm run format`: check or apply Prettier formatting for `*.ts`.
|
||||||
- `npm run build`: bundle `src/index.ts` into `lib/` with `ncc`; do not regenerate `lib/index.js` except for release work.
|
- `npm run build`: bundle `src/index.ts` into `lib/` with `ncc`.
|
||||||
- `make build`, `make test`, `make all`: run the Docker-based development image and test flow.
|
- `make build`, `make test`, `make all`: run the Docker-based development image and test flow.
|
||||||
|
|
||||||
## Coding Style & Naming Conventions
|
## Coding Style & Naming Conventions
|
||||||
|
|||||||
@@ -2,78 +2,6 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
## [3.2.1](https://github.com/peaceiris/actions-hugo/compare/v3.2.0...v3.2.1) (2026-05-10)
|
|
||||||
|
|
||||||
|
|
||||||
### fix
|
|
||||||
|
|
||||||
* handle Hugo 0.139.5 archive fallback (#696) ([4e5bf41](https://github.com/peaceiris/actions-hugo/commit/4e5bf412f00ba628ed366436825de7226933f80d)), closes [#696](https://github.com/peaceiris/actions-hugo/issues/696)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [3.2.0](https://github.com/peaceiris/actions-hugo/compare/v3.1.0...v3.2.0) (2026-05-10)
|
|
||||||
|
|
||||||
|
|
||||||
### build
|
|
||||||
|
|
||||||
* update npm dependencies (#689) ([189731e](https://github.com/peaceiris/actions-hugo/commit/189731ef0083fa5500ca268865b02bd8eb3e7050)), closes [#689](https://github.com/peaceiris/actions-hugo/issues/689)
|
|
||||||
|
|
||||||
### chore
|
|
||||||
|
|
||||||
* delete lib/index.js ([8a69ba5](https://github.com/peaceiris/actions-hugo/commit/8a69ba55a596c78f65c6feef166e2eb2aebc2f2f))
|
|
||||||
|
|
||||||
### ci
|
|
||||||
|
|
||||||
* bump actions/checkout from 4.3.1 to 6.0.2 (#691) ([71c032c](https://github.com/peaceiris/actions-hugo/commit/71c032c9dcb44d6b93dd8910811cb1b6ea450bd5)), closes [#691](https://github.com/peaceiris/actions-hugo/issues/691)
|
|
||||||
* bump actions/setup-node from 4.4.0 to 6.4.0 (#690) ([66080d4](https://github.com/peaceiris/actions-hugo/commit/66080d4abbf3e0d1bcfc83914cbbb18f90efcf00)), closes [#690](https://github.com/peaceiris/actions-hugo/issues/690) [actions/setup-node#1525](https://github.com/actions/setup-node/issues/1525) [actions/setup-node#1533](https://github.com/actions/setup-node/issues/1533) [actions/setup-node#1525](https://github.com/actions/setup-node/issues/1525) [actions/setup-node#1283](https://github.com/actions/setup-node/issues/1283) [actions/setup-node#1491](https://github.com/actions/setup-node/issues/1491) [actions/setup-node#1378](https://github.com/actions/setup-node/issues/1378) [actions/setup-node#1498](https://github.com/actions/setup-node/issues/1498) [actions/setup-node#1467](https://github.com/actions/setup-node/issues/1467) [actions/setup-node#1495](https://github.com/actions/setup-node/issues/1495) [actions/setup-node#1283](https://github.com/actions/setup-node/issues/1283) [actions/setup-node#1454](https://github.com/actions/setup-node/issues/1454) [actions/setup-node#1442](https://github.com/actions/setup-node/issues/1442) [actions/setup-node#1446](https://github.com/actions/setup-node/issues/1446) [actions/setup-node#1226](https://github.com/actions/setup-node/issues/1226) [actions/setup-node#1468](https://github.com/actions/setup-node/issues/1468) [actions/setup-node#1449](https://github.com/actions/setup-node/issues/1449) [actions/setup-node#1454](https://github.com/actions/setup-node/issues/1454) [actions/setup-node#1442](https://github.com/actions/setup-node/issues/1442) [actions/setup-node#1446](https://github.com/actions/setup-node/issues/1446) [#1533](https://github.com/peaceiris/actions-hugo/issues/1533) [#1525](https://github.com/peaceiris/actions-hugo/issues/1525) [#1498](https://github.com/peaceiris/actions-hugo/issues/1498) [#1495](https://github.com/peaceiris/actions-hugo/issues/1495) [#1378](https://github.com/peaceiris/actions-hugo/issues/1378) [#1283](https://github.com/peaceiris/actions-hugo/issues/1283) [#1467](https://github.com/peaceiris/actions-hugo/issues/1467) [#1491](https://github.com/peaceiris/actions-hugo/issues/1491) [#1468](https://github.com/peaceiris/actions-hugo/issues/1468) [#1226](https://github.com/peaceiris/actions-hugo/issues/1226)
|
|
||||||
* bump actions/upload-artifact from 4.6.2 to 7.0.1 (#692) ([27f9d4a](https://github.com/peaceiris/actions-hugo/commit/27f9d4ab073f98ceaee353f893283fd6da81cb6d)), closes [#692](https://github.com/peaceiris/actions-hugo/issues/692)
|
|
||||||
* bump github/codeql-action from 3.35.4 to 4.35.4 (#694) ([681f914](https://github.com/peaceiris/actions-hugo/commit/681f914d18cf3aefb972de7c4f1ac75dfff38e5d)), closes [#694](https://github.com/peaceiris/actions-hugo/issues/694)
|
|
||||||
* bump peaceiris/actions-hugo from 3.0.0 to 3.1.0 (#693) ([7c673b8](https://github.com/peaceiris/actions-hugo/commit/7c673b8b9ebc5b359f3f4dd4eca150830f1fea5e)), closes [#693](https://github.com/peaceiris/actions-hugo/issues/693)
|
|
||||||
|
|
||||||
### docs
|
|
||||||
|
|
||||||
* add pull request template ([d488e4d](https://github.com/peaceiris/actions-hugo/commit/d488e4d9876f0cb74ace1aac7bbf14fcf52868d9))
|
|
||||||
* document build artifact constraint ([e3c35ac](https://github.com/peaceiris/actions-hugo/commit/e3c35ac635d46e1fc932dd524c5490fff7d235a9))
|
|
||||||
|
|
||||||
### feat
|
|
||||||
|
|
||||||
* support renamed Hugo release assets (#687) ([187a5ef](https://github.com/peaceiris/actions-hugo/commit/187a5efe8178fbcd0f0969d3db97b33d4f89d8ab)), closes [#687](https://github.com/peaceiris/actions-hugo/issues/687)
|
|
||||||
|
|
||||||
### fix
|
|
||||||
|
|
||||||
* Hugo package naming fix (#688) ([b1937e1](https://github.com/peaceiris/actions-hugo/commit/b1937e141c2b829e9913293bb8044aec5ef28dd2)), closes [#688](https://github.com/peaceiris/actions-hugo/issues/688) [#609](https://github.com/peaceiris/actions-hugo/issues/609) [#687](https://github.com/peaceiris/actions-hugo/issues/687)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [3.1.0](https://github.com/peaceiris/actions-hugo/compare/v3.0.0...v3.1.0) (2026-05-10)
|
|
||||||
|
|
||||||
|
|
||||||
### chore
|
|
||||||
|
|
||||||
* add .codex/ ([fd1a667](https://github.com/peaceiris/actions-hugo/commit/fd1a6670898ca2ebf1a2c7f921f3eaf59eb75878))
|
|
||||||
|
|
||||||
### ci
|
|
||||||
|
|
||||||
* bump actions/dependency-review-action from 3 to 4 (#656) ([711df4e](https://github.com/peaceiris/actions-hugo/commit/711df4ed6415b013fd3ce424f98c5720d36d19e0)), closes [#656](https://github.com/peaceiris/actions-hugo/issues/656)
|
|
||||||
* bump actions/upload-artifact from 3 to 4 (#654) ([764796d](https://github.com/peaceiris/actions-hugo/commit/764796d276c5a0094764d3fb3fbc3bb6fefb19e6)), closes [#654](https://github.com/peaceiris/actions-hugo/issues/654)
|
|
||||||
* bump codecov/codecov-action from 3 to 4 (#655) ([e177dc3](https://github.com/peaceiris/actions-hugo/commit/e177dc33cb0d5866aa77a82d4cdfdda3a5cd76a3)), closes [#655](https://github.com/peaceiris/actions-hugo/issues/655)
|
|
||||||
* bump codecov/codecov-action from 4 to 5 (#660) ([3a28794](https://github.com/peaceiris/actions-hugo/commit/3a287949d38134f0920e6ac20032acef6d4a23c4)), closes [#660](https://github.com/peaceiris/actions-hugo/issues/660)
|
|
||||||
* bump github/codeql-action from 2 to 3 (#657) ([9d57878](https://github.com/peaceiris/actions-hugo/commit/9d57878417d5429540d059b1dbf19e0717797912)), closes [#657](https://github.com/peaceiris/actions-hugo/issues/657)
|
|
||||||
* bump peaceiris/actions-hugo from 2.6.0 to 3.0.0 (#653) ([3b44307](https://github.com/peaceiris/actions-hugo/commit/3b443076f02aa9537a31bdcaa0c971cdd41eb022)), closes [#653](https://github.com/peaceiris/actions-hugo/issues/653)
|
|
||||||
* harden workflows and update Node.js (#686) ([64e0f66](https://github.com/peaceiris/actions-hugo/commit/64e0f66acbd8b134359e19b06e518ceb2734de14)), closes [#686](https://github.com/peaceiris/actions-hugo/issues/686)
|
|
||||||
|
|
||||||
### docs
|
|
||||||
|
|
||||||
* add contributor guidelines ([ba5146c](https://github.com/peaceiris/actions-hugo/commit/ba5146cb8a90074a91c351b17a4206ffd8594cd5))
|
|
||||||
* add env.HUGO_CACHEDIR (#650) ([288264f](https://github.com/peaceiris/actions-hugo/commit/288264f9c9c4a54b634fdbfdc119faefe699d549)), closes [#650](https://github.com/peaceiris/actions-hugo/issues/650)
|
|
||||||
* bump actions/cache to v4 ([7db63f5](https://github.com/peaceiris/actions-hugo/commit/7db63f5e7f65f5c06a64fd56106389606f84a976))
|
|
||||||
|
|
||||||
### feat
|
|
||||||
|
|
||||||
* upgrade action runtime from Node 20 to 24 (#684) ([83259d8](https://github.com/peaceiris/actions-hugo/commit/83259d800c0f56b05d14cb0b320d8e4034770d68)), closes [#684](https://github.com/peaceiris/actions-hugo/issues/684)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [3.0.0](https://github.com/peaceiris/actions-hugo/compare/v2.6.0...v3.0.0) (2024-04-02)
|
# [3.0.0](https://github.com/peaceiris/actions-hugo/compare/v2.6.0...v3.0.0) (2024-04-02)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
ARG NODE_VERSION=24.15.0
|
ARG NODE_VERSION
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-bookworm-slim
|
FROM node:${NODE_VERSION}-buster-slim
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-l", "-c"]
|
SHELL ["/bin/bash", "-l", "-c"]
|
||||||
|
|
||||||
|
|||||||
+10
-130
@@ -1,135 +1,15 @@
|
|||||||
import getArch from '../src/get-arch';
|
import getArch from '../src/get-arch';
|
||||||
|
|
||||||
describe('getArch', () => {
|
describe('getArch', () => {
|
||||||
const groups = [
|
test('processor architecture', () => {
|
||||||
{
|
expect(getArch('x64')).toBe('64bit');
|
||||||
condition: 'when hugo version < 0.102.0',
|
expect(getArch('arm')).toBe('ARM');
|
||||||
conventions: {
|
expect(getArch('arm64')).toBe('ARM64');
|
||||||
arch: {
|
});
|
||||||
darwinUniversal: false,
|
|
||||||
droppedWindowsArmSupport: false,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [
|
|
||||||
{arch: 'x64', os: 'linux', expected: '64bit'},
|
|
||||||
{arch: 'x64', os: 'darwin', expected: '64bit'},
|
|
||||||
{arch: 'x64', os: 'macOS', expected: '64bit'},
|
|
||||||
{arch: 'x64', os: 'windows', expected: '64bit'},
|
|
||||||
{arch: 'arm', os: 'linux', expected: 'ARM'},
|
|
||||||
{arch: 'arm', os: 'darwin', expected: 'ARM'},
|
|
||||||
{arch: 'arm', os: 'macOS', expected: 'ARM'},
|
|
||||||
{arch: 'arm', os: 'windows', expected: 'ARM'},
|
|
||||||
{arch: 'arm64', os: 'linux', expected: 'ARM64'},
|
|
||||||
{arch: 'arm64', os: 'darwin', expected: 'ARM64'},
|
|
||||||
{arch: 'arm64', os: 'macOS', expected: 'ARM64'},
|
|
||||||
{arch: 'arm64', os: 'windows', expected: 'ARM64'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when hugo version === 0.102.z',
|
|
||||||
conventions: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: true,
|
|
||||||
droppedWindowsArmSupport: true,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [
|
|
||||||
{arch: 'x64', os: 'linux', expected: '64bit'},
|
|
||||||
{arch: 'x64', os: 'macOS', expected: 'universal'},
|
|
||||||
{arch: 'x64', os: 'windows', expected: '64bit'},
|
|
||||||
{arch: 'arm', os: 'linux', expected: 'ARM'},
|
|
||||||
{arch: 'arm', os: 'macOS', expected: 'universal'},
|
|
||||||
{arch: 'arm', os: 'windows', throws: true},
|
|
||||||
{arch: 'arm64', os: 'linux', expected: 'ARM64'},
|
|
||||||
{arch: 'arm64', os: 'macOS', expected: 'universal'},
|
|
||||||
{arch: 'arm64', os: 'windows', expected: 'ARM64'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when hugo version >= 0.103.0',
|
|
||||||
conventions: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: true,
|
|
||||||
droppedWindowsArmSupport: true,
|
|
||||||
standardizedNaming: true
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: true,
|
|
||||||
downcasedAll: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [
|
|
||||||
{arch: 'x64', os: 'linux', expected: 'amd64'},
|
|
||||||
{arch: 'x64', os: 'macOS', expected: 'universal'},
|
|
||||||
{arch: 'x64', os: 'windows', expected: 'amd64'},
|
|
||||||
{arch: 'arm', os: 'linux', expected: 'arm'},
|
|
||||||
{arch: 'arm', os: 'macOS', expected: 'universal'},
|
|
||||||
{arch: 'arm', os: 'windows', throws: true},
|
|
||||||
{arch: 'arm64', os: 'linux', expected: 'arm64'},
|
|
||||||
{arch: 'arm64', os: 'macOS', expected: 'universal'},
|
|
||||||
{arch: 'arm64', os: 'windows', expected: 'arm64'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when the architecture is unsupported for the action',
|
|
||||||
conventions: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: false,
|
|
||||||
droppedWindowsArmSupport: false,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [{arch: 'mips', os: 'linux', throws: true}]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const passingTests = groups.flatMap(group =>
|
test('exception', () => {
|
||||||
group.tests
|
expect(() => {
|
||||||
.filter(example => !example.throws)
|
getArch('mips');
|
||||||
.map(example => ({
|
}).toThrowError('mips is not supported');
|
||||||
...example,
|
});
|
||||||
condition: group.condition,
|
|
||||||
conventions: group.conventions
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
const throwingTests = groups.flatMap(group =>
|
|
||||||
group.tests
|
|
||||||
.filter(example => example.throws)
|
|
||||||
.map(example => ({
|
|
||||||
...example,
|
|
||||||
condition: group.condition,
|
|
||||||
conventions: group.conventions
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
test.each(passingTests)(
|
|
||||||
'$condition: $os on $arch returns $expected',
|
|
||||||
({arch, os, conventions, expected}) => {
|
|
||||||
expect(getArch(arch, os, conventions)).toBe(expected);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
test.each(throwingTests)(
|
|
||||||
'$condition: $os on $arch throws as not supported',
|
|
||||||
({arch, os, conventions}) => {
|
|
||||||
expect(() => {
|
|
||||||
getArch(arch, os, conventions);
|
|
||||||
}).toThrow(`${arch} is not supported`);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
import {getConventions} from '../src/get-conventions';
|
|
||||||
|
|
||||||
describe('getConventions()', () => {
|
|
||||||
const groups = [
|
|
||||||
{
|
|
||||||
condition: 'when hugo version < 0.102.0',
|
|
||||||
version: '0.101.0',
|
|
||||||
expected: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: false,
|
|
||||||
droppedWindowsArmSupport: false,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when hugo version === 0.102.z',
|
|
||||||
version: '0.102.0',
|
|
||||||
expected: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: true,
|
|
||||||
droppedWindowsArmSupport: true,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when hugo version >= 0.103.0',
|
|
||||||
version: '0.103.0',
|
|
||||||
expected: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: true,
|
|
||||||
droppedWindowsArmSupport: true,
|
|
||||||
standardizedNaming: true
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: true,
|
|
||||||
downcasedAll: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
].map(function (group) {
|
|
||||||
return Object.assign(group, {
|
|
||||||
toString: function () {
|
|
||||||
return group.condition;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test.each(groups)('%s', ({expected, version}) => {
|
|
||||||
expect(getConventions(version)).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {getURL, getLatestVersion} from '../src/get-latest-version';
|
import {getURL, getLatestVersion} from '../src/get-latest-version';
|
||||||
|
import nock from 'nock';
|
||||||
import {FetchError} from 'node-fetch';
|
import {FetchError} from 'node-fetch';
|
||||||
import {clearMockFetchResponses, mockFetchResponse} from './mocks/node-fetch';
|
|
||||||
import {Tool} from '../src/constants';
|
import {Tool} from '../src/constants';
|
||||||
import jsonTestBrew from './data/brew.json';
|
import jsonTestBrew from './data/brew.json';
|
||||||
import jsonTestGithub from './data/github.json';
|
import jsonTestGithub from './data/github.json';
|
||||||
@@ -10,7 +10,7 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
clearMockFetchResponses();
|
nock.cleanAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getURL()', () => {
|
describe('getURL()', () => {
|
||||||
@@ -27,26 +27,24 @@ describe('getURL()', () => {
|
|||||||
|
|
||||||
describe('getLatestVersion()', () => {
|
describe('getLatestVersion()', () => {
|
||||||
test('return latest version via brew', async () => {
|
test('return latest version via brew', async () => {
|
||||||
mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 200, jsonTestBrew);
|
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
|
||||||
|
|
||||||
const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'brew');
|
const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'brew');
|
||||||
expect(versionLatest).toMatch(Tool.TestVersionLatest);
|
expect(versionLatest).toMatch(Tool.TestVersionLatest);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('return latest version via GitHub', async () => {
|
test('return latest version via GitHub', async () => {
|
||||||
mockFetchResponse(
|
nock('https://api.github.com')
|
||||||
`https://api.github.com/repos/${Tool.Org}/${Tool.Repo}/releases/latest`,
|
.get(`/repos/${Tool.Org}/${Tool.Repo}/releases/latest`)
|
||||||
200,
|
.reply(200, jsonTestGithub);
|
||||||
jsonTestGithub
|
|
||||||
);
|
|
||||||
|
|
||||||
const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'github');
|
const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'github');
|
||||||
expect(versionLatest).toMatch(Tool.TestVersionLatest);
|
expect(versionLatest).toMatch(Tool.TestVersionLatest);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('return exception 404', async () => {
|
test('return exception 404', async () => {
|
||||||
mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 404);
|
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404);
|
||||||
|
|
||||||
await expect(getLatestVersion(Tool.Org, Tool.Repo, 'brew')).rejects.toThrow(FetchError);
|
await expect(getLatestVersion(Tool.Org, Tool.Repo, 'brew')).rejects.toThrowError(FetchError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,100 +1,15 @@
|
|||||||
import getOS from '../src/get-os';
|
import getOS from '../src/get-os';
|
||||||
|
|
||||||
describe('getOS', () => {
|
describe('getOS', () => {
|
||||||
const groups = [
|
test('os type', () => {
|
||||||
{
|
expect(getOS('linux')).toBe('Linux');
|
||||||
condition: 'when hugo version < 0.102.0',
|
expect(getOS('darwin')).toBe('macOS');
|
||||||
conventions: {
|
expect(getOS('win32')).toBe('Windows');
|
||||||
arch: {
|
|
||||||
darwinUniversal: false,
|
|
||||||
droppedWindowsArmSupport: false,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [
|
|
||||||
{os: 'linux', expected: 'Linux'},
|
|
||||||
{os: 'darwin', expected: 'macOS'},
|
|
||||||
{os: 'win32', expected: 'Windows'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when hugo version === 0.102.z',
|
|
||||||
conventions: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: true,
|
|
||||||
droppedWindowsArmSupport: true,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [
|
|
||||||
{os: 'linux', expected: 'Linux'},
|
|
||||||
{os: 'darwin', expected: 'macOS'},
|
|
||||||
{os: 'win32', expected: 'Windows'}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
condition: 'when hugo version >= 0.103.0',
|
|
||||||
conventions: {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: true,
|
|
||||||
droppedWindowsArmSupport: true,
|
|
||||||
standardizedNaming: true
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: true,
|
|
||||||
downcasedAll: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tests: [
|
|
||||||
{os: 'linux', expected: 'linux'},
|
|
||||||
{os: 'darwin', expected: 'darwin'},
|
|
||||||
{os: 'win32', expected: 'windows'}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
].map(function (group) {
|
|
||||||
group.tests = group.tests.map(function (example) {
|
|
||||||
return Object.assign(example, {
|
|
||||||
toString: function () {
|
|
||||||
return `${example.os} returns ${example.expected}`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return Object.assign(group, {
|
|
||||||
toString: function () {
|
|
||||||
return group.condition;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe.each(groups)('%s', ({conventions, tests}) => {
|
|
||||||
test.each(tests)('%s', ({os, expected}) => {
|
|
||||||
expect(getOS(os, conventions)).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exception', () => {
|
test('exception', () => {
|
||||||
const conventions = {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: false,
|
|
||||||
droppedWindowsArmSupport: false,
|
|
||||||
standardizedNaming: false
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: false,
|
|
||||||
downcasedAll: false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
getOS('centos', conventions);
|
getOS('centos');
|
||||||
}).toThrow('centos is not supported');
|
}).toThrowError('centos is not supported');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+15
-156
@@ -1,161 +1,20 @@
|
|||||||
import getURL, {getDownloadVersion} from '../src/get-url';
|
import getURL from '../src/get-url';
|
||||||
|
|
||||||
describe('getURL()', () => {
|
describe('getURL()', () => {
|
||||||
test('get URLs to Linux assets', () => {
|
test('get a URL to an asset for each platform', () => {
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
||||||
expect(getURL('Linux', '64bit', 'false', '0.58.2')).toEqual([
|
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
|
||||||
`${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`,
|
const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`;
|
||||||
`${baseURL}/hugo_0.58.2_Linux_64bit.tar.gz`,
|
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
|
||||||
`${baseURL}/hugo_0.58.2_linux-amd64.tar.gz`,
|
const urlMacOSExtended = `${baseURL}/hugo_extended_0.58.2_macOS-64bit.tar.gz`;
|
||||||
`${baseURL}/hugo_v0.58.2_Linux-64bit.tar.gz`,
|
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
|
||||||
`${baseURL}/hugo_v0.58.2_Linux_64bit.tar.gz`,
|
expect(getURL('Linux', '64bit', 'false', '0.58.2')).toBe(urlLinux);
|
||||||
`${baseURL}/hugo_v0.58.2_linux-amd64.tar.gz`
|
expect(getURL('Linux', '64bit', 'true', '0.58.2')).not.toBe(urlLinux);
|
||||||
]);
|
expect(getURL('MyOS', '64bit', 'false', '0.58.2')).not.toBe(urlLinux);
|
||||||
expect(getURL('Linux', 'ARM64', 'true', '0.58.2')).toEqual([
|
expect(getURL('Linux', '64bit', 'false', '0.58.1')).not.toBe(urlLinux);
|
||||||
`${baseURL}/hugo_extended_0.58.2_Linux-ARM64.tar.gz`,
|
expect(getURL('Linux', '64bit', 'true', '0.58.2')).toBe(urlLinuxExtended);
|
||||||
`${baseURL}/hugo_extended_0.58.2_Linux_ARM64.tar.gz`,
|
expect(getURL('macOS', '64bit', 'false', '0.58.2')).toBe(urlMacOS);
|
||||||
`${baseURL}/hugo_extended_0.58.2_linux-arm64.tar.gz`,
|
expect(getURL('macOS', '64bit', 'true', '0.58.2')).toBe(urlMacOSExtended);
|
||||||
`${baseURL}/hugo_extended_v0.58.2_Linux-ARM64.tar.gz`,
|
expect(getURL('Windows', '64bit', 'false', '0.58.2')).toBe(urlWindows);
|
||||||
`${baseURL}/hugo_extended_v0.58.2_Linux_ARM64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.58.2_linux-arm64.tar.gz`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to legacy Linux assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.20.3';
|
|
||||||
expect(getURL('Linux', '64bit', 'false', '0.20.3')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.20.3_Linux-64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.20.3_Linux_64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.20.3_linux-amd64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.20.3_Linux-64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.20.3_Linux_64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.20.3_linux-amd64.tar.gz`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to macOS assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.161.1';
|
|
||||||
expect(getURL('macOS', '64bit', 'true', '0.161.1')).toEqual([
|
|
||||||
`${baseURL}/hugo_extended_0.161.1_macOS-64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_0.161.1_macOS-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_extended_0.161.1_macOS-all.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_0.161.1_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_0.161.1_darwin-universal.pkg`,
|
|
||||||
`${baseURL}/hugo_extended_v0.161.1_macOS-64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.161.1_macOS-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_extended_v0.161.1_macOS-all.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.161.1_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.161.1_darwin-universal.pkg`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to macOS 0.102 universal assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.102.0';
|
|
||||||
expect(getURL('macOS', 'universal', 'false', '0.102.0')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.102.0_macOS-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.102.0_macOS-universal.zip`,
|
|
||||||
`${baseURL}/hugo_0.102.0_macOS-all.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.102.0_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.102.0_darwin-universal.pkg`,
|
|
||||||
`${baseURL}/hugo_v0.102.0_macOS-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.102.0_macOS-universal.zip`,
|
|
||||||
`${baseURL}/hugo_v0.102.0_macOS-all.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.102.0_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.102.0_darwin-universal.pkg`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to darwin assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.103.0';
|
|
||||||
expect(getURL('darwin', 'universal', 'false', '0.103.0')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.103.0_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.103.0_darwin-universal.pkg`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_darwin-universal.pkg`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to legacy macOS assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.20.2';
|
|
||||||
expect(getURL('macOS', '64bit', 'false', '0.20.2')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.20.2_macOS-64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.20.2_macOS-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_0.20.2_macOS-all.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.20.2_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.20.2_darwin-universal.pkg`,
|
|
||||||
`${baseURL}/hugo_v0.20.2_macOS-64bit.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.20.2_macOS-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_v0.20.2_macOS-all.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.20.2_darwin-universal.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.20.2_darwin-universal.pkg`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to Windows assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
|
||||||
expect(getURL('Windows', '64bit', 'false', '0.58.2')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.58.2_Windows-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_0.58.2_windows-amd64.zip`,
|
|
||||||
`${baseURL}/hugo_v0.58.2_Windows-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_v0.58.2_windows-amd64.zip`
|
|
||||||
]);
|
|
||||||
expect(getURL('Windows', 'ARM64', 'true', '0.58.2')).toEqual([
|
|
||||||
`${baseURL}/hugo_extended_0.58.2_Windows-ARM64.zip`,
|
|
||||||
`${baseURL}/hugo_extended_0.58.2_windows-arm64.zip`,
|
|
||||||
`${baseURL}/hugo_extended_v0.58.2_Windows-ARM64.zip`,
|
|
||||||
`${baseURL}/hugo_extended_v0.58.2_windows-arm64.zip`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to downcased Windows assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.103.0';
|
|
||||||
expect(getURL('windows', 'amd64', 'false', '0.103.0')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.103.0_windows-amd64.zip`,
|
|
||||||
`${baseURL}/hugo_0.103.0_Windows-amd64.zip`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_windows-amd64.zip`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_Windows-amd64.zip`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to legacy Windows assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.20.3';
|
|
||||||
expect(getURL('Windows', '64bit', 'false', '0.20.3')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.20.3_Windows-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_0.20.3_windows-amd64.zip`,
|
|
||||||
`${baseURL}/hugo_v0.20.3_Windows-64bit.zip`,
|
|
||||||
`${baseURL}/hugo_v0.20.3_windows-amd64.zip`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to downcased Linux assets', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.103.0';
|
|
||||||
expect(getURL('linux', 'arm', 'false', '0.103.0')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.103.0_linux-arm.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.103.0_Linux-arm.tar.gz`,
|
|
||||||
`${baseURL}/hugo_0.103.0_Linux_arm.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_linux-arm.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_Linux-arm.tar.gz`,
|
|
||||||
`${baseURL}/hugo_v0.103.0_Linux_arm.tar.gz`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get URLs to Hugo 0.139.5 archive alias', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.139.4';
|
|
||||||
expect(getDownloadVersion('0.139.5')).toBe('0.139.4');
|
|
||||||
expect(getURL('linux', 'amd64', 'true', '0.139.5')).toEqual([
|
|
||||||
`${baseURL}/hugo_extended_0.139.4_linux-amd64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_0.139.4_Linux-amd64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_0.139.4_Linux_amd64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.139.4_linux-amd64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.139.4_Linux-amd64.tar.gz`,
|
|
||||||
`${baseURL}/hugo_extended_v0.139.4_Linux_amd64.tar.gz`
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('get a fallback URL to an unknown OS asset', () => {
|
|
||||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
|
||||||
expect(getURL('MyOS', '64bit', 'false', '0.58.2')).toEqual([
|
|
||||||
`${baseURL}/hugo_0.58.2_MyOS-64bit.tar.gz`
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
import * as tc from '@actions/tool-cache';
|
|
||||||
import * as io from '@actions/io';
|
|
||||||
import * as exec from '@actions/exec';
|
|
||||||
import path from 'path';
|
|
||||||
import {downloadHugoAsset, extractHugoAsset, isWindowsAsset} from '../src/installer';
|
|
||||||
|
|
||||||
jest.mock('@actions/tool-cache', () => ({
|
|
||||||
downloadTool: jest.fn(),
|
|
||||||
extractTar: jest.fn(),
|
|
||||||
extractZip: jest.fn()
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('@actions/io', () => ({
|
|
||||||
mv: jest.fn()
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('@actions/exec', () => ({
|
|
||||||
exec: jest.fn()
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('downloadHugoAsset()', () => {
|
|
||||||
const mockedTC = tc as jest.Mocked<typeof tc>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('retry 404 candidates and return the first downloaded asset', async () => {
|
|
||||||
mockedTC.downloadTool
|
|
||||||
.mockRejectedValueOnce(new Error('Unexpected HTTP response: 404'))
|
|
||||||
.mockResolvedValueOnce('/tmp/hugo');
|
|
||||||
|
|
||||||
const result = await downloadHugoAsset([
|
|
||||||
'https://example.com/missing.tar.gz',
|
|
||||||
'https://example.com/hugo.tar.gz'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
path: '/tmp/hugo',
|
|
||||||
url: 'https://example.com/hugo.tar.gz'
|
|
||||||
});
|
|
||||||
expect(mockedTC.downloadTool).toHaveBeenCalledTimes(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('throw a clear error when all candidates return 404', async () => {
|
|
||||||
mockedTC.downloadTool.mockRejectedValue(new Error('Unexpected HTTP response: 404'));
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
downloadHugoAsset([
|
|
||||||
'https://example.com/missing-1.tar.gz',
|
|
||||||
'https://example.com/missing-2.tar.gz'
|
|
||||||
])
|
|
||||||
).rejects.toThrow('Unable to find a compatible Hugo release asset');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('rethrow non-404 download failures without retrying', async () => {
|
|
||||||
const error = new Error('socket hang up');
|
|
||||||
mockedTC.downloadTool.mockRejectedValueOnce(error);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
downloadHugoAsset(['https://example.com/hugo.tar.gz', 'https://example.com/fallback.tar.gz'])
|
|
||||||
).rejects.toBe(error);
|
|
||||||
expect(mockedTC.downloadTool).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('extractHugoAsset()', () => {
|
|
||||||
const mockedTC = tc as jest.Mocked<typeof tc>;
|
|
||||||
const mockedIO = io as jest.Mocked<typeof io>;
|
|
||||||
const mockedExec = exec as jest.Mocked<typeof exec>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('extract a tar.gz asset', async () => {
|
|
||||||
mockedTC.extractTar.mockResolvedValue('/tmp/extracted');
|
|
||||||
|
|
||||||
await extractHugoAsset('/tmp/tool', 'https://example.com/hugo.tar.gz', '/tmp/temp', '/tmp/bin');
|
|
||||||
|
|
||||||
expect(mockedTC.extractTar).toHaveBeenCalledWith('/tmp/tool', '/tmp/temp');
|
|
||||||
expect(mockedIO.mv).toHaveBeenCalledWith(path.join('/tmp/extracted', 'hugo'), '/tmp/bin');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('extract a zip asset', async () => {
|
|
||||||
mockedTC.extractZip.mockResolvedValue('/tmp/extracted');
|
|
||||||
|
|
||||||
await extractHugoAsset(
|
|
||||||
'/tmp/tool',
|
|
||||||
'https://example.com/hugo_0.58.2_Windows-64bit.zip',
|
|
||||||
'/tmp/temp',
|
|
||||||
'/tmp/bin'
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(mockedTC.extractZip).toHaveBeenCalledWith('/tmp/tool', '/tmp/temp');
|
|
||||||
expect(mockedIO.mv).toHaveBeenCalledWith(path.join('/tmp/extracted', 'hugo.exe'), '/tmp/bin');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('extract a macOS zip asset', async () => {
|
|
||||||
mockedTC.extractZip.mockResolvedValue('/tmp/extracted');
|
|
||||||
|
|
||||||
await extractHugoAsset(
|
|
||||||
'/tmp/tool',
|
|
||||||
'https://example.com/hugo_0.20.2_macOS-64bit.zip',
|
|
||||||
'/tmp/temp',
|
|
||||||
'/tmp/bin'
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(mockedTC.extractZip).toHaveBeenCalledWith('/tmp/tool', '/tmp/temp');
|
|
||||||
expect(mockedIO.mv).toHaveBeenCalledWith(path.join('/tmp/extracted', 'hugo'), '/tmp/bin');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('extract a macOS pkg asset', async () => {
|
|
||||||
mockedExec.exec.mockResolvedValue(0);
|
|
||||||
|
|
||||||
await extractHugoAsset('/tmp/tool', 'https://example.com/hugo.pkg', '/tmp/temp', '/tmp/bin');
|
|
||||||
|
|
||||||
expect(mockedExec.exec).toHaveBeenCalledWith('pkgutil', [
|
|
||||||
'--expand-full',
|
|
||||||
'/tmp/tool',
|
|
||||||
path.join('/tmp/temp', 'pkg')
|
|
||||||
]);
|
|
||||||
expect(mockedIO.mv).toHaveBeenCalledWith(
|
|
||||||
path.join('/tmp/temp', 'pkg', 'Payload', 'hugo'),
|
|
||||||
'/tmp/bin'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isWindowsAsset()', () => {
|
|
||||||
test('detect Windows asset URLs', () => {
|
|
||||||
expect(isWindowsAsset('https://example.com/hugo_0.58.2_Windows-64bit.zip')).toBe(true);
|
|
||||||
expect(isWindowsAsset('https://example.com/hugo_0.119.0_windows-amd64.zip')).toBe(true);
|
|
||||||
expect(isWindowsAsset('https://example.com/hugo_0.20.2_macOS-64bit.zip')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import nock from 'nock';
|
||||||
import {Tool, Action} from '../src/constants';
|
import {Tool, Action} from '../src/constants';
|
||||||
import {FetchError} from 'node-fetch';
|
import {FetchError} from 'node-fetch';
|
||||||
import {clearMockFetchResponses, mockFetchResponse} from './mocks/node-fetch';
|
|
||||||
import jsonTestBrew from './data/brew.json';
|
import jsonTestBrew from './data/brew.json';
|
||||||
// import jsonTestGithub from './data/github.json';
|
// import jsonTestGithub from './data/github.json';
|
||||||
|
|
||||||
@@ -19,8 +19,7 @@ describe('Integration testing run()', () => {
|
|||||||
await io.rmRF(workDir);
|
await io.rmRF(workDir);
|
||||||
|
|
||||||
delete process.env['INPUT_HUGO-VERSION'];
|
delete process.env['INPUT_HUGO-VERSION'];
|
||||||
delete process.env['INPUT_EXTENDED'];
|
nock.cleanAll();
|
||||||
clearMockFetchResponses();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('succeed in installing a custom version', async () => {
|
test('succeed in installing a custom version', async () => {
|
||||||
@@ -44,7 +43,7 @@ describe('Integration testing run()', () => {
|
|||||||
test('succeed in installing the latest version', async () => {
|
test('succeed in installing the latest version', async () => {
|
||||||
const testVersion = 'latest';
|
const testVersion = 'latest';
|
||||||
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
||||||
mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 200, jsonTestBrew);
|
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
|
||||||
const result: main.ActionResult = await main.run();
|
const result: main.ActionResult = await main.run();
|
||||||
expect(result.exitcode).toBe(0);
|
expect(result.exitcode).toBe(0);
|
||||||
expect(result.output).toMatch(`hugo v${Tool.TestVersionLatest}`);
|
expect(result.output).toMatch(`hugo v${Tool.TestVersionLatest}`);
|
||||||
@@ -54,7 +53,7 @@ describe('Integration testing run()', () => {
|
|||||||
const testVersion = 'latest';
|
const testVersion = 'latest';
|
||||||
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
process.env['INPUT_HUGO-VERSION'] = testVersion;
|
||||||
process.env['INPUT_EXTENDED'] = 'true';
|
process.env['INPUT_EXTENDED'] = 'true';
|
||||||
mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 200, jsonTestBrew);
|
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
|
||||||
const result: main.ActionResult = await main.run();
|
const result: main.ActionResult = await main.run();
|
||||||
expect(result.exitcode).toBe(0);
|
expect(result.exitcode).toBe(0);
|
||||||
expect(result.output).toMatch(`hugo v${Tool.TestVersionLatest}`);
|
expect(result.output).toMatch(`hugo v${Tool.TestVersionLatest}`);
|
||||||
@@ -63,9 +62,9 @@ describe('Integration testing run()', () => {
|
|||||||
|
|
||||||
test('fail to install the latest version due to 404 of brew', async () => {
|
test('fail to install the latest version due to 404 of brew', async () => {
|
||||||
process.env['INPUT_HUGO-VERSION'] = 'latest';
|
process.env['INPUT_HUGO-VERSION'] = 'latest';
|
||||||
mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 404);
|
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404);
|
||||||
|
|
||||||
await expect(main.run()).rejects.toThrow(FetchError);
|
await expect(main.run()).rejects.toThrowError(FetchError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,6 +81,6 @@ describe('showVersion()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('return not found', async () => {
|
test('return not found', async () => {
|
||||||
await expect(main.showVersion('gitgit', ['--version'])).rejects.toThrow('spawn gitgit ENOENT');
|
await expect(main.showVersion('gitgit', ['--version'])).rejects.toThrowError(Error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
import path from 'path';
|
|
||||||
|
|
||||||
export function getInput(name: string): string {
|
|
||||||
return process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addPath(inputPath: string): void {
|
|
||||||
process.env.PATH = `${inputPath}${path.delimiter}${process.env.PATH || ''}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function debug(message: string): void {
|
|
||||||
void message;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function info(message: string): void {
|
|
||||||
void message;
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import {spawn} from 'child_process';
|
|
||||||
|
|
||||||
interface ExecOptions {
|
|
||||||
listeners?: {
|
|
||||||
stdout?: (data: Buffer) => void;
|
|
||||||
stderr?: (data: Buffer) => void;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function exec(
|
|
||||||
commandLine: string,
|
|
||||||
args: string[] = [],
|
|
||||||
options: ExecOptions = {}
|
|
||||||
): Promise<number> {
|
|
||||||
if (commandLine === 'hugo') {
|
|
||||||
const version = process.env.TEST_HUGO_VERSION || '';
|
|
||||||
const extended = process.env.TEST_HUGO_EXTENDED === 'true' ? ' extended' : '';
|
|
||||||
options.listeners?.stdout?.(Buffer.from(`hugo v${version}${extended}\n`));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const child = spawn(commandLine, args);
|
|
||||||
|
|
||||||
child.stdout?.on('data', (data: Buffer) => {
|
|
||||||
options.listeners?.stdout?.(data);
|
|
||||||
});
|
|
||||||
child.stderr?.on('data', (data: Buffer) => {
|
|
||||||
options.listeners?.stderr?.(data);
|
|
||||||
});
|
|
||||||
child.on('error', reject);
|
|
||||||
child.on('close', code => {
|
|
||||||
resolve(code ?? 0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
export async function mkdirP(dir: string): Promise<void> {
|
|
||||||
void dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function rmRF(target: string): Promise<void> {
|
|
||||||
void target;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function mv(source: string, dest: string): Promise<void> {
|
|
||||||
void source;
|
|
||||||
void dest;
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
export async function downloadTool(url: string): Promise<string> {
|
|
||||||
const version = /hugo(?:_extended)?_([^_]+)_/.exec(url)?.[1] || '';
|
|
||||||
process.env.TEST_HUGO_VERSION = version;
|
|
||||||
process.env.TEST_HUGO_EXTENDED = url.includes('hugo_extended_') ? 'true' : 'false';
|
|
||||||
return '/tmp/hugo-archive';
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function extractTar(assetPath: string, tempDir: string): Promise<string> {
|
|
||||||
void assetPath;
|
|
||||||
void tempDir;
|
|
||||||
return '/tmp/extracted';
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function extractZip(assetPath: string, tempDir: string): Promise<string> {
|
|
||||||
void assetPath;
|
|
||||||
void tempDir;
|
|
||||||
return '/tmp/extracted';
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
import http from 'http';
|
|
||||||
import https from 'https';
|
|
||||||
|
|
||||||
export class FetchError extends Error {
|
|
||||||
name = 'FetchError' as const;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
message: string,
|
|
||||||
public type: string,
|
|
||||||
systemError?: Record<string, unknown>
|
|
||||||
) {
|
|
||||||
super(message);
|
|
||||||
if (systemError) {
|
|
||||||
Object.assign(this, systemError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ResponseLike {
|
|
||||||
ok: boolean;
|
|
||||||
status: number;
|
|
||||||
json: () => Promise<unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MockResponse {
|
|
||||||
body?: unknown;
|
|
||||||
status: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mockResponses = new Map<string, MockResponse>();
|
|
||||||
|
|
||||||
export function mockFetchResponse(url: string, status: number, body?: unknown): void {
|
|
||||||
mockResponses.set(url, {
|
|
||||||
body,
|
|
||||||
status
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function clearMockFetchResponses(): void {
|
|
||||||
mockResponses.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function fetch(url: string | URL): Promise<ResponseLike> {
|
|
||||||
const target = url.toString();
|
|
||||||
const mockResponse = mockResponses.get(target);
|
|
||||||
if (mockResponse) {
|
|
||||||
return {
|
|
||||||
ok: mockResponse.status >= 200 && mockResponse.status < 300,
|
|
||||||
status: mockResponse.status,
|
|
||||||
json: async () => mockResponse.body as unknown
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = target.startsWith('https:') ? https : http;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const request = client.get(target, response => {
|
|
||||||
const chunks: Buffer[] = [];
|
|
||||||
|
|
||||||
response.on('data', (chunk: Buffer | string) => {
|
|
||||||
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
||||||
});
|
|
||||||
|
|
||||||
response.on('end', () => {
|
|
||||||
const status = response.statusCode ?? 0;
|
|
||||||
const body = Buffer.concat(chunks).toString();
|
|
||||||
|
|
||||||
resolve({
|
|
||||||
ok: status >= 200 && status < 300,
|
|
||||||
status,
|
|
||||||
json: async () => JSON.parse(body) as unknown
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
request.on('error', error => {
|
|
||||||
reject(new FetchError(error.message, 'system'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
const tseslint = require('@typescript-eslint/eslint-plugin');
|
|
||||||
const jest = require('eslint-plugin-jest');
|
|
||||||
|
|
||||||
const globals = {
|
|
||||||
Atomics: 'readonly',
|
|
||||||
Buffer: 'readonly',
|
|
||||||
SharedArrayBuffer: 'readonly',
|
|
||||||
__dirname: 'readonly',
|
|
||||||
clearTimeout: 'readonly',
|
|
||||||
console: 'readonly',
|
|
||||||
exports: 'writable',
|
|
||||||
module: 'readonly',
|
|
||||||
process: 'readonly',
|
|
||||||
require: 'readonly',
|
|
||||||
setTimeout: 'readonly'
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
{
|
|
||||||
ignores: ['lib/**', 'coverage/**', 'node_modules/**']
|
|
||||||
},
|
|
||||||
...tseslint.configs['flat/recommended'],
|
|
||||||
{
|
|
||||||
files: ['src/**/*.ts', '__tests__/**/*.ts'],
|
|
||||||
languageOptions: {
|
|
||||||
ecmaVersion: 2019,
|
|
||||||
sourceType: 'module',
|
|
||||||
globals
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['__tests__/**/*.ts'],
|
|
||||||
...jest.configs['flat/recommended'],
|
|
||||||
settings: {
|
|
||||||
jest: {
|
|
||||||
version: 30
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
+2
-16
@@ -4,22 +4,8 @@ module.exports = {
|
|||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
testRunner: 'jest-circus/runner',
|
testRunner: 'jest-circus/runner',
|
||||||
moduleNameMapper: {
|
|
||||||
'^@actions/core$': '<rootDir>/__tests__/mocks/actions-core.ts',
|
|
||||||
'^@actions/exec$': '<rootDir>/__tests__/mocks/actions-exec.ts',
|
|
||||||
'^@actions/io$': '<rootDir>/__tests__/mocks/actions-io.ts',
|
|
||||||
'^@actions/tool-cache$': '<rootDir>/__tests__/mocks/actions-tool-cache.ts',
|
|
||||||
'^node-fetch$': '<rootDir>/__tests__/mocks/node-fetch.ts'
|
|
||||||
},
|
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': [
|
'^.+\\.ts$': 'ts-jest'
|
||||||
'ts-jest',
|
|
||||||
{
|
|
||||||
tsconfig: {
|
|
||||||
types: ['jest', 'node']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
verbose: true
|
verbose: true
|
||||||
}
|
}
|
||||||
+11717
File diff suppressed because one or more lines are too long
Generated
+13338
-7453
File diff suppressed because it is too large
Load Diff
+25
-24
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-hugo",
|
"name": "actions-hugo",
|
||||||
"version": "3.2.1",
|
"version": "3.0.0",
|
||||||
"description": "GitHub Actions for Hugo",
|
"description": "GitHub Actions for Hugo",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.15.0",
|
"node": ">=20.10.0",
|
||||||
"npm": ">=11.12.1"
|
"npm": ">=10.2.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"all": "npm run format:check && npm run lint && npm test",
|
"all": "npm run format:check && npm run lint && npm test",
|
||||||
@@ -47,28 +47,29 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/peaceiris/actions-hugo#readme",
|
"homepage": "https://github.com/peaceiris/actions-hugo#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "3.0.1",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "3.0.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "3.0.2",
|
"@actions/io": "^1.1.0",
|
||||||
"@actions/tool-cache": "4.0.0",
|
"@actions/tool-cache": "^1.7.2",
|
||||||
"node-fetch": "3.3.2"
|
"node-fetch": "^2.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "30.0.0",
|
"@types/jest": "^26.0.20",
|
||||||
"@types/node": "25.6.2",
|
"@types/node": "~20",
|
||||||
"@typescript-eslint/eslint-plugin": "8.59.2",
|
"@types/node-fetch": "^2.5.8",
|
||||||
"@typescript-eslint/parser": "8.59.2",
|
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
||||||
"@vercel/ncc": "0.38.4",
|
"@typescript-eslint/parser": "^4.16.1",
|
||||||
"eslint": "10.3.0",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint-plugin-jest": "29.15.2",
|
"eslint": "^7.21.0",
|
||||||
"husky": "9.1.7",
|
"eslint-plugin-jest": "^24.1.5",
|
||||||
"jest": "30.4.2",
|
"husky": "^5.1.3",
|
||||||
"jest-circus": "30.4.2",
|
"jest": "^26.6.3",
|
||||||
"lint-staged": "17.0.4",
|
"jest-circus": "^26.6.3",
|
||||||
"nock": "14.0.15",
|
"lint-staged": "^10.5.4",
|
||||||
"prettier": "3.8.3",
|
"nock": "^13.0.10",
|
||||||
"standard-version": "9.5.0",
|
"prettier": "2.2.1",
|
||||||
"ts-jest": "29.4.9",
|
"standard-version": "^9.1.1",
|
||||||
"typescript": "6.0.3"
|
"ts-jest": "^26.5.3",
|
||||||
|
"typescript": "^4.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -1,12 +1,12 @@
|
|||||||
export const Tool = {
|
export enum Tool {
|
||||||
Name: 'Hugo',
|
Name = 'Hugo',
|
||||||
Org: 'gohugoio',
|
Org = 'gohugoio',
|
||||||
Repo: 'hugo',
|
Repo = 'hugo',
|
||||||
CmdName: 'hugo',
|
CmdName = 'hugo',
|
||||||
CmdOptVersion: 'version',
|
CmdOptVersion = 'version',
|
||||||
TestVersionLatest: '0.83.1',
|
TestVersionLatest = '0.83.1',
|
||||||
TestVersionSpec: '0.82.1'
|
TestVersionSpec = '0.82.1'
|
||||||
} as const;
|
}
|
||||||
|
|
||||||
export enum Action {
|
export enum Action {
|
||||||
WorkDirName = 'actions_hugo',
|
WorkDirName = 'actions_hugo',
|
||||||
|
|||||||
+4
-14
@@ -1,21 +1,11 @@
|
|||||||
import {conventions} from './get-conventions';
|
export default function getArch(arch: string): string {
|
||||||
|
|
||||||
export default function getArch(arch: string, os: string, conventions: conventions): string {
|
|
||||||
if (conventions.arch.darwinUniversal && (os === 'darwin' || os === 'macOS')) {
|
|
||||||
return 'universal';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case 'x64':
|
case 'x64':
|
||||||
return conventions.arch.standardizedNaming ? 'amd64' : '64bit';
|
return '64bit';
|
||||||
case 'arm':
|
case 'arm':
|
||||||
if (conventions.arch.droppedWindowsArmSupport && (os === 'Windows' || os === 'windows')) {
|
return 'ARM';
|
||||||
throw new Error(`${arch} is not supported`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return conventions.arch.standardizedNaming ? 'arm' : 'ARM';
|
|
||||||
case 'arm64':
|
case 'arm64':
|
||||||
return conventions.arch.standardizedNaming ? 'arm64' : 'ARM64';
|
return 'ARM64';
|
||||||
default:
|
default:
|
||||||
throw new Error(`${arch} is not supported`);
|
throw new Error(`${arch} is not supported`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
export interface conventions {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: boolean;
|
|
||||||
droppedWindowsArmSupport: boolean;
|
|
||||||
standardizedNaming: boolean;
|
|
||||||
};
|
|
||||||
os: {
|
|
||||||
renamedMacOS: boolean;
|
|
||||||
downcasedAll: boolean;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getConventions(version: string): conventions {
|
|
||||||
const segments = version.split('.').map(s => parseInt(s));
|
|
||||||
const stableOrNewer = segments[0] > 0;
|
|
||||||
const newerThan103 = stableOrNewer || segments[1] >= 103;
|
|
||||||
const newerThan102 = stableOrNewer || segments[1] >= 102;
|
|
||||||
return {
|
|
||||||
arch: {
|
|
||||||
darwinUniversal: newerThan102,
|
|
||||||
droppedWindowsArmSupport: newerThan102,
|
|
||||||
standardizedNaming: newerThan103
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
renamedMacOS: newerThan103,
|
|
||||||
downcasedAll: newerThan103
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,4 @@
|
|||||||
import fetch, {FetchError} from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
interface BrewFormulaResponse {
|
|
||||||
versions: {
|
|
||||||
stable: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitHubReleaseResponse {
|
|
||||||
tag_name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getURL(org: string, repo: string, api: string): string {
|
export function getURL(org: string, repo: string, api: string): string {
|
||||||
let url = '';
|
let url = '';
|
||||||
@@ -25,16 +15,12 @@ export function getURL(org: string, repo: string, api: string): string {
|
|||||||
export async function getLatestVersion(org: string, repo: string, api: string): Promise<string> {
|
export async function getLatestVersion(org: string, repo: string, api: string): Promise<string> {
|
||||||
const url = getURL(org, repo, api);
|
const url = getURL(org, repo, api);
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
if (!response.ok) {
|
|
||||||
throw new FetchError(`request to ${url} failed with status ${response.status}`, 'system');
|
|
||||||
}
|
|
||||||
|
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
let latestVersion = '';
|
let latestVersion = '';
|
||||||
if (api === 'brew') {
|
if (api === 'brew') {
|
||||||
latestVersion = (json as BrewFormulaResponse).versions.stable;
|
latestVersion = json.versions.stable;
|
||||||
} else if (api === 'github') {
|
} else if (api === 'github') {
|
||||||
latestVersion = (json as GitHubReleaseResponse).tag_name;
|
latestVersion = json.tag_name;
|
||||||
}
|
}
|
||||||
return latestVersion;
|
return latestVersion;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-6
@@ -1,13 +1,11 @@
|
|||||||
import {conventions} from './get-conventions';
|
export default function getOS(platform: string): string {
|
||||||
|
|
||||||
export default function getOS(platform: string, conventions: conventions): string {
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return conventions.os.downcasedAll ? 'linux' : 'Linux';
|
return 'Linux';
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return conventions.os.renamedMacOS ? 'darwin' : 'macOS';
|
return 'macOS';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return conventions.os.downcasedAll ? 'windows' : 'Windows';
|
return 'Windows';
|
||||||
default:
|
default:
|
||||||
throw new Error(`${platform} is not supported`);
|
throw new Error(`${platform} is not supported`);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-74
@@ -3,9 +3,7 @@ export default function getURL(
|
|||||||
arch: string,
|
arch: string,
|
||||||
extended: string,
|
extended: string,
|
||||||
version: string
|
version: string
|
||||||
): string[] {
|
): string {
|
||||||
const downloadVersion = getDownloadVersion(version);
|
|
||||||
|
|
||||||
const extendedStr = (extended: string): string => {
|
const extendedStr = (extended: string): string => {
|
||||||
if (extended === 'true') {
|
if (extended === 'true') {
|
||||||
return 'extended_';
|
return 'extended_';
|
||||||
@@ -16,80 +14,17 @@ export default function getURL(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const lowerArch = (arch: string): string => {
|
const ext = (os: string): string => {
|
||||||
switch (arch) {
|
if (os === 'Windows') {
|
||||||
case '64bit':
|
return 'zip';
|
||||||
return 'amd64';
|
} else {
|
||||||
case 'ARM':
|
return 'tar.gz';
|
||||||
return 'arm';
|
|
||||||
case 'ARM64':
|
|
||||||
return 'arm64';
|
|
||||||
default:
|
|
||||||
return arch.toLowerCase();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 assetBase = `hugo_${extendedStr(extended)}${downloadVersion}_`;
|
const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
|
||||||
const legacyVersionedAssetBase = `hugo_${extendedStr(extended)}v${downloadVersion}_`;
|
|
||||||
const assetBases = [assetBase, legacyVersionedAssetBase];
|
|
||||||
const assetURLs = (assetNames: string[]): string[] => {
|
|
||||||
return Array.from(new Set(assetNames)).map(assetName => {
|
|
||||||
return `${baseURL}/v${downloadVersion}/${assetName}`;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (os === 'macOS') {
|
return url;
|
||||||
return assetURLs(
|
|
||||||
assetBases.flatMap(assetBase => [
|
|
||||||
`${assetBase}macOS-${arch}.tar.gz`,
|
|
||||||
`${assetBase}macOS-${arch}.zip`,
|
|
||||||
`${assetBase}macOS-all.tar.gz`,
|
|
||||||
`${assetBase}darwin-universal.tar.gz`,
|
|
||||||
`${assetBase}darwin-universal.pkg`
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (os === 'darwin') {
|
|
||||||
return assetURLs(
|
|
||||||
assetBases.flatMap(assetBase => [
|
|
||||||
`${assetBase}darwin-${arch}.tar.gz`,
|
|
||||||
`${assetBase}darwin-${arch}.pkg`
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (os === 'Windows' || os === 'windows') {
|
|
||||||
const assetPatterns =
|
|
||||||
os === 'windows'
|
|
||||||
? [`windows-${lowerArch(arch)}.zip`, `Windows-${arch}.zip`]
|
|
||||||
: [`Windows-${arch}.zip`, `windows-${lowerArch(arch)}.zip`];
|
|
||||||
|
|
||||||
return assetURLs(
|
|
||||||
assetBases.flatMap(assetBase => assetPatterns.map(asset => `${assetBase}${asset}`))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (os === 'Linux' || os === 'linux') {
|
|
||||||
const assetPatterns =
|
|
||||||
os === 'linux'
|
|
||||||
? [`linux-${lowerArch(arch)}.tar.gz`, `Linux-${arch}.tar.gz`, `Linux_${arch}.tar.gz`]
|
|
||||||
: [`Linux-${arch}.tar.gz`, `Linux_${arch}.tar.gz`, `linux-${lowerArch(arch)}.tar.gz`];
|
|
||||||
|
|
||||||
return assetURLs(
|
|
||||||
assetBases.flatMap(assetBase => assetPatterns.map(asset => `${assetBase}${asset}`))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return assetURLs([`${assetBase}${os}-${arch}.tar.gz`]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getDownloadVersion(version: string): string {
|
|
||||||
if (version === '0.139.5') {
|
|
||||||
// v0.139.5 has no release archives; Hugo publishes the same archives under v0.139.4.
|
|
||||||
return '0.139.4';
|
|
||||||
}
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@ import * as main from './main';
|
|||||||
try {
|
try {
|
||||||
await main.run();
|
await main.run();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const message = e instanceof Error ? e.message : String(e);
|
core.setFailed(`Action failed with error ${e.message}`);
|
||||||
core.setFailed(`Action failed with error ${message}`);
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
+15
-81
@@ -1,19 +1,12 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as exec from '@actions/exec';
|
|
||||||
import {getConventions} from './get-conventions';
|
|
||||||
import getOS from './get-os';
|
import getOS from './get-os';
|
||||||
import getArch from './get-arch';
|
import getArch from './get-arch';
|
||||||
import getURL, {getDownloadVersion} from './get-url';
|
import getURL from './get-url';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {Tool, Action} from './constants';
|
import {Tool, Action} from './constants';
|
||||||
|
|
||||||
export interface DownloadedAsset {
|
|
||||||
path: string;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getHomeDir(): string {
|
export function getHomeDir(): string {
|
||||||
let homedir = '';
|
let homedir = '';
|
||||||
|
|
||||||
@@ -50,90 +43,31 @@ export async function createBinDir(workDir: string): Promise<string> {
|
|||||||
return binDir;
|
return binDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isRetryableDownloadError(error: unknown): boolean {
|
|
||||||
const message = error instanceof Error ? error.message : `${error}`;
|
|
||||||
return (
|
|
||||||
message.includes('Unexpected HTTP response: 404') ||
|
|
||||||
message.includes('Code(404)') ||
|
|
||||||
(message.includes('404') && message.includes('Not Found'))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isWindowsAsset(assetURL: string): boolean {
|
|
||||||
return /(?:Windows[-_]|windows[-_])/.test(assetURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function downloadHugoAsset(toolURLs: string[]): Promise<DownloadedAsset> {
|
|
||||||
for (const toolURL of toolURLs) {
|
|
||||||
core.debug(`toolURL: ${toolURL}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
return {
|
|
||||||
path: await tc.downloadTool(toolURL),
|
|
||||||
url: toolURL
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
if (!isRetryableDownloadError(error)) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(`Hugo asset not found at ${toolURL}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(
|
|
||||||
`Unable to find a compatible Hugo release asset for this runner. Tried:\n${toolURLs.join('\n')}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function extractHugoAsset(
|
|
||||||
assetPath: string,
|
|
||||||
assetURL: string,
|
|
||||||
tempDir: string,
|
|
||||||
binDir: string
|
|
||||||
): Promise<void> {
|
|
||||||
let toolBin = '';
|
|
||||||
|
|
||||||
if (assetURL.endsWith('.zip')) {
|
|
||||||
const toolExtractedFolder: string = await tc.extractZip(assetPath, tempDir);
|
|
||||||
const toolCmd = isWindowsAsset(assetURL) ? `${Tool.CmdName}.exe` : Tool.CmdName;
|
|
||||||
toolBin = path.join(toolExtractedFolder, toolCmd);
|
|
||||||
} else if (assetURL.endsWith('.pkg')) {
|
|
||||||
const pkgExtractedFolder = path.join(tempDir, 'pkg');
|
|
||||||
await exec.exec('pkgutil', ['--expand-full', assetPath, pkgExtractedFolder]);
|
|
||||||
toolBin = path.join(pkgExtractedFolder, 'Payload', Tool.CmdName);
|
|
||||||
} else {
|
|
||||||
const toolExtractedFolder: string = await tc.extractTar(assetPath, tempDir);
|
|
||||||
toolBin = path.join(toolExtractedFolder, Tool.CmdName);
|
|
||||||
}
|
|
||||||
|
|
||||||
await io.mv(toolBin, binDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function installer(version: string): Promise<void> {
|
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 conventions = getConventions(version);
|
const osName: string = getOS(process.platform);
|
||||||
|
|
||||||
const osName: string = getOS(process.platform, conventions);
|
|
||||||
core.debug(`Operating System: ${osName}`);
|
core.debug(`Operating System: ${osName}`);
|
||||||
|
|
||||||
const archName: string = getArch(process.arch, osName, conventions);
|
const archName: string = getArch(process.arch);
|
||||||
core.debug(`Processor Architecture: ${archName}`);
|
core.debug(`Processor Architecture: ${archName}`);
|
||||||
|
|
||||||
const toolURLs: string[] = getURL(osName, archName, extended, version);
|
const toolURL: string = getURL(osName, archName, extended, version);
|
||||||
const downloadVersion = getDownloadVersion(version);
|
core.debug(`toolURL: ${toolURL}`);
|
||||||
if (downloadVersion !== version) {
|
|
||||||
core.info(
|
|
||||||
`Hugo ${version} release does not publish archives; downloading v${downloadVersion} archives instead.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const workDir = await createWorkDir();
|
const workDir = await createWorkDir();
|
||||||
const binDir = await createBinDir(workDir);
|
const binDir = await createBinDir(workDir);
|
||||||
const tempDir = await createTempDir(workDir);
|
const tempDir = await createTempDir(workDir);
|
||||||
|
|
||||||
const toolAsset: DownloadedAsset = await downloadHugoAsset(toolURLs);
|
const toolAssets: string = await tc.downloadTool(toolURL);
|
||||||
await extractHugoAsset(toolAsset.path, toolAsset.url, tempDir, binDir);
|
let toolBin = '';
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
const toolExtractedFolder: string = await tc.extractZip(toolAssets, tempDir);
|
||||||
|
toolBin = `${toolExtractedFolder}/${Tool.CmdName}.exe`;
|
||||||
|
} else {
|
||||||
|
const toolExtractedFolder: string = await tc.extractTar(toolAssets, tempDir);
|
||||||
|
toolBin = `${toolExtractedFolder}/${Tool.CmdName}`;
|
||||||
|
}
|
||||||
|
await io.mv(toolBin, binDir);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["ES2019"],
|
"lib": ["ES2019"],
|
||||||
"module": "ESNext",
|
"module": "commonjs",
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"target": "ES2019",
|
"target": "ES2019",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
@@ -13,5 +12,5 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "__tests__"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user