Skip to content

Commit

Permalink
chore(ci): add 'redo' release support (#1215)
Browse files Browse the repository at this point in the history
<!-- For Coveo Employees only. Fill this section.

CDX-764

-->

## Proposed changes

If an NPM version is already released, then just release a patch.

---------

Co-authored-by: Benjamin Taillon <54454747+btaillon@users.noreply.github.com>
  • Loading branch information
louis-bompart and btaillon-coveo authored Mar 27, 2023
1 parent c5bec4b commit 9c7af50
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions utils/release/npm-publish-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import angularChangelogConvention from 'conventional-changelog-angular';
import {dirname, resolve, join} from 'node:path';
import {fileURLToPath} from 'node:url';
import retry from 'async-retry';
import {inc, compareBuild} from 'semver';
import {inc, compareBuild, gte} from 'semver';
import {json as fetchNpm} from 'npm-registry-fetch';

const hasPackageJsonChanged = (directoryPath) => {
Expand Down Expand Up @@ -60,9 +60,18 @@ const isPrerelease = process.env.IS_PRERELEASE === 'true';
return;
}
const parsedCommits = parseCommits(commits, convention.parserOpts);
let currentVersion = getCurrentVersion(PATH);
let bumpInfo = convention.recommendedBumpOpts.whatBump(parsedCommits);
const nextGoldVersion = getNextVersion(currentVersion, bumpInfo);
let currentGitVersion = getCurrentVersion(PATH);
let currentNpmVersion = privatePackage
? '0.0.0' // private package does not have a npm version, so we default to the 'lowest' possible
: await describeNpmTag(packageJson.name, 'latest');
const isRedo = gte(currentNpmVersion, currentGitVersion);
const bumpInfo = isRedo
? {type: 'patch'}
: convention.recommendedBumpOpts.whatBump(parsedCommits);
const nextGoldVersion = getNextVersion(
isRedo ? currentNpmVersion : currentGitVersion,
bumpInfo
);
const newVersion =
isPrerelease && !privatePackage
? await getNextBetaVersion(packageJson.name, nextGoldVersion)
Expand Down

0 comments on commit 9c7af50

Please sign in to comment.