Merge pull request #227 from davidmonterocrespo24/fix/release-version-autobump

fix(ci): auto-increment release version on each Discord announce (baseline 3.0.0)
This commit is contained in:
David Montero Crespo 2026-06-11 09:56:08 -03:00 committed by GitHub
commit 6ac425c2fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 8 deletions

View File

@ -72,12 +72,26 @@ jobs:
} }
// ── Version ────────────────────────────────────────────────────── // ── Version ──────────────────────────────────────────────────────
let version = '2.0.1'; // The version to announce comes from frontend/package.json on the
// release branch. After announcing we bump the PATCH and commit it
// back to release, so EACH merge announces a fresh version
// (3.0.0 -> 3.0.1 -> 3.0.2 ...) instead of repeating the same one.
// To jump the major/minor, edit frontend/package.json on the
// release branch (e.g. set "version": "3.1.0") and the next merge
// continues from there.
let version = '3.0.0';
try { try {
const pkg = JSON.parse(fs.readFileSync('frontend/package.json', 'utf8')); const pkg = JSON.parse(fs.readFileSync('frontend/package.json', 'utf8'));
version = pkg.version ?? '2.0.1'; version = pkg.version ?? '3.0.0';
} catch {} } catch {}
console.log(`Version: v${version}`);
function bumpPatch(v) {
const m = String(v).match(/^(\d+)\.(\d+)\.(\d+)/);
if (!m) return v; // leave non-semver strings untouched
return `${m[1]}.${m[2]}.${Number(m[3]) + 1}`;
}
const nextVersion = bumpPatch(version);
console.log(`Version: v${version} -> next: v${nextVersion}`);
// ── Rango exacto del PR mergeado ────────────────────────────────── // ── Rango exacto del PR mergeado ──────────────────────────────────
// base.sha = tip de release ANTES del merge // base.sha = tip de release ANTES del merge
@ -178,15 +192,32 @@ jobs:
fs.writeFileSync(changelogPath, changelogContent, 'utf8'); fs.writeFileSync(changelogPath, changelogContent, 'utf8');
console.log('CHANGELOG.md updated'); console.log('CHANGELOG.md updated');
// ── Commit y push del CHANGELOG ─────────────────────────────────── // ── Bump frontend/package.json to the next patch ──────────────────
// This is the fix for the "same version announced every time" bug:
// nothing ever advanced the counter. Text-replace so the file's
// existing formatting is preserved.
try { try {
execSync('git add CHANGELOG.md', { stdio: 'inherit' }); const pkgPath = 'frontend/package.json';
const pkgRaw = fs.readFileSync(pkgPath, 'utf8');
const bumped = pkgRaw.replace(
/("version"\s*:\s*")[^"]+(")/,
`$1${nextVersion}$2`
);
fs.writeFileSync(pkgPath, bumped, 'utf8');
console.log(`Bumped frontend/package.json: ${version} -> ${nextVersion}`);
} catch (e) {
console.log('package.json bump failed:', e.message);
}
// ── Commit y push del CHANGELOG + version bump ────────────────────
try {
execSync('git add CHANGELOG.md frontend/package.json', { stdio: 'inherit' });
execSync( execSync(
`git commit -m "docs: update CHANGELOG for v${version} [skip ci]"`, `git commit -m "chore: release v${version}, bump to v${nextVersion} [skip ci]"`,
{ stdio: 'inherit' } { stdio: 'inherit' }
); );
execSync('git push origin release', { stdio: 'inherit' }); execSync('git push origin release', { stdio: 'inherit' });
console.log('CHANGELOG.md committed and pushed'); console.log(`CHANGELOG + version bump committed and pushed (next: v${nextVersion})`);
} catch (e) { } catch (e) {
console.log('Nothing to commit or push failed:', e.message); console.log('Nothing to commit or push failed:', e.message);
} }

View File

@ -2,7 +2,7 @@
"name": "velxio", "name": "velxio",
"homepage": "https://velxio.dev", "homepage": "https://velxio.dev",
"private": true, "private": true,
"version": "2.0.1", "version": "3.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"generate:metadata": "cd .. && npx tsx scripts/generate-component-metadata.ts", "generate:metadata": "cd .. && npx tsx scripts/generate-component-metadata.ts",