mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-09-27 13:30:15 +00:00
## 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. [](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>
149 lines
6.5 KiB
TypeScript
149 lines
6.5 KiB
TypeScript
import getURL from '../src/get-url';
|
|
|
|
describe('getURL()', () => {
|
|
test('get URLs to Linux assets', () => {
|
|
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
|
|
expect(getURL('Linux', '64bit', 'false', '0.58.2')).toEqual([
|
|
`${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`,
|
|
`${baseURL}/hugo_0.58.2_Linux_64bit.tar.gz`,
|
|
`${baseURL}/hugo_0.58.2_linux-amd64.tar.gz`,
|
|
`${baseURL}/hugo_v0.58.2_Linux-64bit.tar.gz`,
|
|
`${baseURL}/hugo_v0.58.2_Linux_64bit.tar.gz`,
|
|
`${baseURL}/hugo_v0.58.2_linux-amd64.tar.gz`
|
|
]);
|
|
expect(getURL('Linux', 'ARM64', 'true', '0.58.2')).toEqual([
|
|
`${baseURL}/hugo_extended_0.58.2_Linux-ARM64.tar.gz`,
|
|
`${baseURL}/hugo_extended_0.58.2_Linux_ARM64.tar.gz`,
|
|
`${baseURL}/hugo_extended_0.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`,
|
|
`${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 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`
|
|
]);
|
|
});
|
|
});
|