Compare commits

..
Author SHA1 Message Date
dependabot[bot] 49bb5df02e ci: bump the codeql group with 3 updates
Bumps the codeql group with 3 updates: [github/codeql-action/init](https://github.com/github/codeql-action), [github/codeql-action/autobuild](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action).


Updates `github/codeql-action/init` from 4.39.3 to 4.39.4
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/33d7b85da1a04171e211befe2c739303b9a4c066...1bd86f2fdb4b86187fa4059f16f31a3202acc9ea)

Updates `github/codeql-action/autobuild` from 4.39.3 to 4.39.4
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/33d7b85da1a04171e211befe2c739303b9a4c066...1bd86f2fdb4b86187fa4059f16f31a3202acc9ea)

Updates `github/codeql-action/analyze` from 4.39.3 to 4.39.4
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/33d7b85da1a04171e211befe2c739303b9a4c066...1bd86f2fdb4b86187fa4059f16f31a3202acc9ea)

---
updated-dependencies:
- dependency-name: github/codeql-action/init
  dependency-version: 4.39.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: codeql
- dependency-name: github/codeql-action/autobuild
  dependency-version: 4.39.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: codeql
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.39.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: codeql
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-30 02:02:25 +00:00
peaceiris 1d7cb67e47 chore(release): Remove build assets [skip ci] 2026-11-16 16:07:06 +09:00
peaceiris d1c81a15d4 chore(release): 3.3.0 2026-11-16 16:07:05 +09:00
peaceiris 769ce3760b chore(release): Add build assets 2026-11-16 16:07:04 +09:00
Shohei Ueda c02355f4df feat: add optional verified Dart Sass installation (#769) 2026-11-16 15:57:38 +09:00
Shohei UedaandCodex e4550112cd ci: add seven-day Dependabot cooldowns (#768)
Co-authored-by: Codex <noreply@openai.com>
2026-11-14 23:41:49 +09:00
Shohei Ueda c91aeba70b ci: replace hub with gh for releases (#767) 2026-11-14 23:33:27 +09:00
Shohei Ueda 4a56969a09 docs: remove Verification 2026-11-14 23:15:53 +09:00
Shohei Ueda 1ed797ba5b chore: add dotfiles 2026-11-14 23:15:20 +09:00
Shohei Ueda 3715a155b8 ci: delete .github/workflows/purge-readme-image-cache.yml 2026-11-14 23:14:06 +09:00
dependabot[bot] c0cb134089 ci: bump the codeql group with 3 updates (#766)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-14 03:09:29 +09:00
dependabot[bot] 1df2a73aeb deps: bump the npm_and_yarn group across 1 directory with 2 updates (#765)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-14 03:07:00 +09:00
dependabot[bot]andShohei Ueda 7e5fbec1a9 ci: update CodeQL to 4.39.0 and group future updates (#762)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Shohei Ueda <30958501+peaceiris@users.noreply.github.com>
2026-11-14 01:39:32 +09:00
dependabot[bot] 151819a2d5 ci: bump actions/upload-artifact from 7.0.1 to 7.0.2 (#763)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-14 01:28:11 +09:00
dependabot[bot] 6a4925d6c2 ci: bump codecov/codecov-action from 7.0.0 to 7.1.1 (#753)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-14 01:25:48 +09:00
dependabot[bot] c21c4c2f1d deps: bump the npm_and_yarn group across 1 directory with 2 updates (#745)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-14 01:23:09 +09:00
dependabot[bot] d64889d521 ci: bump actions/setup-node from 7.0.0 to 7.1.0 (#757)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-18 16:19:26 +09:00
dependabot[bot] c53e8f0d96 ci: bump actions/checkout from 7.0.0 to 7.0.1 (#720)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-21 11:52:05 +09:00
dependabot[bot] c582c0a764 ci: bump actions/setup-node from 6.4.0 to 7.0.0 (#716)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-15 14:10:08 +09:00
dependabot[bot] 1574db77a9 ci: bump actions/checkout from 6.0.3 to 7.0.0 (#708)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-19 14:08:56 +09:00
dependabot[bot] 940247d08e ci: bump codecov/codecov-action from 6.0.1 to 7.0.0 (#707)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-08 13:21:59 +09:00
dependabot[bot] d17f2aa363 ci: bump github/codeql-action from 4.36.1 to 4.36.2 (#706)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-05 11:36:29 +09:00
dependabot[bot] c4a9c2db41 ci: bump github/codeql-action from 4.36.0 to 4.36.1 (#704)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-04 11:04:50 +09:00
dependabot[bot] 89ca553e6c ci: bump actions/checkout from 6.0.2 to 6.0.3 (#705)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-04 11:04:39 +09:00
dependabot[bot] 18deeac04c ci: bump github/codeql-action from 4.35.5 to 4.36.0 (#703)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-25 14:12:29 +09:00
dependabot[bot] 7845c37f7f ci: bump codecov/codecov-action from 6.0.0 to 6.0.1 (#702)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-19 22:14:18 +09:00
dependabot[bot] 8d04cd0510 ci: bump github/codeql-action from 4.35.4 to 4.35.5 (#701)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-18 11:59:53 +09:00
dependabot[bot] 9c46f58a58 ci: bump actions/dependency-review-action from 4.9.0 to 5.0.0 (#698)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 13:35:16 +09:00
dependabot[bot] 1f043ee545 ci: bump peaceiris/actions-hugo from 3.1.0 to 3.2.1 (#699)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 13:35:05 +09:00
dependabot[bot] 412dd9124a ci: bump codecov/codecov-action from 5.5.4 to 6.0.0 (#700)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 13:34:52 +09:00
peaceiris 4a3d6e00a5 chore(release): Remove build assets [skip ci] 2026-05-11 01:05:34 +09:00
peaceiris 2752ce1d29 chore(release): 3.2.1 2026-05-11 01:05:33 +09:00
peaceiris d8391e68b0 chore(release): Add build assets 2026-05-11 01:05:32 +09:00
Shohei UedaandCodex 4e5bf412f0 fix: handle Hugo 0.139.5 archive fallback (#696)
Co-authored-by: Codex <noreply@openai.com>
2026-05-11 01:05:09 +09:00
peaceiris c2f9fa4376 chore(release): Remove build assets [skip ci] 2026-05-11 00:27:27 +09:00
peaceiris cf03c8dbc2 chore(release): 3.2.0 2026-05-11 00:27:26 +09:00
peaceiris 50c0903488 chore(release): Add build assets 2026-05-11 00:27:24 +09:00
dependabot[bot] 681f914d18 ci: bump github/codeql-action from 3.35.4 to 4.35.4 (#694)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 00:25:15 +09:00
dependabot[bot] 7c673b8b9e ci: bump peaceiris/actions-hugo from 3.0.0 to 3.1.0 (#693)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 00:25:06 +09:00
dependabot[bot] 27f9d4ab07 ci: bump actions/upload-artifact from 4.6.2 to 7.0.1 (#692)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 00:24:57 +09:00
dependabot[bot] 71c032c9dc ci: bump actions/checkout from 4.3.1 to 6.0.2 (#691)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 00:24:45 +09:00
dependabot[bot] 66080d4abb ci: bump actions/setup-node from 4.4.0 to 6.4.0 (#690)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from
4.4.0 to 6.4.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/setup-node/releases">actions/setup-node's
releases</a>.</em></p>
<blockquote>
<h2>v6.4.0</h2>
<h2>What's Changed</h2>
<h3>Dependency updates:</h3>
<ul>
<li>Upgrade <a
href="https://github.com/actions"><code>@​actions</code></a>
dependencies by <a
href="https://github.com/Copilot"><code>@​Copilot</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1525">actions/setup-node#1525</a></li>
<li>Update Node.js versions in versions.yml and bump package to v6.4.0
by <a
href="https://github.com/priya-kinthali"><code>@​priya-kinthali</code></a>
in <a
href="https://redirect.github.com/actions/setup-node/pull/1533">actions/setup-node#1533</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/Copilot"><code>@​Copilot</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/setup-node/pull/1525">actions/setup-node#1525</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/setup-node/compare/v6...v6.4.0">https://github.com/actions/setup-node/compare/v6...v6.4.0</a></p>
<h2>v6.3.0</h2>
<h2>What's Changed</h2>
<h3>Enhancements:</h3>
<ul>
<li>Support parsing <code>devEngines</code> field by <a
href="https://github.com/susnux"><code>@​susnux</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1283">actions/setup-node#1283</a></li>
</ul>
<blockquote>
<p>When using node-version-file: package.json, setup-node now
prefers devEngines.runtime over engines.node.</p>
</blockquote>
<h3>Dependency updates:</h3>
<ul>
<li>Fix npm audit issues by <a
href="https://github.com/gowridurgad"><code>@​gowridurgad</code></a> in
<a
href="https://redirect.github.com/actions/setup-node/pull/1491">actions/setup-node#1491</a></li>
<li>Replace uuid with crypto.randomUUID() by <a
href="https://github.com/trivikr"><code>@​trivikr</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1378">actions/setup-node#1378</a></li>
<li>Upgrade minimatch from 3.1.2 to 3.1.5 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1498">actions/setup-node#1498</a></li>
</ul>
<h3>Bug fixes:</h3>
<ul>
<li>Remove hardcoded bearer for mirror-url <a
href="https://github.com/marco-ippolito"><code>@​marco-ippolito</code></a>
in <a
href="https://redirect.github.com/actions/setup-node/pull/1467">actions/setup-node#1467</a></li>
<li>Scope test lockfiles by package manager and update cache tests by <a
href="https://github.com/gowridurgad"><code>@​gowridurgad</code></a> in
<a
href="https://redirect.github.com/actions/setup-node/pull/1495">actions/setup-node#1495</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/susnux"><code>@​susnux</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/setup-node/pull/1283">actions/setup-node#1283</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/setup-node/compare/v6...v6.3.0">https://github.com/actions/setup-node/compare/v6...v6.3.0</a></p>
<h2>v6.2.0</h2>
<h2>What's Changed</h2>
<h3>Documentation</h3>
<ul>
<li>Documentation update related to absence of Lockfile by <a
href="https://github.com/mahabaleshwars"><code>@​mahabaleshwars</code></a>
in <a
href="https://redirect.github.com/actions/setup-node/pull/1454">actions/setup-node#1454</a></li>
<li>Correct mirror option typos by <a
href="https://github.com/MikeMcC399"><code>@​MikeMcC399</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1442">actions/setup-node#1442</a></li>
<li>Readme update on checkout version v6 by <a
href="https://github.com/deining"><code>@​deining</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1446">actions/setup-node#1446</a></li>
<li>Readme typo fixes <a
href="https://github.com/munyari"><code>@​munyari</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1226">actions/setup-node#1226</a></li>
<li>Advanced document update on checkout version v6 by <a
href="https://github.com/aparnajyothi-y"><code>@​aparnajyothi-y</code></a>
in <a
href="https://redirect.github.com/actions/setup-node/pull/1468">actions/setup-node#1468</a></li>
</ul>
<h3>Dependency updates:</h3>
<ul>
<li>Upgrade <code>@​actions/cache</code> to v5.0.1 by <a
href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a> in <a
href="https://redirect.github.com/actions/setup-node/pull/1449">actions/setup-node#1449</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/mahabaleshwars"><code>@​mahabaleshwars</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/setup-node/pull/1454">actions/setup-node#1454</a></li>
<li><a
href="https://github.com/MikeMcC399"><code>@​MikeMcC399</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/setup-node/pull/1442">actions/setup-node#1442</a></li>
<li><a href="https://github.com/deining"><code>@​deining</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/setup-node/pull/1446">actions/setup-node#1446</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/actions/setup-node/commit/48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e"><code>48b55a0</code></a>
Update Node.js versions in versions.yml and bump package to v6.4.0 (<a
href="https://redirect.github.com/actions/setup-node/issues/1533">#1533</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/ab72c7e7eba0eaa11f8cab0f5679243900c2cac9"><code>ab72c7e</code></a>
Upgrade <a href="https://github.com/actions"><code>@​actions</code></a>
dependencies (<a
href="https://redirect.github.com/actions/setup-node/issues/1525">#1525</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/53b83947a5a98c8d113130e565377fae1a50d02f"><code>53b8394</code></a>
Bump minimatch from 3.1.2 to 3.1.5 (<a
href="https://redirect.github.com/actions/setup-node/issues/1498">#1498</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/54045abd5dcd3b0fee9ca02fa24c57545834c9cc"><code>54045ab</code></a>
Scope test lockfiles by package manager and update cache tests (<a
href="https://redirect.github.com/actions/setup-node/issues/1495">#1495</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/c882bffdbd4df51ace6b940023952e8669c9932a"><code>c882bff</code></a>
Replace uuid with crypto.randomUUID() (<a
href="https://redirect.github.com/actions/setup-node/issues/1378">#1378</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/774c1d62961e73038a114d59c8847023c003194d"><code>774c1d6</code></a>
feat(node-version-file): support parsing <code>devEngines</code> field
(<a
href="https://redirect.github.com/actions/setup-node/issues/1283">#1283</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/efcb663fc60e97218a2b2d6d827f7830f164739e"><code>efcb663</code></a>
fix: remove hardcoded bearer (<a
href="https://redirect.github.com/actions/setup-node/issues/1467">#1467</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/d02c89dce7e1ba9ef629ce0680989b3a1cc72edb"><code>d02c89d</code></a>
Fix npm audit issues (<a
href="https://redirect.github.com/actions/setup-node/issues/1491">#1491</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/6044e13b5dc448c55e2357c09f80417699197238"><code>6044e13</code></a>
Docs: bump actions/checkout from v5 to v6 (<a
href="https://redirect.github.com/actions/setup-node/issues/1468">#1468</a>)</li>
<li><a
href="https://github.com/actions/setup-node/commit/8e494633d082d609d1e9ff931be32f8a44f1f657"><code>8e49463</code></a>
Fix README typo (<a
href="https://redirect.github.com/actions/setup-node/issues/1226">#1226</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/setup-node/compare/49933ea5288caeca8642d1e84afbd3f7d6820020...48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/setup-node&package-manager=github_actions&previous-version=4.4.0&new-version=6.4.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-11 00:24:17 +09:00
b1937e141c fix: Hugo package naming fix (#688)
## Summary

Rebases the Hugo package naming fix from #609 on top of the current
`main` branch, including the installer flow added in #687.

- Derive Hugo release asset OS and architecture naming conventions from
the requested Hugo version.
- Apply those conventions when selecting OS and architecture segments,
including the 0.102.x macOS universal boundary, 0.103+ downcased OS
names, Windows zip assets, and Linux ARM assets.
- Add table-driven tests for pre-0.102, 0.102.x, and 0.103+ naming
behavior, plus URL coverage for the corrected release asset names.

## Changes

- Add `getConventions` to centralize version-based release asset naming
decisions.
- Update `getOS` and `getArch` to use convention flags for macOS,
lower-case OS names, standardized architecture names, and the Windows
ARM support boundary.
- Update `getURL` to generate candidate URLs for downcased Windows and
Linux assets, and for darwin universal archives.
- Wire convention detection into `installer` before generating candidate
Hugo release asset URLs.
- Expand unit coverage for OS, architecture, convention, and URL
behavior.

## Checklist

- [x] I have read the latest README and followed the instructions.
- [x] I have added or updated tests for behavior changes.
- [x] README.md and action.yml updates are not needed because inputs and
action metadata are unchanged.
- [x] I have run the relevant verification commands.

## References

- Rebased follow-up for
https://github.com/peaceiris/actions-hugo/pull/609
- References https://github.com/peaceiris/actions-hugo/issues/605 and
https://github.com/peaceiris/actions-hugo/issues/608
- Based on `main` after
https://github.com/peaceiris/actions-hugo/pull/687

## Verification

- [x] `RUNNER_TEMP=/private/tmp npm run all`
- [ ] `npm run build` was not run because this branch does not update
bundled output and current `main` removed `lib/index.js`.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Version-aware conventions control OS and architecture naming,
including macOS universal asset support and expanded darwin/macOS
patterns.

* **Refactor**
* Conventions centralized and applied across installer and URL
generation; OS/arch inputs accept varied casing and naming variants.

* **Tests**
* Expanded, data-driven parameterized tests for conventions, OS/arch
mappings, URL variants, and error cases.
* Replaced network stubs with deterministic fetch-mock helpers for test
isolation.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/peaceiris/actions-hugo/pull/688)
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Michael T Lombardi <michael.t.lombardi@gmail.com>
Co-authored-by: codefactor-io <support@codefactor.io>
Co-authored-by: Codex <noreply@openai.com>
2026-05-11 00:23:26 +09:00
Shohei UedaandCodex 189731ef00 build: update npm dependencies (#689)
## Summary

Update all direct npm dependencies and devDependencies to the current
npm latest versions and pin them exactly instead of using caret or tilde
ranges.

## Changes

- Pin all direct runtime and development package versions in
`package.json` and refresh `package-lock.json`.
- Migrate ESLint from `.eslintrc.json` to flat config for ESLint 10.
- Update Jest and TypeScript configuration and test mocks to support the
latest ESM-only packages.
- Add response status handling and typed JSON access for the latest
`node-fetch` types.

## Checklist

- [x] I have read the latest README and followed the instructions.
- [x] I have added or updated tests for behavior changes.
- [x] I have updated README.md and action.yml when inputs or runtime
behavior changed.
- [x] I have run the relevant verification commands.

## Verification

- [x] `npm --userconfig=/private/tmp/empty-npmrc outdated --json
--include=dev` returned `{}`
- [x] `npm run all`
- [x] `npm run build`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Added comprehensive test mocks for Actions APIs and fetch, improved
integration tests, and updated assertions for more precise error
validation.
  * Configured Jest to map external modules to local test mocks.

* **Chores**
* Migrated ESLint to the flat config format and replaced prior ESLint
config.
* Updated project dependencies and modernized TypeScript compiler
settings.

* **Refactor**
* Adjusted exported tool constants and made error handling more explicit
in version-fetching logic.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/peaceiris/actions-hugo/pull/689)
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Codex <noreply@openai.com>
2026-05-10 23:30:59 +09:00
peaceirisandCodex e3c35ac635 docs: document build artifact constraint
Co-Authored-By: Codex <noreply@openai.com>
2026-05-10 22:45:44 +09:00
peaceiris 8a69ba55a5 chore: delete lib/index.js 2026-05-10 22:42:05 +09:00
Shohei UedaandCodex 187a5efe81 feat: support renamed Hugo release assets (#687)
## Summary
- Support multiple Hugo release asset names for Linux, macOS, and
Windows so renamed upstream assets no longer fail with a plain 404.
- Preserve compatibility with legacy Hugo assets that used filename
forms such as `hugo_v0.20.3_*`, macOS `.zip` archives, and
`Linux_ARM`-style names.
- Add retry handling for missing candidate assets and macOS `.pkg`
extraction via `pkgutil --expand-full`, with focused URL and installer
tests plus the rebuilt `lib/index.js` bundle.

## References
- Fixes https://github.com/peaceiris/actions-hugo/issues/652
- `hugo-version: latest` still resolves through Homebrew; this change
does not fall back to an older Hugo version when the resolved release
has no compatible asset.
- Review note: `lib/index.js` is generated by `npm run build` and
contains bundled dependency code.

## Test plan
- [x] `RUNNER_TEMP=/tmp npm run all`
- [x] `npm run build`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Broadened test coverage for asset URL generation, download retry
behavior, and extraction across OSes and architectures.

* **Bug Fixes**
* More resilient installer with multiple candidate download URLs and
retry handling for transient failures.
* Improved extraction logic to correctly handle platform- and
format-specific archives.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/peaceiris/actions-hugo/pull/687)
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Codex <noreply@openai.com>
2026-05-10 22:40:55 +09:00
peaceirisandCodex d488e4d987 docs: add pull request template
Co-Authored-By: Codex <noreply@openai.com>
2026-05-10 21:44:58 +09:00
peaceiris 20e81489be chore(release): Remove build assets [skip ci] 2026-05-10 18:43:22 +09:00
49 changed files with 9335 additions and 25287 deletions
-24
View File
@@ -1,24 +0,0 @@
{
"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": {
}
}
+2 -2
View File
@@ -1,3 +1,3 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
.* @peaceiris
* @peaceiris * @peaceiris
+14
View File
@@ -0,0 +1,14 @@
## 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.
+8
View File
@@ -2,6 +2,8 @@ version: 2
updates: updates:
- package-ecosystem: npm - package-ecosystem: npm
directory: "/" directory: "/"
cooldown:
default-days: 7
schedule: schedule:
interval: daily interval: daily
time: '11:00' time: '11:00'
@@ -15,6 +17,8 @@ updates:
- package-ecosystem: "github-actions" - package-ecosystem: "github-actions"
directory: "/" directory: "/"
cooldown:
default-days: 7
schedule: schedule:
interval: "daily" interval: "daily"
time: '11:00' time: '11:00'
@@ -23,3 +27,7 @@ updates:
- "CI/CD" - "CI/CD"
commit-message: commit-message:
prefix: ci prefix: ci
groups:
codeql:
patterns:
- "github/codeql-action*"
+4 -4
View File
@@ -14,15 +14,15 @@ jobs:
contents: read contents: read
security-events: write security-events: write
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3.35.4 uses: github/codeql-action/init@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
with: with:
languages: javascript languages: javascript
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3.35.4 uses: github/codeql-action/autobuild@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3.35.4 uses: github/codeql-action/analyze@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4
+2 -2
View File
@@ -13,5 +13,5 @@ jobs:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
timeout-minutes: 5 timeout-minutes: 5
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0 - uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
+1 -1
View File
@@ -28,7 +28,7 @@ jobs:
permissions: permissions:
contents: read contents: read
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.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
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
contents: read contents: read
issues: write issues: write
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with: with:
ref: main ref: main
@@ -1,17 +0,0 @@
name: Purge image cache
on:
schedule:
- cron: '4 18 * * */7'
jobs:
purge:
runs-on: ubuntu-slim
timeout-minutes: 5
permissions: {}
steps:
- run: |
curl -sL "https://github.com/${GITHUB_REPOSITORY}" |
grep -oE '<img src="https?://camo.githubusercontent.com/[^"]+' |
sed -e 's/<img src="//' |
xargs -r -I % curl -sX PURGE %
+5 -10
View File
@@ -12,28 +12,23 @@ jobs:
permissions: permissions:
contents: write contents: write
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Dump GitHub context - name: Dump GitHub context
env: env:
GITHUB_CONTEXT: ${{ toJson(github) }} GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "${GITHUB_CONTEXT}" 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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
TAG_NAME="${GITHUB_REF##refs/tags/}" TAG_NAME="${GITHUB_REF##refs/tags/}"
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 gh release create \
./bin/hub release create \
--draft \ --draft \
--prerelease \ --prerelease \
--file ./release_notes.md \ --title "${RELEASE_NAME} ${TAG_NAME}" \
--notes-file ./release_notes.md \
"${TAG_NAME}" "${TAG_NAME}"
+54 -2
View File
@@ -17,13 +17,65 @@ jobs:
hugo-version: ['latest', '0.160.1'] hugo-version: ['latest', '0.160.1']
extended: [true, false] extended: [true, false]
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.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@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 uses: ./
with: with:
hugo-version: ${{ matrix.hugo-version }} hugo-version: ${{ matrix.hugo-version }}
extended: ${{ matrix.extended }} extended: ${{ matrix.extended }}
- name: Verify Hugo - name: Verify Hugo
run: hugo version run: hugo version
dart-sass:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-15, windows-2025, windows-11-arm]
extended: [false, true]
hugo-version: ['0.160.1']
exclude:
# Hugo 0.160.1 has no Windows arm64 extended archive.
- os: windows-11-arm
extended: true
include:
- os: ubuntu-24.04
extended: false
hugo-version: '0.114.0'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm ci
- run: npm run build
- name: Setup Hugo and Dart Sass from this PR
uses: ./
with:
hugo-version: ${{ matrix.hugo-version }}
extended: ${{ matrix.extended }}
dart-sass-version: '1.108.2'
- name: Use the legacy template API on Hugo 0.114.0
if: matrix.hugo-version == '0.114.0'
run: node -e "const fs = require('fs'); const p = '__tests__/fixtures/dart-sass/layouts/index.html'; fs.writeFileSync(p, fs.readFileSync(p, 'utf8').replace('css.Sass', 'resources.ToCSS'));"
- name: Verify standalone Dart Sass
run: sass --version
- name: Compile SCSS with Hugo and verify CSS
shell: bash
run: |
hugo --source __tests__/fixtures/dart-sass --destination "$RUNNER_TEMP/dart-sass-site"
node -e "const fs = require('fs'); const css = fs.readFileSync(process.env.RUNNER_TEMP + '/dart-sass-site/css/main.css', 'utf8'); if (!/\.dart-sass-fixture\s*\{\s*width: 4px;\s*\}/.test(css)) throw new Error(css);"
+4 -4
View File
@@ -24,9 +24,9 @@ jobs:
- 'macos-latest' - 'macos-latest'
- 'windows-latest' - 'windows-latest'
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'npm' cache: 'npm'
@@ -48,9 +48,9 @@ jobs:
- run: npm test - run: npm test
- name: Upload test coverage as artifact - name: Upload test coverage as artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with: with:
name: coverage-${{ matrix.os }} name: coverage-${{ matrix.os }}
path: coverage path: coverage
- uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5.5.4 - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
+1 -1
View File
@@ -11,7 +11,7 @@ jobs:
permissions: permissions:
contents: write contents: write
steps: steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Update major tag - name: Update major tag
run: | run: |
+1 -1
View File
@@ -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`. - `npm run build`: bundle `src/index.ts` into `lib/` with `ncc`; do not regenerate `lib/index.js` except for release work.
- `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
+89
View File
@@ -2,6 +2,95 @@
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.3.0](https://github.com/peaceiris/actions-hugo/compare/v3.2.1...v3.3.0) (2026-11-16)
### chore
* add dotfiles ([1ed797b](https://github.com/peaceiris/actions-hugo/commit/1ed797ba5bcf71a08f0a1e6c86fa48edd605d7e5))
### ci
* add seven-day Dependabot cooldowns (#768) ([e455011](https://github.com/peaceiris/actions-hugo/commit/e4550112cd731d345bd34f1f2157e59dd10b8ea5)), closes [#768](https://github.com/peaceiris/actions-hugo/issues/768)
* bump actions/checkout from 6.0.2 to 6.0.3 (#705) ([89ca553](https://github.com/peaceiris/actions-hugo/commit/89ca553e6cce579728b83911a0a0de59c7773132)), closes [#705](https://github.com/peaceiris/actions-hugo/issues/705)
* bump actions/checkout from 6.0.3 to 7.0.0 (#708) ([1574db7](https://github.com/peaceiris/actions-hugo/commit/1574db77a986d47976ec5e3c86830ab2ef7e5b21)), closes [#708](https://github.com/peaceiris/actions-hugo/issues/708)
* bump actions/checkout from 7.0.0 to 7.0.1 (#720) ([c53e8f0](https://github.com/peaceiris/actions-hugo/commit/c53e8f0d96986117de3365a97c251a0e7bb28d54)), closes [#720](https://github.com/peaceiris/actions-hugo/issues/720)
* bump actions/dependency-review-action from 4.9.0 to 5.0.0 (#698) ([9c46f58](https://github.com/peaceiris/actions-hugo/commit/9c46f58a580354d979917a06a0036ea45fd18c46)), closes [#698](https://github.com/peaceiris/actions-hugo/issues/698)
* bump actions/setup-node from 6.4.0 to 7.0.0 (#716) ([c582c0a](https://github.com/peaceiris/actions-hugo/commit/c582c0a7644f87ab057e61045fde02d26d067006)), closes [#716](https://github.com/peaceiris/actions-hugo/issues/716)
* bump actions/setup-node from 7.0.0 to 7.1.0 (#757) ([d64889d](https://github.com/peaceiris/actions-hugo/commit/d64889d521862d67e513c05c3dfeb9d200f01376)), closes [#757](https://github.com/peaceiris/actions-hugo/issues/757)
* bump actions/upload-artifact from 7.0.1 to 7.0.2 (#763) ([151819a](https://github.com/peaceiris/actions-hugo/commit/151819a2d5fa327582d39302e20ada6acba0909d)), closes [#763](https://github.com/peaceiris/actions-hugo/issues/763)
* bump codecov/codecov-action from 5.5.4 to 6.0.0 (#700) ([412dd91](https://github.com/peaceiris/actions-hugo/commit/412dd9124a017948e82471ffce56bb69fc068cd9)), closes [#700](https://github.com/peaceiris/actions-hugo/issues/700)
* bump codecov/codecov-action from 6.0.0 to 6.0.1 (#702) ([7845c37](https://github.com/peaceiris/actions-hugo/commit/7845c37f7f909e6d7ca8902ae5117b01e77d92f1)), closes [#702](https://github.com/peaceiris/actions-hugo/issues/702)
* bump codecov/codecov-action from 6.0.1 to 7.0.0 (#707) ([940247d](https://github.com/peaceiris/actions-hugo/commit/940247d08e49bd08fdbf94e0294d90305f6cb6f9)), closes [#707](https://github.com/peaceiris/actions-hugo/issues/707)
* bump codecov/codecov-action from 7.0.0 to 7.1.1 (#753) ([6a4925d](https://github.com/peaceiris/actions-hugo/commit/6a4925d6c2eaa6396e5b1de8844dc36af322888b)), closes [#753](https://github.com/peaceiris/actions-hugo/issues/753)
* bump github/codeql-action from 4.35.4 to 4.35.5 (#701) ([8d04cd0](https://github.com/peaceiris/actions-hugo/commit/8d04cd051001b32e12bf6cb92426191ec3314829)), closes [#701](https://github.com/peaceiris/actions-hugo/issues/701)
* bump github/codeql-action from 4.35.5 to 4.36.0 (#703) ([18deeac](https://github.com/peaceiris/actions-hugo/commit/18deeac04c148059823e83c0d7db71f66a0a5e8d)), closes [#703](https://github.com/peaceiris/actions-hugo/issues/703)
* bump github/codeql-action from 4.36.0 to 4.36.1 (#704) ([c4a9c2d](https://github.com/peaceiris/actions-hugo/commit/c4a9c2db4197708e4c4e0b55ac5f742b2ef8cac5)), closes [#704](https://github.com/peaceiris/actions-hugo/issues/704)
* bump github/codeql-action from 4.36.1 to 4.36.2 (#706) ([d17f2aa](https://github.com/peaceiris/actions-hugo/commit/d17f2aa363b769f5f33799d2bfd3238bd348a2ea)), closes [#706](https://github.com/peaceiris/actions-hugo/issues/706)
* bump peaceiris/actions-hugo from 3.1.0 to 3.2.1 (#699) ([1f043ee](https://github.com/peaceiris/actions-hugo/commit/1f043ee5457267b61e88d5a3f14010c4964981c4)), closes [#699](https://github.com/peaceiris/actions-hugo/issues/699)
* bump the codeql group with 3 updates (#766) ([c0cb134](https://github.com/peaceiris/actions-hugo/commit/c0cb13408983fa6ea75f5aa5bb2cf93aac963f5a)), closes [#766](https://github.com/peaceiris/actions-hugo/issues/766)
* delete .github/workflows/purge-readme-image-cache.yml ([3715a15](https://github.com/peaceiris/actions-hugo/commit/3715a155b85f6e00574e5e4179a3f450b11fded9))
* replace hub with gh for releases (#767) ([c91aeba](https://github.com/peaceiris/actions-hugo/commit/c91aeba70bff8f26385ceea61a344df0a5637ad6)), closes [#767](https://github.com/peaceiris/actions-hugo/issues/767)
* update CodeQL to 4.39.0 and group future updates (#762) ([7e5fbec](https://github.com/peaceiris/actions-hugo/commit/7e5fbec1a9c1b61336aeb2d5a25dd950e4dfddf4)), closes [#762](https://github.com/peaceiris/actions-hugo/issues/762)
### deps
* bump the npm_and_yarn group across 1 directory with 2 updates (#745) ([c21c4c2](https://github.com/peaceiris/actions-hugo/commit/c21c4c2f1d819b78a69ebb6868b2df2b305ca668)), closes [#745](https://github.com/peaceiris/actions-hugo/issues/745)
* bump the npm_and_yarn group across 1 directory with 2 updates (#765) ([1df2a73](https://github.com/peaceiris/actions-hugo/commit/1df2a73aebbb5596f5ad2e6154135eac8aa335fd)), closes [#765](https://github.com/peaceiris/actions-hugo/issues/765)
### docs
* remove Verification ([4a56969](https://github.com/peaceiris/actions-hugo/commit/4a56969a09b27c128c1a1eaf013ff9aacec295dd))
### feat
* add optional verified Dart Sass installation (#769) ([c02355f](https://github.com/peaceiris/actions-hugo/commit/c02355f4dfec642ae0895990bfdf5f7f5d14cd3b)), closes [#769](https://github.com/peaceiris/actions-hugo/issues/769)
## [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) # [3.1.0](https://github.com/peaceiris/actions-hugo/compare/v3.0.0...v3.1.0) (2026-05-10)
+37
View File
@@ -42,6 +42,7 @@ Thanks to this change, we can complete this action in less than a few seconds.
- [Getting started](#getting-started) - [Getting started](#getting-started)
- [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow) - [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow)
- [Options](#options) - [Options](#options)
- [⭐️ Install Dart Sass](#%EF%B8%8F-install-dart-sass)
- [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended) - [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended)
- [⭐️ Use the latest version of Hugo](#%EF%B8%8F-use-the-latest-version-of-hugo) - [⭐️ Use the latest version of Hugo](#%EF%B8%8F-use-the-latest-version-of-hugo)
- [Tips](#tips) - [Tips](#tips)
@@ -115,6 +116,42 @@ jobs:
## Options ## Options
### ⭐️ Install Dart Sass
Set `dart-sass-version` to a fixed standalone [Dart Sass](https://github.com/sass/dart-sass) release version:
```yaml
- uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.160.1'
dart-sass-version: '1.108.2'
- run: hugo --minify
```
In your Hugo template, select the Dart Sass transpiler:
```go-html-template
{{ $css := resources.Get "scss/main.scss" | css.Sass (dict "transpiler" "dartsass") }}
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
```
Requires **Hugo 0.114.0 or later**; on older template APIs, use `resources.ToCSS`
instead of `css.Sass`. Dart Sass works independently of `extended`. The old
`dart-sass-embedded` protocol is not supported.
Use a fixed `major.minor.patch` version. Omitting `dart-sass-version` or leaving it
empty skips Sass entirely. Linux **glibc**, macOS, and Windows runners on **x64 or arm64** are
supported when the selected release has the matching asset; musl is unsupported.
The `github-token` input defaults to `${{ github.token }}`; read-only permissions suffice.
Archives must have a valid GitHub API SHA-256 digest and pass verification before
extraction or execution. Missing digests or assets, API errors, and mismatches fail
the action. This checks integrity against the same publisher, not a signature or
an independent immutable checksum pin.
See [Dart Sass details](docs/dart-sass.md) for version and platform selection,
token overrides, failure modes, and the security trust model.
### ⭐️ Use Hugo extended ### ⭐️ Use Hugo extended
Set `extended: true` to use a Hugo extended version. Set `extended: true` to use a Hugo extended version.
@@ -0,0 +1,5 @@
@use 'sass:math';
$width: math.div(12px, 3);
.dart-sass-fixture {
width: $width;
}
+2
View File
@@ -0,0 +1,2 @@
baseURL = 'https://example.org/'
disableKinds = ['taxonomy', 'term', 'RSS', 'sitemap']
@@ -0,0 +1,2 @@
{{ $css := resources.Get "main.scss" | css.Sass (dict "transpiler" "dartsass" "targetPath" "css/main.css") }}
<!doctype html><html><head><link rel="stylesheet" href="{{ $css.RelPermalink }}"></head><body>Dart Sass integration</body></html>
+129 -9
View File
@@ -1,15 +1,135 @@
import getArch from '../src/get-arch'; import getArch from '../src/get-arch';
describe('getArch', () => { describe('getArch', () => {
test('processor architecture', () => { const groups = [
expect(getArch('x64')).toBe('64bit'); {
expect(getArch('arm')).toBe('ARM'); condition: 'when hugo version < 0.102.0',
expect(getArch('arm64')).toBe('ARM64'); conventions: {
}); 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}]
}
];
test('exception', () => { const passingTests = groups.flatMap(group =>
group.tests
.filter(example => !example.throws)
.map(example => ({
...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(() => { expect(() => {
getArch('mips'); getArch(arch, os, conventions);
}).toThrowError('mips is not supported'); }).toThrow(`${arch} is not supported`);
}); }
);
}); });
+61
View File
@@ -0,0 +1,61 @@
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);
});
});
+10 -8
View File
@@ -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(() => {
nock.cleanAll(); clearMockFetchResponses();
}); });
describe('getURL()', () => { describe('getURL()', () => {
@@ -27,24 +27,26 @@ describe('getURL()', () => {
describe('getLatestVersion()', () => { describe('getLatestVersion()', () => {
test('return latest version via brew', async () => { test('return latest version via brew', async () => {
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 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 () => {
nock('https://api.github.com') mockFetchResponse(
.get(`/repos/${Tool.Org}/${Tool.Repo}/releases/latest`) `https://api.github.com/repos/${Tool.Org}/${Tool.Repo}/releases/latest`,
.reply(200, jsonTestGithub); 200,
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 () => {
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404); mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 404);
await expect(getLatestVersion(Tool.Org, Tool.Repo, 'brew')).rejects.toThrowError(FetchError); await expect(getLatestVersion(Tool.Org, Tool.Repo, 'brew')).rejects.toThrow(FetchError);
}); });
}); });
+91 -6
View File
@@ -1,15 +1,100 @@
import getOS from '../src/get-os'; import getOS from '../src/get-os';
describe('getOS', () => { describe('getOS', () => {
test('os type', () => { const groups = [
expect(getOS('linux')).toBe('Linux'); {
expect(getOS('darwin')).toBe('macOS'); condition: 'when hugo version < 0.102.0',
expect(getOS('win32')).toBe('Windows'); conventions: {
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'); getOS('centos', conventions);
}).toThrowError('centos is not supported'); }).toThrow('centos is not supported');
}); });
}); });
+156 -15
View File
@@ -1,20 +1,161 @@
import getURL from '../src/get-url'; import getURL, {getDownloadVersion} from '../src/get-url';
describe('getURL()', () => { describe('getURL()', () => {
test('get a URL to an asset for each platform', () => { test('get URLs to Linux assets', () => {
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2'; const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`; expect(getURL('Linux', '64bit', 'false', '0.58.2')).toEqual([
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_64bit.tar.gz`,
const urlMacOSExtended = `${baseURL}/hugo_extended_0.58.2_macOS-64bit.tar.gz`; `${baseURL}/hugo_0.58.2_linux-amd64.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_64bit.tar.gz`,
expect(getURL('Linux', '64bit', 'true', '0.58.2')).not.toBe(urlLinux); `${baseURL}/hugo_v0.58.2_linux-amd64.tar.gz`
expect(getURL('MyOS', '64bit', 'false', '0.58.2')).not.toBe(urlLinux); ]);
expect(getURL('Linux', '64bit', 'false', '0.58.1')).not.toBe(urlLinux); expect(getURL('Linux', 'ARM64', 'true', '0.58.2')).toEqual([
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_0.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`,
`${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`
]);
}); });
}); });
+298
View File
@@ -0,0 +1,298 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec';
import fetch from 'node-fetch';
import {createHash} from 'crypto';
import {mkdtemp, writeFile, rm} from 'fs/promises';
import {tmpdir} from 'os';
import * as path from 'path';
import {
getDartSassAssetName,
installDartSass,
verifyDartSassArchive
} from '../src/install-dart-sass';
jest.mock('node-fetch');
const version = '1.108.2';
const body = 'test archive bytes';
const digest = `sha256:${createHash('sha256').update(body).digest('hex')}`;
const mockedFetch = jest.mocked(fetch);
const originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform')!;
const originalArch = Object.getOwnPropertyDescriptor(process, 'arch')!;
let directory: string;
let archive: string;
beforeEach(async () => {
directory = await mkdtemp(path.join(tmpdir(), 'dart-sass-test-'));
archive = path.join(directory, 'archive');
await writeFile(archive, body);
jest.spyOn(tc, 'downloadTool').mockResolvedValue(archive);
jest.spyOn(tc, 'extractTar').mockResolvedValue(directory);
jest.spyOn(tc, 'extractZip').mockResolvedValue(directory);
jest.spyOn(core, 'addPath').mockImplementation(() => {});
jest.spyOn(exec, 'exec').mockResolvedValue(0);
mockedFetch.mockReset();
});
afterEach(async () => {
Object.defineProperty(process, 'platform', originalPlatform);
Object.defineProperty(process, 'arch', originalArch);
jest.restoreAllMocks();
await rm(directory, {recursive: true, force: true});
});
function metadata(overrides: Record<string, unknown> = {}): void {
const name = getDartSassAssetName(version, process.platform, process.arch, '2.39');
mockedFetch.mockResolvedValue({
ok: true,
json: async () => ({
tag_name: version,
assets: [
{
name,
digest,
browser_download_url: `https://github.com/sass/dart-sass/releases/download/${version}/${name}`,
...overrides
}
]
})
} as Awaited<ReturnType<typeof fetch>>);
}
function expectNoInstallation(): void {
expect(tc.extractTar).not.toHaveBeenCalled();
expect(tc.extractZip).not.toHaveBeenCalled();
expect(exec.exec).not.toHaveBeenCalled();
expect(core.addPath).not.toHaveBeenCalled();
}
test('empty input makes no network calls or PATH changes', async () => {
await installDartSass('', 'unused-token');
expect(fetch).not.toHaveBeenCalled();
expect(tc.downloadTool).not.toHaveBeenCalled();
expectNoInstallation();
});
test.each([
'latest',
'^1.89.1',
'1.89',
'v1.89.1',
'01.89.1',
'1.89.1-beta.1',
'https://example.com/sass',
'../1.89.1'
])('rejects non-fixed input %s before network access', async value => {
await expect(installDartSass(value)).rejects.toThrow('fixed version');
expect(fetch).not.toHaveBeenCalled();
expectNoInstallation();
});
test.each([
['linux', 'x64', 'linux-x64.tar.gz'],
['linux', 'arm64', 'linux-arm64.tar.gz'],
['darwin', 'x64', 'macos-x64.tar.gz'],
['darwin', 'arm64', 'macos-arm64.tar.gz'],
['win32', 'x64', 'windows-x64.zip'],
['win32', 'arm64', 'windows-arm64.zip']
])('maps %s/%s exactly', (platform, arch, suffix) => {
expect(getDartSassAssetName(version, platform, arch, '2.39')).toBe(
`dart-sass-${version}-${suffix}`
);
});
test.each([
['freebsd', 'x64'],
['linux', 'ia32'],
['darwin', 'arm'],
['win32', 'riscv64']
])('rejects unsupported %s/%s', (platform, arch) => {
expect(() => getDartSassAssetName(version, platform, arch, '2.39')).toThrow('Unsupported');
});
test('rejects musl or unknown libc', () => {
expect(() => getDartSassAssetName(version, 'linux', 'x64')).toThrow('glibc');
});
test.each([
undefined,
null,
'',
'sha512:' + 'a'.repeat(64),
'sha256:' + 'a'.repeat(63),
'sha256:' + 'g'.repeat(64)
])('rejects missing or malformed digest %s before download', async invalid => {
metadata({digest: invalid});
await expect(installDartSass(version)).rejects.toThrow('no valid GitHub API SHA-256 digest');
expect(tc.downloadTool).not.toHaveBeenCalled();
expectNoInstallation();
});
test('rejects checksum mismatch before extraction or execution', async () => {
metadata({digest: 'sha256:' + '0'.repeat(64)});
await expect(installDartSass(version)).rejects.toThrow('SHA-256 mismatch');
expectNoInstallation();
});
test('rejects missing archive', async () => {
metadata({name: 'another-platform.tar.gz'});
await expect(installDartSass(version)).rejects.toThrow('no release asset');
expect(tc.downloadTool).not.toHaveBeenCalled();
expectNoInstallation();
});
test('rejects unexpected download URL', async () => {
metadata({browser_download_url: 'https://example.com/archive'});
await expect(installDartSass(version)).rejects.toThrow('Unexpected download URL');
expect(tc.downloadTool).not.toHaveBeenCalled();
expectNoInstallation();
});
test.each([403, 404, 429, 500])('fails closed on API HTTP %s', async status => {
mockedFetch.mockResolvedValue({ok: false, status} as Awaited<ReturnType<typeof fetch>>);
await expect(installDartSass(version)).rejects.toThrow(`HTTP ${status}`);
expect(tc.downloadTool).not.toHaveBeenCalled();
expectNoInstallation();
});
test('fails closed on network error', async () => {
mockedFetch.mockRejectedValue(new Error('network failed'));
await expect(installDartSass(version)).rejects.toThrow('Unable to fetch Dart Sass');
expectNoInstallation();
});
test.each([null, {}, {tag_name: 'other', assets: []}, {tag_name: version, assets: null}])(
'rejects malformed release metadata %j',
async release => {
mockedFetch.mockResolvedValue({ok: true, json: async () => release} as Awaited<
ReturnType<typeof fetch>
>);
await expect(installDartSass(version)).rejects.toThrow('Invalid Dart Sass');
expectNoInstallation();
}
);
test('fails closed on invalid JSON', async () => {
mockedFetch.mockResolvedValue({
ok: true,
status: 200,
json: async (): Promise<unknown> => {
throw new Error('invalid JSON');
}
} as Awaited<ReturnType<typeof fetch>>);
await expect(installDartSass(version)).rejects.toThrow('Invalid Dart Sass');
expectNoInstallation();
});
test('fails closed on download or read failure', async () => {
metadata();
jest.mocked(tc.downloadTool).mockRejectedValueOnce(new Error('download failed'));
await expect(installDartSass(version)).rejects.toThrow('download failed');
jest.mocked(tc.downloadTool).mockResolvedValueOnce(path.join(directory, 'missing'));
await expect(installDartSass(version)).rejects.toThrow('ENOENT');
expectNoInstallation();
});
test('verifies bytes then preserves the whole standalone directory on PATH', async () => {
metadata();
await installDartSass(version);
const extract = process.platform === 'win32' ? tc.extractZip : tc.extractTar;
expect(extract).toHaveBeenCalledWith(archive);
expect(core.addPath).toHaveBeenCalledWith(path.join(directory, 'dart-sass'));
expect(exec.exec).not.toHaveBeenCalled();
});
test('accepts uppercase checksum hex but rejects invalid verification input', async () => {
await expect(
verifyDartSassArchive(archive, 'sha256:' + digest.slice(7).toUpperCase())
).resolves.toBeUndefined();
await expect(verifyDartSassArchive(archive, '')).rejects.toThrow('no valid');
});
test.each([
['linux', 'x64'],
['linux', 'arm64'],
['darwin', 'x64'],
['darwin', 'arm64'],
['win32', 'x64'],
['win32', 'arm64']
])('installs the verified archive for %s/%s', async (platform, arch) => {
Object.defineProperty(process, 'platform', {value: platform, configurable: true});
Object.defineProperty(process, 'arch', {value: arch, configurable: true});
jest
.spyOn(process.report, 'getReport')
.mockReturnValue({header: {glibcVersionRuntime: '2.39'}} as unknown as ReturnType<
typeof process.report.getReport
>);
metadata();
await installDartSass(version);
const extract = platform === 'win32' ? tc.extractZip : tc.extractTar;
const otherExtract = platform === 'win32' ? tc.extractTar : tc.extractZip;
expect(extract).toHaveBeenCalledWith(archive);
expect(otherExtract).not.toHaveBeenCalled();
expect(core.addPath).toHaveBeenCalledWith(path.join(directory, 'dart-sass'));
});
test('does not add PATH if extraction fails', async () => {
metadata();
jest.mocked(tc.extractTar).mockRejectedValue(new Error('extraction failed'));
jest.mocked(tc.extractZip).mockRejectedValue(new Error('extraction failed'));
await expect(installDartSass(version)).rejects.toThrow('extraction failed');
expect(core.addPath).not.toHaveBeenCalled();
});
test('uses the explicit token only for exact-origin metadata and refuses redirects', async () => {
metadata();
const info = jest.spyOn(core, 'info');
const debug = jest.spyOn(core, 'debug');
await installDartSass(version, 'test-token');
expect(fetch).toHaveBeenCalledWith(
`https://api.github.com/repos/sass/dart-sass/releases/tags/${version}`,
expect.objectContaining({
headers: expect.objectContaining({Authorization: 'Bearer test-token'}),
redirect: 'error'
})
);
expect(jest.mocked(tc.downloadTool).mock.calls[0]).toHaveLength(1);
expect(JSON.stringify(jest.mocked(tc.downloadTool).mock.calls)).not.toContain('test-token');
expect(JSON.stringify(info.mock.calls)).not.toContain('test-token');
expect(JSON.stringify(debug.mock.calls)).not.toContain('test-token');
});
test.each(['', 'explicit-token'])(
'never uses a stale environment token with input %j',
async token => {
const original = process.env.GITHUB_TOKEN;
process.env.GITHUB_TOKEN = 'stale-environment-token';
try {
metadata();
await installDartSass(version, token);
const headers = mockedFetch.mock.calls[0][1]?.headers;
expect((headers as Record<string, string>).Authorization).toBe(
token ? 'Bearer explicit-token' : undefined
);
expect(JSON.stringify(mockedFetch.mock.calls)).not.toContain('stale-environment-token');
} finally {
if (original === undefined) delete process.env.GITHUB_TOKEN;
else process.env.GITHUB_TOKEN = original;
}
}
);
test('does not expose token-bearing transport or parsing errors', async () => {
mockedFetch.mockRejectedValueOnce(new Error('transport error containing secret-token'));
await expect(installDartSass(version, 'secret-token')).rejects.toEqual(
new Error(`Unable to fetch Dart Sass ${version} release metadata.`)
);
mockedFetch.mockResolvedValueOnce({
ok: true,
json: async (): Promise<unknown> => {
throw new Error('parse error containing secret-token');
}
} as Awaited<ReturnType<typeof fetch>>);
await expect(installDartSass(version, 'secret-token')).rejects.toEqual(
new Error(`Invalid Dart Sass ${version} release metadata.`)
);
expectNoInstallation();
});
+136
View File
@@ -0,0 +1,136 @@
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);
});
});
+37 -7
View File
@@ -1,9 +1,12 @@
import * as main from '../src/main'; import * as main from '../src/main';
import * as core from '@actions/core';
import * as sass from '../src/install-dart-sass';
import {readFileSync} from 'fs';
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,7 +22,8 @@ describe('Integration testing run()', () => {
await io.rmRF(workDir); await io.rmRF(workDir);
delete process.env['INPUT_HUGO-VERSION']; delete process.env['INPUT_HUGO-VERSION'];
nock.cleanAll(); delete process.env['INPUT_EXTENDED'];
clearMockFetchResponses();
}); });
test('succeed in installing a custom version', async () => { test('succeed in installing a custom version', async () => {
@@ -43,7 +47,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;
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 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}`);
@@ -53,7 +57,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';
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 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}`);
@@ -62,9 +66,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';
nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404); mockFetchResponse(`https://formulae.brew.sh/api/formula/${Tool.Repo}.json`, 404);
await expect(main.run()).rejects.toThrowError(FetchError); await expect(main.run()).rejects.toThrow(FetchError);
}); });
}); });
@@ -81,6 +85,32 @@ describe('showVersion()', () => {
}); });
test('return not found', async () => { test('return not found', async () => {
await expect(main.showVersion('gitgit', ['--version'])).rejects.toThrowError(Error); await expect(main.showVersion('gitgit', ['--version'])).rejects.toThrow('spawn gitgit ENOENT');
}); });
}); });
describe('Dart Sass token input plumbing', () => {
afterEach(() => jest.restoreAllMocks());
test('declares the runner-resolved GitHub token as the default', () => {
const metadata = readFileSync(path.join(__dirname, '..', 'action.yml'), 'utf8');
expect(metadata).toMatch(/github-token:[\s\S]*?default: \$\{\{ github.token \}\}/);
});
test.each(['runner-resolved-default-token', 'explicit-token', ''])(
'passes the resolved github-token input %j explicitly to Sass',
async token => {
jest.spyOn(core, 'getInput').mockImplementation(name => {
const inputs: Record<string, string> = {
'hugo-version': Tool.TestVersionSpec,
'dart-sass-version': '1.108.2',
'github-token': token
};
return inputs[name] || '';
});
const install = jest.spyOn(sass, 'installDartSass').mockResolvedValue();
await main.run();
expect(install).toHaveBeenCalledWith('1.108.2', token);
}
);
});
+17
View File
@@ -0,0 +1,17 @@
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;
}
+36
View File
@@ -0,0 +1,36 @@
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);
});
});
}
+12
View File
@@ -0,0 +1,12 @@
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;
}
+18
View File
@@ -0,0 +1,18 @@
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';
}
+80
View File
@@ -0,0 +1,80 @@
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'));
});
});
}
+8
View File
@@ -10,6 +10,14 @@ inputs:
description: 'Download (if necessary) and use Hugo extended version. Example: true' description: 'Download (if necessary) and use Hugo extended version. Example: true'
required: false required: false
default: 'false' default: 'false'
dart-sass-version:
description: 'Optional fixed standalone Dart Sass version (e.g. 1.108.2). Requires a GitHub API SHA-256 digest.'
required: false
default: ''
github-token:
description: 'GitHub token for Dart Sass release metadata. Read-only permissions suffice; set empty for unauthenticated requests.'
required: false
default: ${{ github.token }}
runs: runs:
using: 'node24' using: 'node24'
main: 'lib/index.js' main: 'lib/index.js'
+91
View File
@@ -0,0 +1,91 @@
# Dart Sass installation details
See the [README](../README.md) for workflow and Hugo template examples.
## Inputs and compatibility
`dart-sass-version` is optional and defaults to an empty string. When omitted or
empty, it causes no Sass network requests, installation, or PATH changes. When
set, it must be a fixed `major.minor.patch` version, such as `1.108.2`. The action
rejects `latest`, ranges, `v` prefixes, prereleases, and arbitrary download URLs.
The installer uses standalone releases from [sass/dart-sass](https://github.com/sass/dart-sass).
Hugo **0.114.0 or later** is required to use this standalone executable. Select
`"transpiler" "dartsass"` in `css.Sass`, or in `resources.ToCSS` on older Hugo
versions. Installation is independent of the `extended` input. The old
`dart-sass-embedded` executable and protocol are outside this action's support.
## Platform and archive selection
The action selects the exact archive for the requested version and the Node
runtime's operating system and architecture:
| Runner | Architectures | Archive suffix |
| --- | --- | --- |
| Linux with glibc | x64, arm64 | `linux-<arch>.tar.gz` |
| macOS | x64, arm64 | `macos-<arch>.tar.gz` |
| Windows | x64, arm64 | `windows-<arch>.zip` |
The full asset name is `dart-sass-<version>-<suffix>`. The selected release must
publish that exact asset. There is no fallback to another version, architecture,
or download host. Linux musl (including Alpine), unknown libc, and unsupported
operating systems or architectures are rejected. Linux detection uses Node's
runtime report to confirm glibc.
After verification, the action extracts the entire standalone `dart-sass`
directory and adds that directory to PATH. Its launcher and sibling `src` runtime
stay together, making `sass` available to subsequent workflow steps. Installing
Sass does not change which Hugo archives a release provides; for example, Hugo
0.160.1 has a Windows arm64 standard archive but no Windows arm64 extended archive.
## GitHub authentication
The `github-token` input defaults to `${{ github.token }}`. Read-only permissions
suffice; no additional write permissions are needed. The token authenticates only
the exact release metadata endpoint on `https://api.github.com`, with redirects
disabled. It is never passed to archive downloads or included in installer logs
or errors.
To use another token, set the input explicitly:
```yaml
- uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.160.1'
dart-sass-version: '1.108.2'
github-token: ${{ secrets.SASS_METADATA_TOKEN }}
```
Set `github-token: ''` to make unauthenticated metadata requests instead. This has
lower API rate limits. An explicitly empty input remains empty: the action never
falls back to `GITHUB_TOKEN` or another environment token. When Sass is disabled,
the action does not make a Sass metadata request regardless of the token input.
## Integrity checks and failures
The action fetches official release metadata for the requested version, confirms
the tag and matching asset, and requires a digest in the form `sha256:<64 hex digits>`.
It also checks that the download URL matches the expected official release URL.
After downloading, it computes the archive's SHA-256 digest and compares it with
the API digest **before extraction or execution**.
The action fails closed on:
- Unsupported platforms, invalid versions, or missing release assets.
- API failures, including authentication errors, rate limits, redirects, and invalid metadata.
- Missing or malformed digests, download/read errors, or checksum mismatches.
- Extraction failures; the Sass directory is not added to PATH if extraction fails.
There is no manual checksum input or unverified fallback. Older releases often
have no API digest, including 1.89.0 and earlier. Choose a release with
digest-bearing assets, such as 1.108.2. The installer checks the actual metadata;
it does not infer digest or asset availability from the version number alone.
## Trust model
The digest and archive come from the same publisher through GitHub. Verification
checks that the downloaded bytes match the publisher's current metadata. It is
not a signature, provenance attestation, or an independent immutable checksum
pin. A fixed version does not independently prevent replacement of a release
asset and its digest. GitHub API availability and the integrity of the publisher's
release metadata remain part of the trust and availability model.
+40
View File
@@ -0,0 +1,40 @@
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
}
}
}
];
+15 -1
View File
@@ -4,8 +4,22 @@ 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-jest' '^.+\\.ts$': [
'ts-jest',
{
tsconfig: {
types: ['jest', 'node']
}
}
]
}, },
verbose: true verbose: true
} }
-11730
View File
File diff suppressed because one or more lines are too long
+7501 -13383
View File
File diff suppressed because it is too large Load Diff
+22 -23
View File
@@ -1,6 +1,6 @@
{ {
"name": "actions-hugo", "name": "actions-hugo",
"version": "3.1.0", "version": "3.3.0",
"description": "GitHub Actions for Hugo", "description": "GitHub Actions for Hugo",
"main": "lib/index.js", "main": "lib/index.js",
"engines": { "engines": {
@@ -47,29 +47,28 @@
}, },
"homepage": "https://github.com/peaceiris/actions-hugo#readme", "homepage": "https://github.com/peaceiris/actions-hugo#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "3.0.1",
"@actions/exec": "^1.1.1", "@actions/exec": "3.0.0",
"@actions/io": "^1.1.0", "@actions/io": "3.0.2",
"@actions/tool-cache": "^1.7.2", "@actions/tool-cache": "4.0.0",
"node-fetch": "^2.6.1" "node-fetch": "3.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.20", "@types/jest": "30.0.0",
"@types/node": "~24", "@types/node": "25.6.2",
"@types/node-fetch": "^2.5.8", "@typescript-eslint/eslint-plugin": "8.59.2",
"@typescript-eslint/eslint-plugin": "^4.16.1", "@typescript-eslint/parser": "8.59.2",
"@typescript-eslint/parser": "^4.16.1", "@vercel/ncc": "0.38.4",
"@vercel/ncc": "^0.38.1", "eslint": "10.3.0",
"eslint": "^7.21.0", "eslint-plugin-jest": "29.15.2",
"eslint-plugin-jest": "^24.1.5", "husky": "9.1.7",
"husky": "^5.1.3", "jest": "30.4.2",
"jest": "^26.6.3", "jest-circus": "30.4.2",
"jest-circus": "^26.6.3", "lint-staged": "17.0.4",
"lint-staged": "^10.5.4", "nock": "14.0.15",
"nock": "^13.0.10", "prettier": "3.8.3",
"prettier": "2.2.1", "standard-version": "9.5.0",
"standard-version": "^9.1.1", "ts-jest": "29.4.9",
"ts-jest": "^26.5.3", "typescript": "6.0.3"
"typescript": "^4.9.5"
} }
} }
+9 -9
View File
@@ -1,12 +1,12 @@
export enum Tool { export const 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',
+14 -4
View File
@@ -1,11 +1,21 @@
export default function getArch(arch: string): string { import {conventions} from './get-conventions';
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 '64bit'; return conventions.arch.standardizedNaming ? 'amd64' : '64bit';
case 'arm': case 'arm':
return 'ARM'; if (conventions.arch.droppedWindowsArmSupport && (os === 'Windows' || os === 'windows')) {
throw new Error(`${arch} is not supported`);
}
return conventions.arch.standardizedNaming ? 'arm' : 'ARM';
case 'arm64': case 'arm64':
return 'ARM64'; return conventions.arch.standardizedNaming ? 'arm64' : 'ARM64';
default: default:
throw new Error(`${arch} is not supported`); throw new Error(`${arch} is not supported`);
} }
+29
View File
@@ -0,0 +1,29 @@
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
}
};
}
+17 -3
View File
@@ -1,4 +1,14 @@
import fetch from 'node-fetch'; import fetch, {FetchError} 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 = '';
@@ -15,12 +25,16 @@ 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.versions.stable; latestVersion = (json as BrewFormulaResponse).versions.stable;
} else if (api === 'github') { } else if (api === 'github') {
latestVersion = json.tag_name; latestVersion = (json as GitHubReleaseResponse).tag_name;
} }
return latestVersion; return latestVersion;
} }
+6 -4
View File
@@ -1,11 +1,13 @@
export default function getOS(platform: string): string { import {conventions} from './get-conventions';
export default function getOS(platform: string, conventions: conventions): string {
switch (platform) { switch (platform) {
case 'linux': case 'linux':
return 'Linux'; return conventions.os.downcasedAll ? 'linux' : 'Linux';
case 'darwin': case 'darwin':
return 'macOS'; return conventions.os.renamedMacOS ? 'darwin' : 'macOS';
case 'win32': case 'win32':
return 'Windows'; return conventions.os.downcasedAll ? 'windows' : 'Windows';
default: default:
throw new Error(`${platform} is not supported`); throw new Error(`${platform} is not supported`);
} }
+74 -9
View File
@@ -3,7 +3,9 @@ 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_';
@@ -14,17 +16,80 @@ export default function getURL(
} }
}; };
const ext = (os: string): string => { const lowerArch = (arch: string): string => {
if (os === 'Windows') { switch (arch) {
return 'zip'; case '64bit':
} else { return 'amd64';
return 'tar.gz'; case 'ARM':
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 url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`; const assetBase = `hugo_${extendedStr(extended)}${downloadVersion}_`;
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}`;
});
};
return url; if (os === 'macOS') {
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;
} }
+120
View File
@@ -0,0 +1,120 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import {createHash} from 'crypto';
import {createReadStream} from 'fs';
import * as path from 'path';
import fetch from 'node-fetch';
interface ReleaseAsset {
name: string;
digest?: string | null;
browser_download_url: string;
}
interface Release {
tag_name: string;
assets: ReleaseAsset[];
}
export function getDartSassAssetName(
version: string,
platform: string,
arch: string,
glibcVersion?: string
): string {
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(version)) {
throw new Error('dart-sass-version must be a fixed version such as 1.108.2 (without v).');
}
const platforms: Record<string, string> = {linux: 'linux', darwin: 'macos', win32: 'windows'};
const os = platforms[platform];
if (!os || !['x64', 'arm64'].includes(arch)) {
throw new Error(`Unsupported Dart Sass platform: ${platform}/${arch}.`);
}
if (platform === 'linux' && !glibcVersion) {
throw new Error('Dart Sass requires Linux with glibc; musl and unknown libc are unsupported.');
}
const extension = platform === 'win32' ? 'zip' : 'tar.gz';
return `dart-sass-${version}-${os}-${arch}.${extension}`;
}
export async function verifyDartSassArchive(archive: string, digest: string): Promise<void> {
if (!/^sha256:[a-fA-F0-9]{64}$/.test(digest)) {
throw new Error('Dart Sass release asset has no valid GitHub API SHA-256 digest.');
}
const hash = createHash('sha256');
for await (const chunk of createReadStream(archive)) {
hash.update(chunk);
}
if (hash.digest('hex') !== digest.slice(7).toLowerCase()) {
throw new Error('Dart Sass archive SHA-256 mismatch; refusing to extract or execute it.');
}
}
export async function installDartSass(version: string, token = ''): Promise<void> {
if (version === '') {
return;
}
// Node's report identifies the libc actually used by this runner. Do not assume
// Linux means glibc or silently install an incompatible archive on musl.
const header =
process.platform === 'linux'
? (process.report?.getReport() as {header?: {glibcVersionRuntime?: string}})?.header
: undefined;
const name = getDartSassAssetName(
version,
process.platform,
process.arch,
header?.glibcVersionRuntime
);
const headers: Record<string, string> = {
'User-Agent': 'peaceiris/actions-hugo',
Accept: 'application/vnd.github+json'
};
if (token) {
headers.Authorization = `Bearer ${token}`;
}
let response;
try {
response = await fetch(`https://api.github.com/repos/sass/dart-sass/releases/tags/${version}`, {
headers,
redirect: 'error'
});
} catch {
// Do not surface transport errors that may contain request headers.
throw new Error(`Unable to fetch Dart Sass ${version} release metadata.`);
}
if (!response.ok) {
throw new Error(
`Unable to fetch Dart Sass ${version} release metadata: HTTP ${response.status}.`
);
}
let release: Release | null;
try {
release = (await response.json()) as Release | null;
} catch {
throw new Error(`Invalid Dart Sass ${version} release metadata.`);
}
if (release?.tag_name !== version || !Array.isArray(release.assets)) {
throw new Error(`Invalid Dart Sass ${version} release metadata.`);
}
const asset = release.assets.find(candidate => candidate?.name === name);
if (!asset) {
throw new Error(`Dart Sass ${version} has no release asset for this runner: ${name}.`);
}
if (typeof asset.digest !== 'string' || !/^sha256:[a-fA-F0-9]{64}$/.test(asset.digest)) {
throw new Error(`Dart Sass asset ${name} has no valid GitHub API SHA-256 digest.`);
}
const url = `https://github.com/sass/dart-sass/releases/download/${version}/${name}`;
if (asset.browser_download_url !== url) {
throw new Error(`Unexpected download URL for Dart Sass asset ${name}.`);
}
const archive = await tc.downloadTool(url);
await verifyDartSassArchive(archive, asset.digest);
// Keep the launcher and its sibling src runtime together, including on Windows.
const extracted = name.endsWith('.zip')
? await tc.extractZip(archive)
: await tc.extractTar(archive);
core.addPath(path.join(extracted, 'dart-sass'));
core.info(`Dart Sass version: ${version}`);
}
+81 -15
View File
@@ -1,12 +1,19 @@
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 from './get-url'; import getURL, {getDownloadVersion} 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 = '';
@@ -43,31 +50,90 @@ 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 osName: string = getOS(process.platform); const conventions = getConventions(version);
const osName: string = getOS(process.platform, conventions);
core.debug(`Operating System: ${osName}`); core.debug(`Operating System: ${osName}`);
const archName: string = getArch(process.arch); const archName: string = getArch(process.arch, osName, conventions);
core.debug(`Processor Architecture: ${archName}`); core.debug(`Processor Architecture: ${archName}`);
const toolURL: string = getURL(osName, archName, extended, version); const toolURLs: string[] = getURL(osName, archName, extended, version);
core.debug(`toolURL: ${toolURL}`); const downloadVersion = getDownloadVersion(version);
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 toolAssets: string = await tc.downloadTool(toolURL); const toolAsset: DownloadedAsset = await downloadHugoAsset(toolURLs);
let toolBin = ''; await extractHugoAsset(toolAsset.path, toolAsset.url, tempDir, binDir);
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
View File
@@ -3,6 +3,7 @@ import * as exec from '@actions/exec';
import {getLatestVersion} from './get-latest-version'; import {getLatestVersion} from './get-latest-version';
import {installer} from './installer'; import {installer} from './installer';
import {Tool} from './constants'; import {Tool} from './constants';
import {installDartSass} from './install-dart-sass';
export interface ActionResult { export interface ActionResult {
exitcode: number; exitcode: number;
@@ -47,6 +48,7 @@ export async function run(): Promise<ActionResult> {
core.info(`${Tool.Name} version: ${installVersion}`); core.info(`${Tool.Name} version: ${installVersion}`);
await installer(installVersion); await installer(installVersion);
await installDartSass(core.getInput('dart-sass-version'), core.getInput('github-token'));
result = await showVersion(Tool.CmdName, [Tool.CmdOptVersion]); result = await showVersion(Tool.CmdName, [Tool.CmdOptVersion]);
return result; return result;
+3 -2
View File
@@ -1,7 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": ["ES2019"], "lib": ["ES2019"],
"module": "commonjs", "module": "ESNext",
"moduleResolution": "bundler",
"target": "ES2019", "target": "ES2019",
"sourceMap": true, "sourceMap": true,
"outDir": "./lib", "outDir": "./lib",
@@ -12,5 +13,5 @@
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true "resolveJsonModule": true
}, },
"exclude": ["node_modules", "**/*.test.ts"] "exclude": ["node_modules", "__tests__"]
} }