Skip to content

Commit

Permalink
[STA-3429] pre-release: do not apply pre-release tag to 0.x.x versions (
Browse files Browse the repository at this point in the history
#59)

* pre-release: do not apply tag to 0.x.x versions

* add test for premajor version with prerelease label
  • Loading branch information
meorphis authored Jan 29, 2024
1 parent 9e84ad1 commit 6c9ab11
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1282,9 +1282,7 @@ export class Manifest {
draft: config.draft ?? this.draft,
prerelease:
hasPrereleaseLabel ||
(config.prerelease &&
(!!release.tag.version.preRelease ||
release.tag.version.major === 0)),
(config.prerelease && !!release.tag.version.preRelease),
});
}
}
Expand Down
53 changes: 52 additions & 1 deletion test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6908,7 +6908,7 @@ version = "3.0.0"
);
});

it('should build prerelease releases from pre-major', async () => {
it('should not build prerelease releases from pre-major', async () => {
mockPullRequests(
github,
[],
Expand Down Expand Up @@ -6955,6 +6955,57 @@ version = "3.0.0"
expect(releases).lengthOf(1);
expect(releases[0].name).to.eql('release-brancher: v0.2.0');
expect(releases[0].draft).to.be.undefined;
expect(releases[0].prerelease).to.be.false;
expect(releases[0].tag.toString()).to.eql('release-brancher-v0.2.0');
});

it('should build prerelease releases from pre-major if the pre-release label is applied', async () => {
mockPullRequests(
github,
[],
[
{
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 1234,
title: 'chore: release main',
body: pullRequestBody(
'release-notes/single-manifest-pre-major.txt'
),
labels: ['autorelease: pending', 'autorelease: pre-release'],
files: [''],
sha: 'abc123',
},
]
);
const getFileContentsStub = sandbox.stub(
github,
'getFileContentsOnBranch'
);
getFileContentsStub
.withArgs('package.json', 'main')
.resolves(
buildGitHubFileRaw(
JSON.stringify({name: '@google-cloud/release-brancher'})
)
);
const manifest = new Manifest(
github,
'main',
{
'.': {
releaseType: 'node',
prerelease: true,
},
},
{
'.': Version.parse('0.1.0'),
}
);
const releases = await manifest.buildReleases();
expect(releases).lengthOf(1);
expect(releases[0].name).to.eql('release-brancher: v0.2.0');
expect(releases[0].draft).to.be.undefined;
expect(releases[0].prerelease).to.be.true;
expect(releases[0].tag.toString()).to.eql('release-brancher-v0.2.0');
});
Expand Down

0 comments on commit 6c9ab11

Please sign in to comment.