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>
This commit is contained in:
Shohei Ueda
2026-05-10 22:40:55 +09:00
committed by GitHub
co-authored by Codex
parent d488e4d987
commit 187a5efe81
6 changed files with 12153 additions and 35 deletions
+51 -9
View File
@@ -3,7 +3,7 @@ export default function getURL(
arch: string,
extended: string,
version: string
): string {
): string[] {
const extendedStr = (extended: string): string => {
if (extended === 'true') {
return 'extended_';
@@ -14,17 +14,59 @@ export default function getURL(
}
};
const ext = (os: string): string => {
if (os === 'Windows') {
return 'zip';
} else {
return 'tar.gz';
const lowerArch = (arch: string): string => {
switch (arch) {
case '64bit':
return 'amd64';
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 url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
const assetBase = `hugo_${extendedStr(extended)}${version}_`;
const legacyVersionedAssetBase = `hugo_${extendedStr(extended)}v${version}_`;
const assetBases = [assetBase, legacyVersionedAssetBase];
const assetURLs = (assetNames: string[]): string[] => {
return Array.from(new Set(assetNames)).map(assetName => {
return `${baseURL}/v${version}/${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 === 'Windows') {
return assetURLs(
assetBases.flatMap(assetBase => [
`${assetBase}Windows-${arch}.zip`,
`${assetBase}windows-${lowerArch(arch)}.zip`
])
);
}
if (os === 'Linux') {
return assetURLs(
assetBases.flatMap(assetBase => [
`${assetBase}Linux-${arch}.tar.gz`,
`${assetBase}Linux_${arch}.tar.gz`,
`${assetBase}linux-${lowerArch(arch)}.tar.gz`
])
);
}
return assetURLs([`${assetBase}${os}-${arch}.tar.gz`]);
}