Skip to content

Commit

Permalink
feat: issue a combined PR comment for all releases (#2286)
Browse files Browse the repository at this point in the history
also fixes the release URL with non-ascii characters

fixes #2285

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
niieani and chingor13 committed Jun 6, 2024
1 parent eeb1411 commit 719fdf5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
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

0 comments on commit 719fdf5

Please sign in to comment.