mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
fix: accept any v* tag to match build.yml trigger pattern
The workflow triggers on `v*` tags and build.yml extracts version from any v-prefixed tag. Updated the regex from `^v\d+\.\d+\.\d+` to `^v\d` to accept tags like v1, v1.2, v1.2.3, etc. This ensures version parsing stays in sync with build.yml behavior. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Check if refName is a version tag (matches v* pattern used by workflow trigger)
|
||||
// This keeps parsing in sync with build.yml which triggers on tags: v*
|
||||
function isVersionTag(refName) {
|
||||
return refName && /^v\d/.test(refName);
|
||||
}
|
||||
|
||||
// Determine version priority:
|
||||
// 1. VERSION env variable
|
||||
// 2. Valid version tag (v1.2.3 format)
|
||||
// 2. Any v* tag (v1, v1.2, v1.2.3, etc. - matches build.yml trigger)
|
||||
// 3. Short commit ID (first 7 chars of GITHUB_SHA)
|
||||
// 4. package.json version as fallback
|
||||
function getVersion() {
|
||||
@@ -12,8 +18,8 @@ function getVersion() {
|
||||
}
|
||||
|
||||
const refName = process.env.GITHUB_REF_NAME;
|
||||
// Check if refName is a valid version tag (e.g., v1.2.3)
|
||||
if (refName && /^v\d+\.\d+\.\d+/.test(refName)) {
|
||||
// Accept any v* tag to match build.yml behavior
|
||||
if (isVersionTag(refName)) {
|
||||
return refName.replace(/^v/, '');
|
||||
}
|
||||
|
||||
@@ -36,7 +42,7 @@ function getVersion() {
|
||||
const version = getVersion();
|
||||
const repo = process.env.GITHUB_REPOSITORY || 'binaricat/netcatty';
|
||||
// For tag releases, use the tag; for workflow_dispatch, create a tag from version
|
||||
const tag = (process.env.GITHUB_REF_NAME && /^v\d+\.\d+\.\d+/.test(process.env.GITHUB_REF_NAME))
|
||||
const tag = isVersionTag(process.env.GITHUB_REF_NAME)
|
||||
? process.env.GITHUB_REF_NAME
|
||||
: `v${version}`;
|
||||
const baseUrl = `https://github.com/${repo}/releases/download/${tag}`;
|
||||
|
||||
Reference in New Issue
Block a user