diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 2a5845542..c9d5ec1cc 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -4,6 +4,7 @@ on: push: branches: - release + - release-keep-version - integration - integration-* - next @@ -39,6 +40,7 @@ jobs: run: yarn release env: RELEASE_BRANCH: release + RELEASE_KEEP_VERSION_BRANCH: release-keep-version INTEGRATION_BRANCH: integration NEXT_BRANCH: next STABLE_BRANCH: stable diff --git a/vx/opts.js b/vx/opts.js index c49f83784..a1904a9e8 100644 --- a/vx/opts.js +++ b/vx/opts.js @@ -17,6 +17,7 @@ module.exports = { DEVELOPMENT: 'development', TEST: 'test', }, + fileNames: { CHANGELOG: 'CHANGELOG.md', JEST_CONFIG: 'jest.config.js', @@ -29,12 +30,12 @@ module.exports = { TSCONFIG_JSON: 'tsconfig.json', VX_BUILD: 'vx.build.js', }, - packageJsonFields: { - VX: 'vx', - }, format: { UMD: 'umd', CJS: 'cjs', ES: 'es', }, + packageJsonFields: { + VX: 'vx', + }, }; diff --git a/vx/scripts/release/genDiffData.js b/vx/scripts/release/genDiffData.js index c0976da14..75ead0ae4 100644 --- a/vx/scripts/release/genDiffData.js +++ b/vx/scripts/release/genDiffData.js @@ -9,6 +9,7 @@ const { isIntegrationBranch, isReleaseBranch, isNextBranch, + isReleaseKeepVersionBranch, } = require('vx/util/taggedBranch'); const { CURRENT_BRANCH } = require('vx/util/taggedBranch'); const { usePackage } = require('vx/vxContext'); @@ -31,6 +32,11 @@ function genDiffData(commits) { tag, tagId, version, + versionToPublish: isReleaseKeepVersionBranch + ? version + : tag + ? tagId + : nextVersion, }; } @@ -46,12 +52,16 @@ function pickTagId(nextVersion) { const commitHash = GITHUB_SHA.substr(0, 6); if (isNextBranch) { - return `${nextVersion}-${TAG_NEXT}-${commitHash}`; + return getTag(nextVersion, TAG_NEXT, commitHash); } if (isIntegrationBranch) { - return `${nextVersion}-${TAG_DEV}-${commitHash}`; + return getTag(nextVersion, TAG_DEV, commitHash); } throw Error('pickTagId: Encountered an unexpected input.'); } + +function getTag(...keywords) { + return keywords.filter(Boolean).join('-'); +} diff --git a/vx/scripts/release/steps/publishPackage.js b/vx/scripts/release/steps/publishPackage.js index 0e038466d..556f17ce3 100644 --- a/vx/scripts/release/steps/publishPackage.js +++ b/vx/scripts/release/steps/publishPackage.js @@ -1,26 +1,23 @@ -const { TAG_NEXT } = require('../releaseKeywords'); +const { TAG_NEXT, TAG_DEV } = require('../releaseKeywords'); const exec = require('vx/exec'); const logger = require('vx/logger'); -const { TAG_DEV } = require('vx/scripts/release/releaseKeywords'); const joinTruthy = require('vx/util/joinTruthy'); const { isReleaseBranch } = require('vx/util/taggedBranch'); const { usePackage } = require('vx/vxContext'); const vxPath = require('vx/vxPath'); -function publishPackage({ tag, tagId, nextVersion }) { - const versionToUse = tag && tagId ? tagId : nextVersion; - +function publishPackage({ tag, tagId, versionToPublish }) { logger.info(`🚀 Publishing package ${usePackage()}. - Version: ${versionToUse} + Version: ${versionToPublish} Tag Id: ${tagId} Tag: ${tag}`); - if (!shouldRelease(versionToUse)) { + if (!shouldRelease(versionToPublish)) { return logger.info(`❌ Not in release branch. Skipping publish.`); } - const command = genPublishCommand(versionToUse, tag); + const command = genPublishCommand(versionToPublish, tag); execCommandWithGitConfig(command); clearTag(tag, tagId); } diff --git a/vx/scripts/release/steps/setNextVersion.js b/vx/scripts/release/steps/setNextVersion.js index 8cbe5c289..15aa8fd52 100644 --- a/vx/scripts/release/steps/setNextVersion.js +++ b/vx/scripts/release/steps/setNextVersion.js @@ -1,24 +1,45 @@ const { writeJSONSync } = require('fs-extra'); +const { isReleaseKeepVersionBranch } = require('../../../util/taggedBranch'); + const logger = require('vx/logger'); const packageJson = require('vx/util/packageJson'); const { usePackage } = require('vx/vxContext'); const vxPath = require('vx/vxPath'); -function setNextVersion({ tagId, tag, nextVersion }) { +function setNextVersion({ + tagId, + tag, + nextVersion, + versionToPublish, + changeLevel, +}) { const packageName = usePackage(); const existingPkgJson = packageJson(packageName); - const prevVersion = existingPkgJson.version; + if (isReleaseKeepVersionBranch) { + logger.info( + `🔢 Skipping version update for ${usePackage()} due to release keep version branch. + Version being kept: ${existingPkgJson.version}. + + Diff data: + packageName: ${packageName} + changeLevel: ${changeLevel} + tagId: ${tagId} + tag: ${tag} + versionToPublish: ${versionToPublish}` + ); + return; + } - nextVersion = tag ? tagId : nextVersion; + const prevVersion = existingPkgJson.version; - const nextPackageJson = { ...existingPkgJson, version: nextVersion }; + const nextPackageJson = { ...existingPkgJson, version: versionToPublish }; - existingPkgJson.version = nextVersion; + existingPkgJson.version = versionToPublish; logger.info( - `🔢 Setting next version for ${usePackage()}. From ${prevVersion} to ${nextVersion}` + `🔢 Setting next version for ${usePackage()}. From ${prevVersion} to ${versionToPublish}` ); writeJSONSync(vxPath.packageJson(packageName), nextPackageJson, { @@ -27,9 +48,9 @@ function setNextVersion({ tagId, tag, nextVersion }) { const updated = packageJson(packageName); - if (updated.version !== nextVersion) { + if (updated.version !== versionToPublish) { logger.error( - `🚨 Failed to update ${usePackage()} version to: ` + nextVersion + `🚨 Failed to update ${usePackage()} version to: ` + versionToPublish ); return process.exit(1); } diff --git a/vx/util/taggedBranch.js b/vx/util/taggedBranch.js index 47596b864..2d904a3c8 100644 --- a/vx/util/taggedBranch.js +++ b/vx/util/taggedBranch.js @@ -5,6 +5,7 @@ const { LATEST_BRANCH, STABLE_BRANCH, RELEASE_BRANCH, + RELEASE_KEEP_VERSION_BRANCH, } = process.env; const packageNames = require('vx/packageNames'); @@ -13,6 +14,9 @@ const isNextBranch = CURRENT_BRANCH.startsWith(NEXT_BRANCH); const isLatestBranch = CURRENT_BRANCH.startsWith(LATEST_BRANCH); const isStableBranch = CURRENT_BRANCH.startsWith(STABLE_BRANCH); const isReleaseBranch = CURRENT_BRANCH.startsWith(RELEASE_BRANCH); +const isReleaseKeepVersionBranch = CURRENT_BRANCH.startsWith( + RELEASE_KEEP_VERSION_BRANCH +); const [, target = undefined] = isIntegrationBranch || isNextBranch ? CURRENT_BRANCH.split('-') : []; @@ -31,6 +35,7 @@ module.exports = { isLatestBranch, isNextBranch, isReleaseBranch, + isReleaseKeepVersionBranch, isStableBranch, targetPackage: packageNames.names[target], };