Skip to content

Commit 0ac1b9c

Browse files
authored
ci: update release artifacts creation (#33601)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/33601?quickstart=1) This PR disables the PR checks for the master branch and enables the metamaskbot comment for release branches, even if there is a merge conflict. ## **Related issues** Fixes: #32582 ## **Manual testing steps** 1. The main workflow should only run once on release branches and it should happen on push. PRs targeting master should not trigger PR checks. 2. The metamaskbot comment should be posted on release branches when there is a PR from the release branch to master, even if there is a merge conflict. ## **Screenshots/Recordings** Not applicable ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent bfb86af commit 0ac1b9c

File tree

3 files changed

+42
-20
lines changed

3 files changed

+42
-20
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
- opened
1313
- reopened
1414
- synchronize
15+
branches-ignore:
16+
- master
1517
merge_group:
1618

1719
concurrency:
@@ -328,7 +330,6 @@ jobs:
328330

329331
publish-prerelease:
330332
name: Publish prerelease
331-
if: ${{ github.event_name == 'pull_request' }}
332333
needs:
333334
- build-dist-browserify
334335
- build-dist-mv2-browserify

.github/workflows/publish-prerelease.yml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ jobs:
1010
publish-prerelease:
1111
name: Publish prerelease
1212
runs-on: ubuntu-latest
13+
env:
14+
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
15+
OWNER: ${{ github.repository_owner }}
16+
REPOSITORY: ${{ github.event.repository.name }}
17+
RUN_ID: ${{ github.run_id }}
18+
# For a `pull_request` event, the branch is `github.head_ref`.
19+
# For a `push` event, the branch is `github.ref_name`.
20+
BRANCH: ${{ github.head_ref || github.ref_name }}
21+
PR_NUMBER: ${{ github.event.pull_request.number }}
22+
BASE_COMMIT_HASH: ${{ github.event.pull_request.base.sha }}
23+
HEAD_COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
24+
MERGE_BASE_COMMIT_HASH: '' # placeholder so that we have autocomplete and logs
25+
CLOUDFRONT_REPO_URL: ${{ vars.AWS_CLOUDFRONT_URL }}/${{ github.event.repository.name }}
26+
HOST_URL: ${{ vars.AWS_CLOUDFRONT_URL }}/${{ github.event.repository.name }}/${{ github.run_id }}
1327
steps:
1428
- name: Checkout and setup high risk environment
1529
uses: MetaMask/action-checkout-and-setup@v1
@@ -19,26 +33,33 @@ jobs:
1933
fetch-depth: 0 # This is needed to get merge base to calculate bundle size diff
2034
yarn-custom-url: ${{ vars.YARN_URL }}
2135

36+
- name: Find the associated PR
37+
if: ${{ startsWith(env.BRANCH, 'Version-v') && (!env.PR_NUMBER || !env.BASE_COMMIT_HASH || !env.HEAD_COMMIT_HASH) }}
38+
uses: actions/github-script@v7
39+
with:
40+
script: |
41+
const prs = await github.rest.pulls.list({
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
head: `${context.repo.owner}:${process.env.BRANCH}`
45+
base: 'master',
46+
});
47+
if (prs.data.length > 0) {
48+
core.exportVariable("PR_NUMBER", prs.data[0].number);
49+
core.exportVariable("BASE_COMMIT_HASH", prs.data[0].base.sha);
50+
core.exportVariable("HEAD_COMMIT_HASH", prs.data[0].head.sha);
51+
core.info(`The pull request number is '${process.env.PR_NUMBER}', the base commit hash is '${process.env.BASE_COMMIT_HASH}', and the head commit hash is '${process.env.HEAD_COMMIT_HASH}'`);
52+
} else {
53+
core.info(`No pull request detected for branch '${process.env.BRANCH}'`);
54+
}
55+
2256
- name: Get merge base commit hash
23-
id: get-merge-base
24-
env:
25-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
26-
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
57+
if: ${{ env.BASE_COMMIT_HASH && env.HEAD_COMMIT_HASH }}
2758
run: |
28-
merge_base="$(git merge-base "${BASE_SHA}" "${HEAD_SHA}")"
29-
echo "MERGE_BASE=${merge_base}" >> "$GITHUB_OUTPUT"
30-
echo "Merge base is '${merge_base}'"
59+
merge_base_commit_hash="$(git merge-base "${BASE_COMMIT_HASH}" "${HEAD_COMMIT_HASH}")"
60+
echo "MERGE_BASE_COMMIT_HASH=${merge_base_commit_hash}" >> "${GITHUB_ENV}"
61+
echo "The merge base commit hash is '${merge_base_commit_hash}'"
3162
3263
- name: Publish prerelease
33-
if: ${{ env.PR_COMMENT_TOKEN && vars.AWS_CLOUDFRONT_URL }}
34-
env:
35-
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }}
36-
OWNER: ${{ github.repository_owner }}
37-
REPOSITORY: ${{ github.event.repository.name }}
38-
RUN_ID: ${{ github.run_id }}
39-
PR_NUMBER: ${{ github.event.pull_request.number }}
40-
HEAD_COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
41-
MERGE_BASE_COMMIT_HASH: ${{ steps.get-merge-base.outputs.MERGE_BASE }}
42-
CLOUDFRONT_REPO_URL: ${{ vars.AWS_CLOUDFRONT_URL }}/${{ github.event.repository.name }}
43-
HOST_URL: ${{ vars.AWS_CLOUDFRONT_URL }}/${{ github.event.repository.name }}/${{ github.run_id }}
64+
if: ${{ env.MERGE_BASE_COMMIT_HASH && env.PR_NUMBER && env.PR_COMMENT_TOKEN && vars.AWS_CLOUDFRONT_URL }}
4465
run: yarn tsx ./development/metamaskbot-build-announce.ts

development/metamaskbot-build-announce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ async function start(): Promise<void> {
369369
}
370370

371371
const JSON_PAYLOAD = JSON.stringify({ body: commentBody });
372-
const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${PR_NUMBER}/comments`;
372+
const POST_COMMENT_URI = `https://api.github.com/repos/${OWNER}/${REPOSITORY}/issues/${PR_NUMBER}/comments`;
373373
console.log(`Announcement:\n${commentBody}`);
374374

375375
if (PR_COMMENT_TOKEN) {

0 commit comments

Comments
 (0)