Skip to content

Commit

Permalink
Merge pull request #1081 from ckeditor/ck/18080
Browse files Browse the repository at this point in the history
Internal: The commitAndTag() function now uses annotated tags instead of lightweight ones to allow signing tags while preparing a release.
  • Loading branch information
martnpaneq authored Mar 7, 2025
2 parents 19c0ba6 + 3b0da9b commit 1aa979d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Changelog

* **[release-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-release-tools)**: Added the options.dryRun parameter to the commitAndTag() function to verify if a release commit passes validation, so releasing a project will not fail due to issues while committing. ([commit](https://github.com/ckeditor/ckeditor5-dev/commit/0e4779d403fbf22dd6f8a3f2a1de5d1b2183db81))

### Other changes

* **[release-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-release-tools)**: The `commitAndTag()` function now uses annotated tags instead of lightweight ones to allow signing tags while preparing a release. Closes [ckeditor/ckeditor5#18080](https://github.com/ckeditor/ckeditor5/issues/18080). ([commit](https://github.com/ckeditor/ckeditor5-dev/commit/ecbcfd3a6767b1251400e67659ae326fa44b868a))

### Released packages

Check out the [Versioning policy](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/versioning-policy.html) guide for more information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ export default async function commitAndTag( {
} else if ( !tagForVersion ) {
// Commit and create a tag if it does not exist yet. It might happen when a release job is restarted.
await makeCommit();
await git.addTag( `v${ version }` );
await git.addAnnotatedTag( `v${ version }`, `Release: v${ version }.` );
}
}
20 changes: 14 additions & 6 deletions packages/ckeditor5-dev-release-tools/tests/tasks/commitandtag.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe( 'commitAndTag()', () => {
commit: vi.fn(),
reset: vi.fn(),
log: vi.fn(),
addTag: vi.fn()
addAnnotatedTag: vi.fn()
}
};

Expand All @@ -40,7 +40,7 @@ describe( 'commitAndTag()', () => {
await commitAndTag( { files: [] } );

expect( stubs.git.commit ).not.toHaveBeenCalled();
expect( stubs.git.addTag ).not.toHaveBeenCalled();
expect( stubs.git.addAnnotatedTag ).not.toHaveBeenCalled();
} );

it( 'should not create a commit and tag if the specified version is already tagged', async () => {
Expand All @@ -52,7 +52,7 @@ describe( 'commitAndTag()', () => {
await commitAndTag( { files: [ 'package.json' ], version: '1.0.0' } );

expect( stubs.git.commit ).not.toHaveBeenCalled();
expect( stubs.git.addTag ).not.toHaveBeenCalled();
expect( stubs.git.addAnnotatedTag ).not.toHaveBeenCalled();
} );

it( 'should allow to specify custom cwd', async () => {
Expand Down Expand Up @@ -123,7 +123,15 @@ describe( 'commitAndTag()', () => {

await commitAndTag( { version: '1.0.0', packagesDirectory: 'packages' } );

expect( stubs.git.addTag ).toHaveBeenCalledExactlyOnceWith( 'v1.0.0' );
expect( stubs.git.addAnnotatedTag ).toHaveBeenCalledExactlyOnceWith( 'v1.0.0', 'Release: v1.0.0.' );
} );

it( 'should add a tag to the created commit with a correct message when skipCi is true', async () => {
vi.mocked( glob ).mockResolvedValue( [ 'package.json' ] );

await commitAndTag( { version: '1.0.0', packagesDirectory: 'packages', skipCi: true } );

expect( stubs.git.addAnnotatedTag ).toHaveBeenCalledExactlyOnceWith( 'v1.0.0', 'Release: v1.0.0.' );
} );

it( 'should create a commit in dry run mode without creating a tag and then reset it', async () => {
Expand All @@ -144,7 +152,7 @@ describe( 'commitAndTag()', () => {
] );
expect( stubs.git.reset ).toHaveBeenCalledExactlyOnceWith( [ 'previousmockhash' ] );

expect( stubs.git.addTag ).not.toHaveBeenCalled();
expect( stubs.git.addAnnotatedTag ).not.toHaveBeenCalled();
} );

it( 'should not run git reset when commit in dry run throws an error', async () => {
Expand All @@ -167,6 +175,6 @@ describe( 'commitAndTag()', () => {
] );

expect( stubs.git.reset ).not.toHaveBeenCalled();
expect( stubs.git.addTag ).not.toHaveBeenCalled();
expect( stubs.git.addAnnotatedTag ).not.toHaveBeenCalled();
} );
} );

0 comments on commit 1aa979d

Please sign in to comment.