diff --git a/packages/build/src/github-repo.spec.ts b/packages/build/src/github-repo.spec.ts index 874809c2c7..050b3389a4 100644 --- a/packages/build/src/github-repo.spec.ts +++ b/packages/build/src/github-repo.spec.ts @@ -405,7 +405,7 @@ describe('GithubRepo', () => { beforeEach(() => { octokit = { - paginate: sinon.stub().resolves([{ id: '123', tag_name: 'v0.0.6', draft: true }]), + paginate: sinon.stub().resolves([{ id: '123', tag_name: 'v0.0.6', draft: true, html_url: 'releaseUrl' }]), repos: { updateRelease: sinon.stub().resolves() } @@ -414,8 +414,9 @@ describe('GithubRepo', () => { }); it('finds the release corresponding to config.version and sets draft to false', async() => { - await githubRepo.promoteRelease({ version: '0.0.6' } as any); + const releaseUrl = await githubRepo.promoteRelease({ version: '0.0.6' } as any); + expect(releaseUrl).to.equal('releaseUrl'); expect(octokit.repos.updateRelease).to.have.been.calledWith({ draft: false, owner: 'mongodb-js', @@ -668,7 +669,8 @@ describe('GithubRepo', () => { ...githubRepo.repo, base: 'toBase', head: 'fromBranch', - title: 'PR' + title: 'PR', + body: 'description' }).resolves({ data: { number: 42, @@ -676,7 +678,7 @@ describe('GithubRepo', () => { } }); - const result = await githubRepo.createPullRequest('PR', 'fromBranch', 'toBase'); + const result = await githubRepo.createPullRequest('PR', 'description', 'fromBranch', 'toBase'); expect(result.prNumber).to.equal(42); expect(result.url).to.equal('url'); }); @@ -698,7 +700,7 @@ describe('GithubRepo', () => { githubRepo = getTestGithubRepo(octokit); }); - it('creates a proper PR', async() => { + it('merges a PR', async() => { mergePullRequest.withArgs({ ...githubRepo.repo, pull_number: 42 diff --git a/packages/build/src/github-repo.ts b/packages/build/src/github-repo.ts index f7fc2b372b..529b1a7dc2 100644 --- a/packages/build/src/github-repo.ts +++ b/packages/build/src/github-repo.ts @@ -31,6 +31,7 @@ type ReleaseDetails = { upload_url: string; id: number; assets?: ReleaseAsset[] + html_url: string; }; type ReleaseAsset = { @@ -174,7 +175,7 @@ export class GithubRepo { return releases.find(({ tag_name }) => tag_name === tag); } - async promoteRelease(config: Config): Promise { + async promoteRelease(config: Config): Promise { const tag = `v${config.version}`; const releaseDetails = await this.getReleaseByTag(tag); @@ -185,7 +186,7 @@ export class GithubRepo { if (!releaseDetails.draft) { console.info(`Release for ${tag} is already public.`); - return; + return releaseDetails.html_url; } const params = { @@ -195,6 +196,7 @@ export class GithubRepo { }; await this.octokit.repos.updateRelease(params); + return releaseDetails.html_url; } /** @@ -279,12 +281,13 @@ export class GithubRepo { }; } - async createPullRequest(title: string, fromBranch: string, toBaseBranch: string): Promise<{prNumber: number, url: string}> { + async createPullRequest(title: string, description: string, fromBranch: string, toBaseBranch: string): Promise<{prNumber: number, url: string}> { const response = await this.octokit.pulls.create({ ...this.repo, base: toBaseBranch, head: fromBranch, - title + title, + body: description }); return { diff --git a/packages/build/src/homebrew/publish-to-homebrew.spec.ts b/packages/build/src/homebrew/publish-to-homebrew.spec.ts index 3d4998d8cc..0ff12da612 100644 --- a/packages/build/src/homebrew/publish-to-homebrew.spec.ts +++ b/packages/build/src/homebrew/publish-to-homebrew.spec.ts @@ -57,13 +57,14 @@ describe('Homebrew publish-to-homebrew', () => { createPullRequest .rejects() - .withArgs('mongosh 1.0.0', 'mongodb-js:new-branch', 'master') + .withArgs('mongosh 1.0.0', sinon.match.string, 'mongodb-js:new-branch', 'master') .resolves({ prNumber: 42, url: 'url' }); await publishToHomebrew( homebrewCore, homebrewFork, '1.0.0', + 'githubRelease', httpsSha256, generateFormula, updateHomebrewFork @@ -100,6 +101,7 @@ describe('Homebrew publish-to-homebrew', () => { homebrewCore, homebrewFork, '1.0.0', + 'githubRelease', httpsSha256, generateFormula, updateHomebrewFork @@ -134,13 +136,14 @@ describe('Homebrew publish-to-homebrew', () => { createPullRequest .rejects() - .withArgs('mongosh 1.0.0', 'mongodb-js:new-branch', 'master') + .withArgs('mongosh 1.0.0', sinon.match.string, 'mongodb-js:new-branch', 'master') .resolves({ prNumber: 42, url: 'url' }); await publishToHomebrew( homebrewCore, homebrewFork, '1.0.0', + 'githubRelease', httpsSha256, generateFormula, updateHomebrewFork diff --git a/packages/build/src/homebrew/publish-to-homebrew.ts b/packages/build/src/homebrew/publish-to-homebrew.ts index 001e3fc9d3..1931056453 100644 --- a/packages/build/src/homebrew/publish-to-homebrew.ts +++ b/packages/build/src/homebrew/publish-to-homebrew.ts @@ -8,6 +8,7 @@ export async function publishToHomebrew( homebrewCore: GithubRepo, homebrewCoreFork: GithubRepo, packageVersion: string, + githubReleaseLink: string, httpsSha256Fn = httpsSha256, generateFormulaFn = generateUpdatedFormula, updateHomebrewForkFn = updateHomebrewFork @@ -32,6 +33,13 @@ export async function publishToHomebrew( return; } - const pr = await homebrewCore.createPullRequest(`mongosh ${packageVersion}`, `${homebrewCoreFork.repo.owner}:${forkBranch}`, 'master'); + const description = `This PR was created automatically and bumps \`mongosh\` to the latest published version \`${packageVersion}\`.\n\nFor additional details see ${githubReleaseLink}.`; + + const pr = await homebrewCore.createPullRequest( + `mongosh ${packageVersion}`, + description, + `${homebrewCoreFork.repo.owner}:${forkBranch}`, + 'master' + ); console.info(`Created PR #${pr.prNumber} in ${homebrewCore.repo.owner}/${homebrewCore.repo.repo}: ${pr.url}`); } diff --git a/packages/build/src/run-publish.ts b/packages/build/src/run-publish.ts index 8960b8659e..bf5e044f7b 100644 --- a/packages/build/src/run-publish.ts +++ b/packages/build/src/run-publish.ts @@ -62,7 +62,7 @@ export async function runPublish( config.downloadCenterAwsSecret || '' ); - await mongoshGithubRepo.promoteRelease(config); + const releaseUrl = await mongoshGithubRepo.promoteRelease(config); // ensures the segment api key to be present in the published packages await writeAnalyticsConfig( @@ -75,7 +75,8 @@ export async function runPublish( await publishToHomebrew( homebrewCoreGithubRepo, mongodbHomebrewForkGithubRepo, - config.version + config.version, + releaseUrl ); console.info('mongosh: finished release process.');