Fix Windows installer and build versioning
This commit is contained in:
@@ -20,5 +20,5 @@ fi
|
||||
|
||||
node - <<'NODE'
|
||||
const pkg = require('./package.json');
|
||||
console.log(`StepForge ${pkg.version} bootstrap OK`);
|
||||
console.log(`StepForge ${pkg.buildVersion || pkg.version} bootstrap OK`);
|
||||
NODE
|
||||
|
||||
@@ -70,6 +70,7 @@ for (const rel of walk(examplesRoot, examplesRoot)) {
|
||||
}
|
||||
|
||||
const pkg = require(path.join(rootDir, 'package.json'));
|
||||
const buildVersion = pkg.buildVersion || pkg.version;
|
||||
|
||||
const { execSync } = require('node:child_process');
|
||||
function toolAvailable(cmd) {
|
||||
@@ -88,7 +89,8 @@ const toolRows = Object.entries(tools)
|
||||
|
||||
const report = `# StepForge Build Report
|
||||
|
||||
Version: ${pkg.version}
|
||||
Build version: ${buildVersion}
|
||||
Package version: ${pkg.version}
|
||||
Generated: ${new Date().toISOString()}
|
||||
Host: ${process.platform} ${process.arch} (node ${process.version})
|
||||
|
||||
@@ -133,6 +135,7 @@ fs.writeFileSync(manifestFile, JSON.stringify({
|
||||
version: 1,
|
||||
generatedAt: new Date().toISOString(),
|
||||
packageVersion: pkg.version,
|
||||
buildVersion,
|
||||
files,
|
||||
}, null, 2) + '\n');
|
||||
NODE
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
VERSION="$(node -p "require('${ROOT_DIR}/package.json').version" 2>/dev/null || echo 0.0.0)"
|
||||
VERSION="$(node -p "const pkg=require('${ROOT_DIR}/package.json'); pkg.buildVersion || pkg.version" 2>/dev/null || echo 0.0.0)"
|
||||
OUT_DIR="${STEPFORGE_PACKAGE_DIR:-$ROOT_DIR/build/artifacts}"
|
||||
mkdir -p "$OUT_DIR"
|
||||
WORK_DIR="$(mktemp -d "${OUT_DIR%/}/.pkg.XXXXXX")"
|
||||
|
||||
@@ -10,6 +10,7 @@ const { build, Platform } = require('electron-builder');
|
||||
const ROOT_DIR = path.resolve(__dirname, '..');
|
||||
const PACKAGE_JSON = require(path.join(ROOT_DIR, 'package.json'));
|
||||
const APP_ID = 'com.stepforge.app';
|
||||
const BUILD_VERSION = PACKAGE_JSON.buildVersion || PACKAGE_JSON.version;
|
||||
|
||||
function findInstallerExe(dir) {
|
||||
if (!fs.existsSync(dir)) return null;
|
||||
@@ -32,6 +33,7 @@ function createWindowsInstallerConfig(outputDir) {
|
||||
return {
|
||||
appId: APP_ID,
|
||||
productName: 'StepForge',
|
||||
buildVersion: BUILD_VERSION,
|
||||
directories: {
|
||||
output: outputDir,
|
||||
},
|
||||
@@ -52,6 +54,7 @@ function createWindowsInstallerConfig(outputDir) {
|
||||
createDesktopShortcut: true,
|
||||
createStartMenuShortcut: true,
|
||||
shortcutName: 'StepForge',
|
||||
artifactName: '${productName} Setup ${buildVersion}.${ext}',
|
||||
include: 'build/installer.nsh',
|
||||
},
|
||||
};
|
||||
@@ -87,7 +90,7 @@ async function buildWindowsInstaller() {
|
||||
const releaseInstaller = path.join(releaseDir, path.basename(builtInstaller));
|
||||
fs.copyFileSync(builtInstaller, releaseInstaller);
|
||||
|
||||
console.log(`StepForge ${PACKAGE_JSON.version} Windows installer written to ${releaseInstaller}`);
|
||||
console.log(`StepForge ${BUILD_VERSION} Windows installer written to ${releaseInstaller}`);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
@@ -16,18 +16,25 @@ function stampVersion(rootDir, version) {
|
||||
throw new Error('version is required');
|
||||
}
|
||||
|
||||
const normalized = version.replace(/^v/i, '');
|
||||
const parts = normalized.split('.');
|
||||
const isFourPartBuild = parts.length === 4 && parts.every((part) => /^\d+$/.test(part));
|
||||
const packageVersion = isFourPartBuild ? parts.slice(0, 3).join('.') : normalized;
|
||||
const buildVersion = normalized;
|
||||
|
||||
const pkgPath = path.join(rootDir, 'package.json');
|
||||
const pkg = readJson(pkgPath);
|
||||
pkg.version = version;
|
||||
pkg.version = packageVersion;
|
||||
pkg.buildVersion = buildVersion;
|
||||
writeJson(pkgPath, pkg);
|
||||
|
||||
const lockPath = path.join(rootDir, 'package-lock.json');
|
||||
if (!fs.existsSync(lockPath)) return;
|
||||
|
||||
const lock = readJson(lockPath);
|
||||
lock.version = version;
|
||||
lock.version = packageVersion;
|
||||
if (lock.packages && lock.packages['']) {
|
||||
lock.packages[''].version = version;
|
||||
lock.packages[''].version = packageVersion;
|
||||
}
|
||||
writeJson(lockPath, lock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user