From 719fdf565e9f92694e7e38edee1eadcd62334681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bazyli=20Brz=C3=B3ska?= Date: Thu, 6 Jun 2024 09:32:30 -0700 Subject: [PATCH] feat: issue a combined PR comment for all releases (#2286) also fixes the release URL with non-ascii characters fixes #2285 Co-authored-by: Jeff Ching --- src/manifest.ts | 22 +++++++++++++++++----- test/manifest.ts | 4 ++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/manifest.ts b/src/manifest.ts index be5c0ed96..10ac85748 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -1219,7 +1219,10 @@ 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) { @@ -1227,11 +1230,24 @@ export class Manifest { 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 === @@ -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, diff --git a/test/manifest.ts b/test/manifest.ts index bc6c2e6e1..7315dee0c 100644 --- a/test/manifest.ts +++ b/test/manifest.ts @@ -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'], @@ -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'],