ci: change nightly version scheme

This commit is contained in:
7w1 committed 2026-07-22 12:18:39 -05:00
1 parent fa9a763395
commit 6d875ff449
4 files changed
+28 -9

No files matched your search

+25 -6
View File
@@ -1,10 +1,9 @@
#!/usr/bin/env node
/* oxlint-disable no-console */
import { execSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
const runNumber = process.argv[2];
const runAttempt = process.argv[3];
const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(packageJson.version);
@@ -13,10 +12,30 @@ if (!match) {
process.exit(1);
}
if (!/^\d+$/.test(runNumber ?? '') || !/^\d+$/.test(runAttempt ?? '')) {
console.error('Usage: nightly-version.mjs <run-number> <run-attempt>');
process.exit(1);
let timestamp;
try {
// Read the HEAD commit's committer timestamp in UTC epoch seconds
const commitTimestamp = execSync('git log -1 --format=%ct', {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
}).trim();
if (/^\d+$/.test(commitTimestamp)) {
timestamp = new Date(Number(commitTimestamp) * 1000);
}
} catch {
// Fallback to current system time if git is unavailable
}
timestamp ||= new Date();
const year = String(timestamp.getUTCFullYear()).slice(-2);
const month = String(timestamp.getUTCMonth() + 1).padStart(2, '0');
const day = String(timestamp.getUTCDate()).padStart(2, '0');
const hours = String(timestamp.getUTCHours()).padStart(2, '0');
const minutes = String(timestamp.getUTCMinutes()).padStart(2, '0');
const timeIdentifier = `${year}-${month}-${day}-${hours}${minutes}`;
const [, major, minor, patch] = match;
console.log(`${major}.${minor}.${Number(patch) + 1}-nightly.${runNumber}.${runAttempt}`);
console.log(`${major}.${minor}.${Number(patch) + 1}-nightly.${timeIdentifier}`);