when you release it creates the version automatically

This commit is contained in:
2026-08-22 09:12:38 -07:00
parent 5d78dafe43
commit 34fbc16e5d

View File

@@ -12,9 +12,32 @@ if (!TOKEN) {
process.exit(1);
}
function getPackageVersion() {
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
return pkg.version || '1.0.0';
function incrementVersion() {
const pkgPath = path.join(__dirname, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
let [major, minor, patch] = (pkg.version || '1.0.0').split('.').map(Number);
patch = (patch || 0) + 1;
const newVersion = `${major}.${minor}.${patch}`;
pkg.version = newVersion;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
const tauriPath = path.join(__dirname, 'src-tauri', 'tauri.conf.json');
if (fs.existsSync(tauriPath)) {
const tauriConf = JSON.parse(fs.readFileSync(tauriPath, 'utf8'));
tauriConf.version = newVersion;
fs.writeFileSync(tauriPath, JSON.stringify(tauriConf, null, 4) + '\n', 'utf8');
}
const cargoPath = path.join(__dirname, 'src-tauri', 'Cargo.toml');
if (fs.existsSync(cargoPath)) {
let cargo = fs.readFileSync(cargoPath, 'utf8');
cargo = cargo.replace(/^version\s*=\s*".*"/m, `version = "${newVersion}"`);
fs.writeFileSync(cargoPath, cargo, 'utf8');
}
return newVersion;
}
function uploadFileToGitLabPackage(filePath, packageName, version, fileName) {
@@ -112,7 +135,7 @@ async function main() {
const isFullBuild = process.argv.includes('--installer');
const customTag = process.argv.find(arg => arg.startsWith('--tag='))?.split('=')[1];
const version = customTag || `v${getPackageVersion()}`;
const version = customTag || `v${incrementVersion()}`;
console.log(`=== Building Vyla Home Release (${version}) ===`);