feat: add admin-web Docker build & push workflow with semantic-release
This commit is contained in:
46
scripts/prepare-release.cjs
Normal file
46
scripts/prepare-release.cjs
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[\dA-Za-z.-]+)?(?:\+[\dA-Za-z.-]+)?$/;
|
||||
|
||||
const nextVersion = process.argv[2];
|
||||
|
||||
if (!nextVersion) {
|
||||
throw new Error(
|
||||
'Usage: node scripts/prepare-release.cjs <version> — version argument is required.',
|
||||
);
|
||||
}
|
||||
|
||||
if (!SEMVER_PATTERN.test(nextVersion)) {
|
||||
throw new Error(
|
||||
`Invalid semver "${nextVersion}". Expected e.g. 1.2.3 or 1.2.3-beta.1.`,
|
||||
);
|
||||
}
|
||||
|
||||
const workspaceRoot = path.resolve(__dirname, '..');
|
||||
|
||||
const versionJsonPath = path.join(workspaceRoot, 'version.json');
|
||||
const adminWebPackagePath = path.join(workspaceRoot, 'admin-web', 'package.json');
|
||||
|
||||
writeVersionJson(versionJsonPath, nextVersion);
|
||||
bumpPackageVersion(adminWebPackagePath, nextVersion);
|
||||
|
||||
console.log(`[prepare-release] Updated version to ${nextVersion}`);
|
||||
console.log('[prepare-release] - version.json');
|
||||
console.log('[prepare-release] - admin-web/package.json');
|
||||
|
||||
function writeVersionJson(filePath, version) {
|
||||
const versionJson = { version };
|
||||
fs.writeFileSync(filePath, `${JSON.stringify(versionJson, null, 2)}\n`, 'utf8');
|
||||
}
|
||||
|
||||
function bumpPackageVersion(filePath, version) {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`Package manifest not found: ${filePath}`);
|
||||
}
|
||||
const manifest = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
manifest.version = version;
|
||||
fs.writeFileSync(filePath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
|
||||
}
|
||||
Reference in New Issue
Block a user