Skip to content

Commit

Permalink
Adds nightly release task for container (#3944)
Browse files Browse the repository at this point in the history
  • Loading branch information
walmazacn authored Oct 7, 2024
1 parent 3223bc2 commit 051efa7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
6 changes: 6 additions & 0 deletions scripts/tools/publish-nightly.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ const publishPaths = {
testing_utilities: ['client-frameworks-support', 'testing-utilities', 'dist']
};

if (!process.env.NIGHTLY_VERSION) {
logHeadline('Added container path to publish nightly release steps');
packagePaths.container = ['container'];
publishPaths.container = ['container', 'public'];
}

function execTrim(cmd) {
return require('child_process')
.execSync(cmd)
Expand Down
57 changes: 41 additions & 16 deletions scripts/tools/release-cli/release-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const pkgJsonPaths = {
testing_utilities: path.resolve(base, 'client-frameworks-support', 'testing-utilities', 'dist', 'package.json'),
testing_utilities_src: path.resolve(base, 'client-frameworks-support', 'testing-utilities', 'package.json')
};

const installPaths = {
core: path.resolve(base, 'core'),
client: path.resolve(base, 'client'),
Expand All @@ -68,6 +67,11 @@ const installPaths = {
testing_utilities: path.resolve(base, 'client-frameworks-support', 'testing-utilities')
};

if (process.env.NIGHTLY === 'true' && !process.env.NIGHTLY_VERSION) {
pkgJsonPaths.container = path.resolve(base, 'container', 'public', 'package.json');
installPaths.container = path.resolve(base, 'container');
}

/**
* FNS
*/
Expand All @@ -90,6 +94,26 @@ function getNextVersion() {
return semver.inc(getVersion('core'), 'patch');
}

/**
* getVersionSuffix generates version suffix to make it unique
* @returns {string} Unique version suffix
*/
function getVersionSuffix() {
const padLeft = (str, inp) => {
return str.substring(0, str.length - inp.toString().length) + inp.toString();
};
const currentDatetime = new Date();
const formattedDate = `${currentDatetime.getFullYear()}${padLeft(
'00',
currentDatetime.getMonth() + 1
)}${currentDatetime.getDate()}${padLeft('00', currentDatetime.getHours())}${padLeft(
'00',
currentDatetime.getMinutes()
)}`;

return '-dev.' + formattedDate;
}

function writeVersion(packagePath, version) {
const pkgjson = require(packagePath);
pkgjson.version = version;
Expand Down Expand Up @@ -135,18 +159,8 @@ function addToChangelog(versionText, changelog, lastline) {
logHeadline('\nFound custom version in env: ' + process.env.NIGHTLY_VERSION);
prompts.inject([process.env.NIGHTLY_VERSION, false]);
} else {
const padLeft = (str, inp) => {
return str.substring(0, str.length - inp.toString().length) + inp.toString();
};
const currentDatetime = new Date();
let formattedDate = `${currentDatetime.getFullYear()}${padLeft(
'00',
currentDatetime.getMonth() + 1
)}${currentDatetime.getDate()}${padLeft('00', currentDatetime.getHours())}${padLeft(
'00',
currentDatetime.getMinutes()
)}`;
prompts.inject([nextVersion + '-dev.' + formattedDate, false]);
const versionSuffix = getVersionSuffix();
prompts.inject([nextVersion + versionSuffix, false]);
}
}

Expand Down Expand Up @@ -178,7 +192,18 @@ function addToChangelog(versionText, changelog, lastline) {
* PACKAGE VERSIONS
*/
for (const name of Object.keys(pkgJsonPaths)) {
writeVersion(pkgJsonPaths[name], input.version);
let inputVersion = input.version;

// handle custom container version for nightly release
if (name === 'container' && process.env.NIGHTLY === 'true') {
const containerNightlyVersion = getVersion('container');
const versionSuffix = getVersionSuffix();

inputVersion = containerNightlyVersion + versionSuffix;
logHeadline('\nContainer updated to v' + inputVersion + ':');
}

writeVersion(pkgJsonPaths[name], inputVersion);
}
logHeadline('\nPackages updated to v' + input.version + ':');
logStep(Object.keys(pkgJsonPaths).join(', '));
Expand Down Expand Up @@ -224,7 +249,7 @@ function addToChangelog(versionText, changelog, lastline) {
* UPDATE PACKAGE-LOCKS
* Skip when running in ci for nightly.
*/
if (process.env.NIGHTLY !== true) {
if (process.env.NIGHTLY !== 'true') {
logHeadline('\nInstalling packages to update package-lock.json');
for (const key in installPaths) {
logStep(`Installing ${key}`);
Expand All @@ -235,7 +260,7 @@ function addToChangelog(versionText, changelog, lastline) {

logHeadline('\nRelease prepared!');

if (process.env.NIGHTLY === true) {
if (process.env.NIGHTLY === 'true') {
console.log(color.bold(`\nNow execute: npm run release:nightly`));
} else {
console.log(
Expand Down

0 comments on commit 051efa7

Please sign in to comment.