fix: sync versions

This commit is contained in:
2026-02-09 22:50:28 +01:00
parent d7cec1fa0e
commit e152fb8171
21 changed files with 191 additions and 567 deletions

View File

@@ -1,11 +1,45 @@
import * as fs from "fs";
import * as path from "path";
const tag = process.env.GITHUB_REF_NAME || process.env.TAG;
import { execSync } from "child_process";
if (!tag || !tag.startsWith("v")) {
console.error("❌ No valid tag found (must start with v, e.g., v1.0.0)");
process.exit(1);
/**
* Gets the current version tag from environment or git.
*/
function getVersionTag() {
// 1. Check CI environment variables
if (
process.env.GITHUB_REF_NAME &&
process.env.GITHUB_REF_NAME.startsWith("v")
) {
return process.env.GITHUB_REF_NAME;
}
if (process.env.TAG && process.env.TAG.startsWith("v")) {
return process.env.TAG;
}
// 2. Try to get it from local git
try {
const gitTag = execSync("git describe --tags --abbrev=0", {
encoding: "utf8",
}).trim();
if (gitTag && gitTag.startsWith("v")) {
return gitTag;
}
} catch (e) {
// Fallback or silence
}
return null;
}
const tag = getVersionTag();
if (!tag) {
console.log(
" No version tag found (starting with v). Skipping version sync.",
);
process.exit(0); // Exit gracefully if no tag is present
}
const version = tag.replace(/^v/, "");