diff --git a/dist/index.js b/dist/index.js index e59b833..24b1876 100644 --- a/dist/index.js +++ b/dist/index.js @@ -52347,7 +52347,7 @@ async function getInputs() { } } const config = { - version: core.getInput("version") || "1.94.2", + version: parseVersion(core.getInput("version") || "1.94.2"), resolvedVersion: "", arch: "", authKey: authKey, @@ -52371,6 +52371,16 @@ async function getInputs() { } return config; } +function parseVersion(input) { + if (input === versionLatest || input === versionUnstable) { + return input; + } + const version = input.replace(/^v/, ""); + if (!/^\d+\.\d+\.\d+$/.test(version)) { + throw new Error(`Invalid version "${input}": use a version number such as 1.104.2, "latest", or "unstable".`); + } + return version; +} function validateAuth(config) { if (!config.authKey && (!config.oauthSecret || !config.tags) && diff --git a/src/main.ts b/src/main.ts index 109d4c1..73fb892 100644 --- a/src/main.ts +++ b/src/main.ts @@ -258,7 +258,7 @@ async function getInputs(): Promise { } const config = { - version: core.getInput("version") || "1.94.2", + version: parseVersion(core.getInput("version") || "1.94.2"), resolvedVersion: "", arch: "", authKey: authKey, @@ -287,6 +287,19 @@ async function getInputs(): Promise { return config; } +function parseVersion(input: string): string { + if (input === versionLatest || input === versionUnstable) { + return input; + } + const version = input.replace(/^v/, ""); + if (!/^\d+\.\d+\.\d+$/.test(version)) { + throw new Error( + `Invalid version "${input}": use a version number such as 1.104.2, "latest", or "unstable".`, + ); + } + return version; +} + function validateAuth(config: TailscaleConfig): void { if ( !config.authKey &&