Skip to content

feat: add --skipTag flag #687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)) |

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packages/semver/src/executors/version/index.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/semver/src/executors/version/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
Expand Down
3 changes: 3 additions & 0 deletions packages/semver/src/executors/version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,6 +133,7 @@ export default async function version(
commitMessage,
dependencyUpdates,
skipCommit,
skipTag,
workspace: context.projectsConfigurations,
};

Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions packages/semver/src/executors/version/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/semver/src/executors/version/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 19 additions & 0 deletions packages/semver/src/executors/version/utils/git.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ describe('git', () => {
tag: 'project-a-1.0.0',
commitMessage: 'chore(release): 1.0.0',
projectName: 'p',
skipTag: false,
})
);

Expand All @@ -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',
Expand All @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion packages/semver/src/executors/version/utils/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,20 @@ export function getFirstCommitRef(): Observable<string> {

export function createTag({
dryRun,
skipTag,
tag,
commitHash,
commitMessage,
projectName,
}: {
dryRun: boolean;
skipTag: boolean;
tag: string;
commitHash: string;
commitMessage: string;
projectName: string;
}): Observable<string> {
if (dryRun) {
if (dryRun || skipTag) {
return EMPTY;
}
return exec('git', ['tag', '-a', tag, commitHash, '-m', commitMessage]).pipe(
Expand Down
7 changes: 7 additions & 0 deletions packages/semver/src/executors/version/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface CommonVersionOptions {
tagPrefix: string;
changelogHeader: string;
skipCommit: boolean;
skipTag: boolean;
commitMessage: string;
projectName: string;
skipProjectChangelog: boolean;
Expand All @@ -50,6 +51,7 @@ export function versionWorkspace({
projectName,
tag,
skipCommit,
skipTag,
projectRoot,
...options
}: {
Expand All @@ -70,6 +72,7 @@ export function versionWorkspace({
noVerify,
projectName,
skipCommit,
skipTag,
tag,
...options,
}),
Expand Down Expand Up @@ -105,6 +108,7 @@ export function versionWorkspace({
concatMap((commitHash) =>
createTag({
dryRun,
skipTag,
tag,
commitHash,
commitMessage,
Expand All @@ -124,6 +128,7 @@ export function versionProject({
tagPrefix,
projectName,
skipCommit,
skipTag,
tag,
...options
}: {
Expand All @@ -138,6 +143,7 @@ export function versionProject({
commitMessage,
dryRun,
skipCommit,
skipTag,
noVerify,
tagPrefix,
tag,
Expand Down Expand Up @@ -188,6 +194,7 @@ export function versionProject({
concatMap((commitHash) =>
createTag({
dryRun,
skipTag,
tag,
commitHash,
commitMessage,
Expand Down