Skip to content
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

feat: issue a combined PR comment for all releases #2286

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
22 changes: 17 additions & 5 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1219,19 +1219,35 @@ export class Manifest {
);
const duplicateReleases: DuplicateReleaseError[] = [];
const githubReleases: CreatedRelease[] = [];
let error: unknown | undefined;
for (const release of releases) {
// stop releasing once we hit an error
if (error) continue;
try {
githubReleases.push(await this.createRelease(release));
} catch (err) {
if (err instanceof DuplicateReleaseError) {
this.logger.warn(`Duplicate release tag: ${release.tag.toString()}`);
duplicateReleases.push(err);
} else {
throw err;
error = err;
}
}
}

if (githubReleases.length > 0) {
// comment on pull request about the successful releases
const releaseList = githubReleases
.map(({tagName, url}) => `- [${tagName}](${url})`)
.join('\n');
const comment = `:robot: Created releases:\n${releaseList}\n:sunflower:`;
await this.github.commentOnIssue(comment, pullRequest.number);
}

if (error) {
throw error;
}

if (duplicateReleases.length > 0) {
if (
duplicateReleases.length + githubReleases.length ===
Expand Down Expand Up @@ -1266,10 +1282,6 @@ export class Manifest {
prerelease: release.prerelease,
});

// comment on pull request
const comment = `:robot: Release is at ${githubRelease.url} :sunflower:`;
await this.github.commentOnIssue(comment, release.pullRequest.number);

return {
...githubRelease,
path: release.path,
Expand Down
4 changes: 2 additions & 2 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5722,7 +5722,7 @@ describe('Manifest', () => {
expect(releases[3]!.sha).to.eql('abc123');
expect(releases[3]!.notes).to.be.string;
expect(releases[3]!.path).to.eql('packages/datastore-lock');
sinon.assert.callCount(commentStub, 4);
sinon.assert.callCount(commentStub, 1);
sinon.assert.calledOnceWithExactly(
addLabelsStub,
['autorelease: tagged'],
Expand Down Expand Up @@ -6200,7 +6200,7 @@ describe('Manifest', () => {
expect(releases[2]!.sha).to.eql('abc123');
expect(releases[2]!.notes).to.be.string;
expect(releases[2]!.path).to.eql('packages/datastore-lock');
sinon.assert.callCount(commentStub, 3);
sinon.assert.callCount(commentStub, 1);
sinon.assert.calledOnceWithExactly(
addLabelsStub,
['autorelease: tagged'],
Expand Down
Loading