diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index e9861f8737a6..e86e864a8514 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -17400,12 +17400,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/awaitStagingDeploys/index.js b/.github/actions/javascript/awaitStagingDeploys/index.js index 6ec9bbf06aeb..61bda9a76816 100644 --- a/.github/actions/javascript/awaitStagingDeploys/index.js +++ b/.github/actions/javascript/awaitStagingDeploys/index.js @@ -12641,12 +12641,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/checkDeployBlockers/index.js b/.github/actions/javascript/checkDeployBlockers/index.js index c6518f4e61c9..05ecf630719d 100644 --- a/.github/actions/javascript/checkDeployBlockers/index.js +++ b/.github/actions/javascript/checkDeployBlockers/index.js @@ -11924,12 +11924,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index 260dd0847c8d..10feae33f412 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -14954,12 +14954,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/getArtifactInfo/index.js b/.github/actions/javascript/getArtifactInfo/index.js index cde9cf8748db..c9c71a78dafd 100644 --- a/.github/actions/javascript/getArtifactInfo/index.js +++ b/.github/actions/javascript/getArtifactInfo/index.js @@ -11885,12 +11885,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index cfe512076ecd..af45518be73d 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -12233,12 +12233,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/getPullRequestDetails/index.js b/.github/actions/javascript/getPullRequestDetails/index.js index 8fa081de17fa..1ea4870c581b 100644 --- a/.github/actions/javascript/getPullRequestDetails/index.js +++ b/.github/actions/javascript/getPullRequestDetails/index.js @@ -11987,12 +11987,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/getReleaseBody/getReleaseBody.ts b/.github/actions/javascript/getReleaseBody/getReleaseBody.ts index 10024fedc5e7..3d8bd90599ed 100644 --- a/.github/actions/javascript/getReleaseBody/getReleaseBody.ts +++ b/.github/actions/javascript/getReleaseBody/getReleaseBody.ts @@ -1,12 +1,32 @@ import * as core from '@actions/core'; +import type {components as OctokitComponents} from '@octokit/openapi-types'; import * as ActionUtils from '@github/libs/ActionUtils'; import GithubUtils from '@github/libs/GithubUtils'; +type GitHubPR = OctokitComponents['schemas']['pull-request-simple']; + // Parse the stringified JSON array of PR numbers, and cast each from String -> Number const PRList = ActionUtils.getJSONInput('PR_LIST', {required: true}) as number[]; console.log('Got PR list: ', String(PRList)); -const releaseBody = GithubUtils.getReleaseBody(PRList); -console.log(`Generated release body: ${releaseBody}`); +/** + * Generate the well-formatted body of a production release. + */ +function getReleaseBody(pullRequests: GitHubPR[]): string { + return pullRequests.map((pr) => `- ${pr.title} by ${pr.user?.login ?? 'unknown'} in ${pr.html_url}`).join('\r\n'); +} + +async function run() { + const allPRs = await GithubUtils.fetchAllPullRequests(PRList); + if (!allPRs) { + core.setFailed(`something went wrong getting PRList ${JSON.stringify(PRList)}`); + return; + } + const releaseBody = getReleaseBody(allPRs); + console.log(`Generated release body: ${releaseBody}`); + core.setOutput('RELEASE_BODY', releaseBody); +} -core.setOutput('RELEASE_BODY', releaseBody); +if (require.main === module) { + run(); +} diff --git a/.github/actions/javascript/getReleaseBody/index.js b/.github/actions/javascript/getReleaseBody/index.js index 81b73876db95..808c7b066bde 100644 --- a/.github/actions/javascript/getReleaseBody/index.js +++ b/.github/actions/javascript/getReleaseBody/index.js @@ -11459,9 +11459,25 @@ const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); // Parse the stringified JSON array of PR numbers, and cast each from String -> Number const PRList = ActionUtils.getJSONInput('PR_LIST', { required: true }); console.log('Got PR list: ', String(PRList)); -const releaseBody = GithubUtils_1.default.getReleaseBody(PRList); -console.log(`Generated release body: ${releaseBody}`); -core.setOutput('RELEASE_BODY', releaseBody); +/** + * Generate the well-formatted body of a production release. + */ +function getReleaseBody(pullRequests) { + return pullRequests.map((pr) => `- ${pr.title} by ${pr.user?.login ?? 'unknown'} in ${pr.html_url}`).join('\r\n'); +} +async function run() { + const allPRs = await GithubUtils_1.default.fetchAllPullRequests(PRList); + if (!allPRs) { + core.setFailed(`something went wrong getting PRList ${JSON.stringify(PRList)}`); + return; + } + const releaseBody = getReleaseBody(allPRs); + console.log(`Generated release body: ${releaseBody}`); + core.setOutput('RELEASE_BODY', releaseBody); +} +if (require.main === require.cache[eval('__filename')]) { + run(); +} /***/ }), @@ -11931,12 +11947,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/isStagingDeployLocked/index.js b/.github/actions/javascript/isStagingDeployLocked/index.js index feccd44beb1a..fa646a5686ea 100644 --- a/.github/actions/javascript/isStagingDeployLocked/index.js +++ b/.github/actions/javascript/isStagingDeployLocked/index.js @@ -11885,12 +11885,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/index.js b/.github/actions/javascript/markPullRequestsAsDeployed/index.js index ba474583a2fe..84aab97e40f8 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/index.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/index.js @@ -12092,12 +12092,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 68f3b11f45f1..5ff14b7a347d 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -11984,12 +11984,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/reopenIssueWithComment/index.js b/.github/actions/javascript/reopenIssueWithComment/index.js index 461f576e4691..f64c94d2cce6 100644 --- a/.github/actions/javascript/reopenIssueWithComment/index.js +++ b/.github/actions/javascript/reopenIssueWithComment/index.js @@ -11895,12 +11895,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index 5be97363a21c..36685043d757 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -11987,12 +11987,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/actions/javascript/verifySignedCommits/index.js b/.github/actions/javascript/verifySignedCommits/index.js index c932e0c4c618..449a1603232b 100644 --- a/.github/actions/javascript/verifySignedCommits/index.js +++ b/.github/actions/javascript/verifySignedCommits/index.js @@ -11927,12 +11927,6 @@ class GithubUtils { }) .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests) { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/libs/GithubUtils.ts b/.github/libs/GithubUtils.ts index 73553cb46bff..adf391ee95b0 100644 --- a/.github/libs/GithubUtils.ts +++ b/.github/libs/GithubUtils.ts @@ -462,13 +462,6 @@ class GithubUtils { .then((response) => response.data.workflow_runs[0]?.id); } - /** - * Generate the well-formatted body of a production release. - */ - static getReleaseBody(pullRequests: number[]): string { - return pullRequests.map((number) => `- ${this.getPullRequestURLFromNumber(number)}`).join('\r\n'); - } - /** * Generate the URL of an New Expensify pull request given the PR number. */ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5030ea1c2f2b..5aacf0ceea1d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,7 +28,7 @@ jobs: - name: 🚀 Push tags to trigger staging deploy 🚀 run: git push --tags - + - name: Warn deployers if staging deploy failed if: ${{ failure() }} uses: 8398a7/action-slack@v3 @@ -83,10 +83,10 @@ jobs: PR_LIST: ${{ steps.getReleasePRList.outputs.PR_LIST }} - name: 🚀 Create release to trigger production deploy 🚀 - run: gh release create ${{ env.PRODUCTION_VERSION }} --notes '${{ steps.getReleaseBody.outputs.RELEASE_BODY }}' + run: gh release create ${{ env.PRODUCTION_VERSION }} --title ${{ env.PRODUCTION_VERSION }} --notes '${{ steps.getReleaseBody.outputs.RELEASE_BODY }}' env: GITHUB_TOKEN: ${{ steps.setupGitForOSBotify.outputs.OS_BOTIFY_API_TOKEN }} - + - name: Warn deployers if production deploy failed if: ${{ failure() }} uses: 8398a7/action-slack@v3 diff --git a/tests/unit/GithubUtilsTest.ts b/tests/unit/GithubUtilsTest.ts index b157f105f469..2bab87550357 100644 --- a/tests/unit/GithubUtilsTest.ts +++ b/tests/unit/GithubUtilsTest.ts @@ -621,13 +621,4 @@ describe('GithubUtils', () => { [54321, 'https://github.com/Expensify/App/pull/54321'], ])('getPullRequestNumberFromURL("%s")', (input, expectedOutput) => expect(GithubUtils.getPullRequestURLFromNumber(input)).toBe(expectedOutput)); }); - - describe('getReleaseBody', () => { - test.each([ - // eslint-disable-next-line max-len - [[1, 2, 3], '- https://github.com/Expensify/App/pull/1\r\n- https://github.com/Expensify/App/pull/2\r\n- https://github.com/Expensify/App/pull/3'], - [[], ''], - [[12345], '- https://github.com/Expensify/App/pull/12345'], - ])('getReleaseBody("%s")', (input, expectedOutput) => expect(GithubUtils.getReleaseBody(input)).toBe(expectedOutput)); - }); });