diff --git a/README.md b/README.md index fb87ec3d8..e794e248a 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ Important: merge commits messages are ignored by the tool when calculating next | **`--allowEmptyRelease`** | `boolean` | `false` | force a patch increment even if library source didn't change | | **`--skipCommitTypes`** | `string[]` | `[]` | treat commits with specified types as non invoking version bump ([details](https://github.com/jscutlery/semver#skipping-release-for-specific-types-of-commits)) | | **`--skipCommit`** | `boolean` | `false` | skips generating a new commit, leaves all changes in index, tag would be put on last commit ([details](https://github.com/jscutlery/semver#skipping-commit)) | +| **`--skipTag`** | `boolean` | `false` | skips tagging the latest commit with the version calculated ([details](https://github.com/jscutlery/semver#skipping-tag)) | | **`--commitMessageFormat`** | `string` | `undefined` | format the auto-generated message commit ([details](https://github.com/jscutlery/semver#commit-message-customization)) | | **`--preset`** | `string \| object` | `'angular'` | customize Conventional Changelog options ([details](https://github.com/jscutlery/semver#customizing-conventional-changelog-options)) | @@ -212,6 +213,11 @@ In some cases, your release process relies only on tags and you don't want a new To achieve this, you can provide the `--skipCommit` flag and changes made by the library would stay in the index without committing. The tag for the new version would be put on the last existing commit. +#### Skipping tag + +You may want to use this plugin only to calculate the next version of your module, but prevent tagging because it may be done at a later stage in your CI pipeline. +Providing `--skipTag` prevents tagging the latest commit with the calculated `${tag}`. However, the `${version}` and `${tag}` values will still be available in the post-targets. + #### Triggering executors post-release The **`--postTargets`** option allows you to run targets post-release. This is particularly handful for publishing packages on a registry or scheduling any other task. diff --git a/packages/semver/src/executors/version/index.e2e.spec.ts b/packages/semver/src/executors/version/index.e2e.spec.ts index b8607b7d9..0880fdd3d 100644 --- a/packages/semver/src/executors/version/index.e2e.spec.ts +++ b/packages/semver/src/executors/version/index.e2e.spec.ts @@ -20,6 +20,7 @@ jest.mock('@nrwl/devkit'); describe('@jscutlery/semver:version', () => { const defaultBuilderOptions: VersionBuilderSchema = { dryRun: false, + skipTag: false, noVerify: false, trackDeps: false, push: false, diff --git a/packages/semver/src/executors/version/index.spec.ts b/packages/semver/src/executors/version/index.spec.ts index adf9e5435..1b303bd0c 100644 --- a/packages/semver/src/executors/version/index.spec.ts +++ b/packages/semver/src/executors/version/index.spec.ts @@ -72,6 +72,7 @@ describe('@jscutlery/semver:version', () => { syncVersions: false, skipRootChangelog: false, skipProjectChangelog: false, + skipTag: false, postTargets: [], preset: 'angular', commitMessageFormat: 'chore(${projectName}): release version ${version}', diff --git a/packages/semver/src/executors/version/index.ts b/packages/semver/src/executors/version/index.ts index c5b9c85e8..7780e49c9 100644 --- a/packages/semver/src/executors/version/index.ts +++ b/packages/semver/src/executors/version/index.ts @@ -48,6 +48,7 @@ export default async function version( allowEmptyRelease, skipCommitTypes, skipCommit, + skipTag, } = _normalizeOptions(options); const workspaceRoot = context.root; const projectName = context.projectName as string; @@ -132,6 +133,7 @@ export default async function version( commitMessage, dependencyUpdates, skipCommit, + skipTag, workspace: context.projectsConfigurations, }; @@ -237,6 +239,7 @@ function _normalizeOptions(options: VersionBuilderSchema) { versionTagPrefix: options.tagPrefix ?? options.versionTagPrefix, commitMessageFormat: options.commitMessageFormat as string, skipCommit: options.skipCommit as boolean, + skipTag: options.skipTag as boolean, preset: options.preset === 'conventional' ? 'conventionalcommits' diff --git a/packages/semver/src/executors/version/schema.d.ts b/packages/semver/src/executors/version/schema.d.ts index 7078b6907..83521bb59 100644 --- a/packages/semver/src/executors/version/schema.d.ts +++ b/packages/semver/src/executors/version/schema.d.ts @@ -25,6 +25,7 @@ export interface VersionBuilderSchema { skipProjectChangelog?: boolean; trackDeps?: boolean; skipCommit?: boolean; + skipTag?: boolean; /** * @deprecated Use the alias releaseAs (--releaseAs) instead. * @sunset 3.0.0 diff --git a/packages/semver/src/executors/version/schema.json b/packages/semver/src/executors/version/schema.json index 988980469..c853c6289 100644 --- a/packages/semver/src/executors/version/schema.json +++ b/packages/semver/src/executors/version/schema.json @@ -110,6 +110,11 @@ "type": "boolean", "default": false }, + "skipTag": { + "description": "Allows to skip making a tag when bumping a version.", + "type": "boolean", + "default": false + }, "skipCommitTypes": { "description": "Specify array of commit types to be ignored when calculating next version bump.", "type": "array", diff --git a/packages/semver/src/executors/version/utils/git.spec.ts b/packages/semver/src/executors/version/utils/git.spec.ts index 0c4f8d77f..d8d7d3385 100644 --- a/packages/semver/src/executors/version/utils/git.spec.ts +++ b/packages/semver/src/executors/version/utils/git.spec.ts @@ -237,6 +237,7 @@ describe('git', () => { tag: 'project-a-1.0.0', commitMessage: 'chore(release): 1.0.0', projectName: 'p', + skipTag: false, }) ); @@ -257,6 +258,23 @@ describe('git', () => { it('should skip with --dryRun', (done) => { createTag({ dryRun: true, + skipTag: false, + tag: 'project-a-1.0.0', + commitHash: '123', + commitMessage: 'chore(release): 1.0.0', + projectName: 'p', + }).subscribe({ + complete: () => { + expect(cp.exec).not.toBeCalled(); + done(); + }, + }); + }); + + it('should skip with --skipTag', (done) => { + createTag({ + dryRun: false, + skipTag: true, tag: 'project-a-1.0.0', commitHash: '123', commitMessage: 'chore(release): 1.0.0', @@ -280,6 +298,7 @@ describe('git', () => { createTag({ dryRun: false, + skipTag: false, tag: 'project-a-1.0.0', commitHash: '123', commitMessage: 'chore(release): 1.0.0', diff --git a/packages/semver/src/executors/version/utils/git.ts b/packages/semver/src/executors/version/utils/git.ts index aeddffb5f..8331415fe 100644 --- a/packages/semver/src/executors/version/utils/git.ts +++ b/packages/semver/src/executors/version/utils/git.ts @@ -154,18 +154,20 @@ export function getFirstCommitRef(): Observable { export function createTag({ dryRun, + skipTag, tag, commitHash, commitMessage, projectName, }: { dryRun: boolean; + skipTag: boolean; tag: string; commitHash: string; commitMessage: string; projectName: string; }): Observable { - if (dryRun) { + if (dryRun || skipTag) { return EMPTY; } return exec('git', ['tag', '-a', tag, commitHash, '-m', commitMessage]).pipe( diff --git a/packages/semver/src/executors/version/version.ts b/packages/semver/src/executors/version/version.ts index f21e45e17..d20e41e07 100644 --- a/packages/semver/src/executors/version/version.ts +++ b/packages/semver/src/executors/version/version.ts @@ -33,6 +33,7 @@ export interface CommonVersionOptions { tagPrefix: string; changelogHeader: string; skipCommit: boolean; + skipTag: boolean; commitMessage: string; projectName: string; skipProjectChangelog: boolean; @@ -50,6 +51,7 @@ export function versionWorkspace({ projectName, tag, skipCommit, + skipTag, projectRoot, ...options }: { @@ -70,6 +72,7 @@ export function versionWorkspace({ noVerify, projectName, skipCommit, + skipTag, tag, ...options, }), @@ -105,6 +108,7 @@ export function versionWorkspace({ concatMap((commitHash) => createTag({ dryRun, + skipTag, tag, commitHash, commitMessage, @@ -124,6 +128,7 @@ export function versionProject({ tagPrefix, projectName, skipCommit, + skipTag, tag, ...options }: { @@ -138,6 +143,7 @@ export function versionProject({ commitMessage, dryRun, skipCommit, + skipTag, noVerify, tagPrefix, tag, @@ -188,6 +194,7 @@ export function versionProject({ concatMap((commitHash) => createTag({ dryRun, + skipTag, tag, commitHash, commitMessage,