Added withDeploy flag allowing users to install builds with deploy support in CI/CD pipelines

This commit is contained in:
Vlad Kyrylenko 2025-01-03 17:36:35 -05:00
parent 3a287949d3
commit 0cadccf22b
3 changed files with 22 additions and 6 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ coverage
.eslintcache .eslintcache
.env .env
node_modules node_modules
/.idea

View File

@ -1,11 +1,13 @@
export default function getURL( export default function getURL(
os: string, os: string,
arch: string, arch: string,
extended: string, extended: boolean,
withdeploy: boolean,
version: string version: string
): string { ): string {
const extendedStr = (extended: string): string => {
if (extended === 'true') { const extendedStr = (extended: boolean): string => {
if (extended) {
return 'extended_'; return 'extended_';
} else { } else {
return ''; return '';
@ -14,6 +16,16 @@ export default function getURL(
} }
}; };
const deployStr = (deploy: boolean): string => {
if (deploy) {
return 'withdeploy_';
} else {
return '';
// } else {
// throw new Error(`Invalid input (extended): ${extended}`);
}
};
const ext = (os: string): string => { const ext = (os: string): string => {
if (os === 'Windows') { if (os === 'Windows') {
return 'zip'; return 'zip';
@ -22,7 +34,7 @@ export default function getURL(
} }
}; };
const hugoName = `hugo_${extendedStr(extended)}${version}_${os}-${arch}`; const hugoName = `hugo_${extendedStr(extended)}${deployStr(withdeploy)}${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 url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;

View File

@ -44,16 +44,19 @@ export async function createBinDir(workDir: string): Promise<string> {
} }
export async function installer(version: string): Promise<void> { export async function installer(version: string): Promise<void> {
const extended: string = core.getInput('extended'); const extended: boolean = core.getInput('extended');
core.debug(`Hugo extended: ${extended}`); core.debug(`Hugo extended: ${extended}`);
const withDeploy: boolean = core.getInput('withDeploy');
core.debug(`Hugo withDeploy: ${withDeploy}`);
const osName: string = getOS(process.platform); const osName: string = getOS(process.platform);
core.debug(`Operating System: ${osName}`); core.debug(`Operating System: ${osName}`);
const archName: string = getArch(process.arch); const archName: string = getArch(process.arch);
core.debug(`Processor Architecture: ${archName}`); core.debug(`Processor Architecture: ${archName}`);
const toolURL: string = getURL(osName, archName, extended, version); const toolURL: string = getURL(osName, archName, extended, withDeploy, version);
core.debug(`toolURL: ${toolURL}`); core.debug(`toolURL: ${toolURL}`);
const workDir = await createWorkDir(); const workDir = await createWorkDir();