Skip to content

Commit bf87a8a

Browse files
action: validate the version input and accept a leading v
A version written as a tag, such as v1.98.10, was passed through unchanged. The action then logged "Resolved Tailscale version: v1.98.10" and requested tailscale_v1.98.10_amd64.tgz.sha256, which returns 404, and on macOS ran "git checkout vv1.98.10". Strip one leading "v" from the version input and reject anything that is not X.Y.Z, "latest" or "unstable" with an error that names the value and the accepted forms. The check runs in getInputs, so the macOS cache check, validateAuth and resolveVersion all see the normalized value. Fixes #316 Signed-off-by: abhiramshaji-cyber <write4abhiram@gmail.com>
1 parent 99a8333 commit bf87a8a

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎dist/index.js‎

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/main.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async function getInputs(): Promise<TailscaleConfig> {
258258
}
259259

260260
const config = {
261-
version: core.getInput("version") || "1.94.2",
261+
version: parseVersion(core.getInput("version") || "1.94.2"),
262262
resolvedVersion: "",
263263
arch: "",
264264
authKey: authKey,
@@ -287,6 +287,19 @@ async function getInputs(): Promise<TailscaleConfig> {
287287
return config;
288288
}
289289

290+
function parseVersion(input: string): string {
291+
if (input === versionLatest || input === versionUnstable) {
292+
return input;
293+
}
294+
const version = input.replace(/^v/, "");
295+
if (!/^\d+\.\d+\.\d+$/.test(version)) {
296+
throw new Error(
297+
`Invalid version "${input}": use a version number such as 1.104.2, "latest", or "unstable".`,
298+
);
299+
}
300+
return version;
301+
}
302+
290303
function validateAuth(config: TailscaleConfig): void {
291304
if (
292305
!config.authKey &&

0 commit comments

Comments
 (0)