chore: have correct version in driver (#10374)

This commit is contained in:
Max Schmitt 2021-11-29 18:05:43 +01:00 committed by GitHub
parent 293c233a49
commit 11a389c8f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,19 +31,20 @@ if (process.argv[2] === '--alpha') {
throw new Error('only --alpha or --beta prefixes are allowed'); throw new Error('only --alpha or --beta prefixes are allowed');
} }
let newVersion;
if (process.argv[3] === '--today-date') { if (process.argv[3] === '--today-date') {
const date = new Date(); const date = new Date();
const month = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'][date.getMonth()]; const month = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'][date.getMonth()];
const day = date.getDate(); const day = date.getDate();
const year = date.getFullYear(); const year = date.getFullYear();
packageJSON.version = `${baseVersion}-${prefix}-${month}-${day}-${year}`; newVersion = `${baseVersion}-${prefix}-${month}-${day}-${year}`;
} else if (process.argv[3] === '--commit-timestamp') { } else if (process.argv[3] === '--commit-timestamp') {
const timestamp = execSync('git show -s --format=%ct HEAD', { const timestamp = execSync('git show -s --format=%ct HEAD', {
stdio: ['ignore', 'pipe', 'ignore'] stdio: ['ignore', 'pipe', 'ignore']
}).toString('utf8').trim(); }).toString('utf8').trim();
packageJSON.version = `${baseVersion}-${prefix}-${timestamp}000`; newVersion = `${baseVersion}-${prefix}-${timestamp}000`;
} else { } else {
throw new Error('This script must be run with either --commit-timestamp or --today-date parameter'); throw new Error('This script must be run with either --commit-timestamp or --today-date parameter');
} }
console.log('Setting version to ' + packageJSON.version); console.log('Setting version to ' + newVersion);
fs.writeFileSync(path.join(__dirname, '..', '..', 'package.json'), JSON.stringify(packageJSON, undefined, 2) + '\n'); execSync(`node utils/bump_package_versions.js ${newVersion}`, { stdio: 'inherit' });