Skip to content

Commit

Permalink
support auto-merge for pre-release bumps (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
meorphis authored Jan 27, 2025
1 parent 2010d20 commit 3f2cbd9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export type AutoMergeOption = {
/**
* Only auto merge if the version bump match the filter
*/
versionBumpFilter?: ('major' | 'minor' | 'patch' | 'build')[];
versionBumpFilter?: ('major' | 'minor' | 'patch' | 'build' | 'preRelease')[];
};

export class Manifest {
Expand Down
7 changes: 6 additions & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export class Version {
return `${this.major}.${this.minor}.${this.patch}${preReleasePart}${buildPart}`;
}

compareBump(other: Version): 'major' | 'minor' | 'patch' | 'build' | 'none' {
compareBump(
other: Version
): 'major' | 'minor' | 'patch' | 'build' | 'preRelease' | 'none' {
if (this.major !== other.major) {
return 'major';
}
Expand All @@ -96,6 +98,9 @@ export class Version {
if (this.build !== other.build) {
return 'build';
}
if (this.preRelease !== other.preRelease) {
return 'preRelease';
}
return 'none';
}
}
Expand Down
33 changes: 33 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,39 @@ describe('Manifest', () => {
);
});

it('should identify prerelease bumps as such', async () => {
const manifest = new Manifest(
github,
'main',
{
'.': {
releaseType: 'simple',
versioning: 'prerelease',
},
},
{
'.': Version.parse('0.1.0-alpha.28'),
}
);
const pullRequests = await manifest.buildPullRequests([], []);
expect(pullRequests).lengthOf(1);
const pullRequest = pullRequests[0];
expect(pullRequest.version?.toString()).to.eql('0.1.0-alpha.29');
expect(pullRequest.previousVersion?.toString()).to.eql(
'0.1.0-alpha.28'
);
expect(
pullRequest.version!.compareBump(pullRequest.previousVersion!)
).to.eql('preRelease');
// simple release type updates the changelog and version.txt
assertHasUpdate(pullRequest.updates, 'CHANGELOG.md');
assertHasUpdate(pullRequest.updates, 'version.txt');
assertHasUpdate(pullRequest.updates, '.release-please-manifest.json');
expect(pullRequest.headRefName).to.eql(
'release-please--branches--main'
);
});

it('should honour the manifestFile argument in Manifest.fromManifest', async () => {
const getFileContentsStub = sandbox
.stub(github, 'getFileContentsOnBranch')
Expand Down

0 comments on commit 3f2cbd9

Please sign in to comment.