From 34fbc16e5d2ce0ed7983ce9a3299a42ddcd6135f Mon Sep 17 00:00:00 2001 From: alwaysmesmerizingyou Date: Sat, 22 Aug 2026 09:12:38 -0700 Subject: [PATCH] when you release it creates the version automatically --- release.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/release.js b/release.js index 3a74497..cf3b5cf 100644 --- a/release.js +++ b/release.js @@ -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}) ===`);