-
Notifications
You must be signed in to change notification settings - Fork 5k
78 lines (69 loc) · 3.51 KB
/
build-beta.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Build beta
on:
workflow_call:
jobs:
build-beta:
name: Build beta
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# By default, the checkout action checks out the last merge commit for pull requests.
# Source: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
# However, we need the head commit (the latest commit pushed to the source branch)
# because in the workflow, we would like to parse the latest commit message.
# Specifying `ref` ensures that the head commit is checked out directly.
# For a `pull_request` event, the head commit hash is `github.event.pull_request.head.sha`.
# For a `push` event, the head commit hash is `github.sha`.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Needs beta build
# For a `pull_request` event, the branch is `github.head_ref``.
# For a `push` event, the branch is `github.ref_name`.
if: ${{ (github.head_ref || github.ref_name) != 'master' }}
id: needs-beta-build
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
version="${BRANCH/Version-v/}"
commit_message=$(git show -s --format=%s HEAD)
beta_version_regex="Version v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+"
if [[ "$commit_message" =~ $beta_version_regex ]]; then
printf '%s\n' "Creating a build for $version with $commit_message"
echo "NEEDS_BETA_BUILD=true" >> "$GITHUB_OUTPUT"
else
printf '%s\n' 'Commit message does not match commit message for beta pattern; skipping beta build'
echo "NEEDS_BETA_BUILD=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup environment
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
uses: metamask/github-tools/.github/actions/setup-environment@main
- name: Run beta build
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
env:
INFURA_PROJECT_ID: 00000000000
INFURA_BETA_PROJECT_ID: 00000000000
SEGMENT_BETA_WRITE_KEY: 00000000000
ENABLE_MV3: true
run: |
yarn build --build-type beta --platform='chrome' dist
yarn build --build-type beta --platform='chrome' prod
- name: Validate source maps
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
run: yarn validate-source-maps
- name: Upload 'dist-beta' to S3
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
uses: metamask/github-tools/.github/actions/upload-s3@1233659b3850eb84824d7375e2e0c58eb237701d
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
s3-bucket: ${{ vars.AWS_S3_BUCKET }}/${{ github.event.repository.name }}/${{ github.run_id }}/dist-beta
path: dist
- name: Upload 'builds-beta' to S3
if: ${{ steps.needs-beta-build.outputs.NEEDS_BETA_BUILD == 'true' }}
uses: metamask/github-tools/.github/actions/upload-s3@1233659b3850eb84824d7375e2e0c58eb237701d
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
s3-bucket: ${{ vars.AWS_S3_BUCKET }}/${{ github.event.repository.name }}/${{ github.run_id }}/builds-beta
path: builds