Skip to content

Commit 39ac56e

Browse files
authored
refactor!: Migrate remaining release-related workflows to actions (#168)
* Migrate remaining release-related actions * secrets -> inputs * Add missing token
1 parent 4fad0e1 commit 39ac56e

File tree

6 files changed

+382
-381
lines changed

6 files changed

+382
-381
lines changed
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: Create Release Pull Request
2+
description: 'Creates a release pull request for the specified platform (mobile or extension).'
3+
4+
inputs:
5+
checkout-base-branch:
6+
required: true
7+
description: 'The base branch, tag, or SHA for git operations.'
8+
release-pr-base-branch:
9+
required: true
10+
description: 'The base branch, tag, or SHA for the release pull request.'
11+
semver-version:
12+
required: true
13+
description: 'A semantic version, e.g.: "x.y.z".'
14+
mobile-build-version:
15+
required: false
16+
description: 'The build version for the mobile platform.'
17+
previous-version-ref:
18+
required: true
19+
description: 'Previous release version branch name, tag or commit hash (e.g., release/7.7.0, v7.7.0, or 76fbc500034db9779e9ff7ce637ac5be1da0493d). For hotfix releases, pass the literal string "null".'
20+
mobile-template-sheet-id:
21+
required: false
22+
description: 'The Mobile testing sheet template id.'
23+
default: '1012668681' # prod sheet template
24+
extension-template-sheet-id:
25+
required: false
26+
description: 'The Extension testing sheet template id.'
27+
default: '295804563' # prod sheet template
28+
test-only:
29+
required: false
30+
description: 'If true, the release will be marked as a test release.'
31+
default: 'false'
32+
release-sheet-google-document-id:
33+
required: false
34+
description: 'The Google Document ID for the release notes.'
35+
default: '1tsoodlAlyvEUpkkcNcbZ4PM9HuC9cEM80RZeoVv5OCQ' # Prod Release Document
36+
platform:
37+
required: true
38+
description: 'The platform for which the release PR is being created. Must be one of: mobile, extension.'
39+
git-user-name:
40+
description: 'Git user name for commits. Defaults to metamaskbot.'
41+
default: 'metamaskbot'
42+
git-user-email:
43+
description: 'Git user email for commits. Defaults to [email protected].'
44+
default: '[email protected]'
45+
github-token:
46+
description: 'GitHub token used for authentication.'
47+
required: true
48+
google-application-creds-base64:
49+
description: 'Google application credentials base64 encoded.'
50+
required: true
51+
github-tools-repository:
52+
description: 'The GitHub repository containing the GitHub tools. Defaults to the GitHub tools action repositor, and usually does not need to be changed.'
53+
required: false
54+
default: ${{ github.action_repository }}
55+
github-tools-ref:
56+
description: 'The SHA of the action to use. Defaults to the current action ref, and usually does not need to be changed.'
57+
required: false
58+
default: ${{ github.action_ref }}
59+
60+
runs:
61+
using: composite
62+
steps:
63+
# Step 1: Checkout invoking repository (metamask-mobile | metamask-extension )
64+
- name: Checkout invoking repository
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
ref: ${{ inputs.checkout-base-branch }}
69+
token: ${{ inputs.github-token }}
70+
71+
# Step 2: Checkout github-tools repository
72+
- name: Checkout github-tools repository
73+
uses: actions/checkout@v4
74+
with:
75+
repository: ${{ inputs.github-tools-repository }}
76+
ref: ${{ inputs.github-tools-ref }}
77+
path: github-tools
78+
79+
# Step 3: Setup environment
80+
- name: Checkout and setup environment
81+
uses: MetaMask/action-checkout-and-setup@v2
82+
with:
83+
is-high-risk-environment: true
84+
85+
# Step 4: Print Input Values
86+
- name: Print Input Values
87+
env:
88+
PLATFORM: ${{ inputs.platform }}
89+
CHECKOUT_BASE_BRANCH: ${{ inputs.checkout-base-branch }}
90+
RELEASE_PR_BASE_BRANCH: ${{ inputs.release-pr-base-branch }}
91+
SEMVER_VERSION: ${{ inputs.semver-version }}
92+
PREVIOUS_VERSION_REF: ${{ inputs.previous-version-ref }}
93+
TEST_ONLY: ${{ inputs.test-only }}
94+
MOBILE_BUILD_VERSION: ${{ inputs.mobile-build-version }}
95+
MOBILE_TEMPLATE_SHEET_ID: ${{ inputs.mobile-template-sheet-id }}
96+
EXTENSION_TEMPLATE_SHEET_ID: ${{ inputs.extension-template-sheet-id }}
97+
RELEASE_SHEET_GOOGLE_DOCUMENT_ID: ${{ inputs.release-sheet-google-document-id }}
98+
GIT_USER_NAME: ${{ inputs.git-user-name }}
99+
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
100+
shell: bash
101+
run: |
102+
echo "Input Values:"
103+
echo "-------------"
104+
echo "Platform: $PLATFORM"
105+
echo "Checkout Base Branch: $CHECKOUT_BASE_BRANCH"
106+
echo "Release PR Base Branch: $RELEASE_PR_BASE_BRANCH"
107+
echo "Semver Version: $SEMVER_VERSION"
108+
echo "Previous Version Reference: $PREVIOUS_VERSION_REF"
109+
echo "Test Only Mode: $TEST_ONLY"
110+
if [[ "$PLATFORM" == "mobile" ]]; then
111+
echo "Mobile Build Version: $MOBILE_BUILD_VERSION"
112+
fi
113+
echo "Mobile Template Sheet ID: $MOBILE_TEMPLATE_SHEET_ID"
114+
echo "Extension Template Sheet ID: $EXTENSION_TEMPLATE_SHEET_ID"
115+
echo "Release Sheet Google Document ID: $RELEASE_SHEET_GOOGLE_DOCUMENT_ID"
116+
echo "Git User Name: $GIT_USER_NAME"
117+
echo "Git User Email: $GIT_USER_EMAIL"
118+
echo "-------------"
119+
120+
# Step 5: Create Release PR
121+
- name: Create Release PR
122+
id: create-release-pr
123+
shell: bash
124+
env:
125+
GITHUB_TOKEN: ${{ inputs.github-token }}
126+
BASE_BRANCH: ${{ inputs.release-pr-base-branch }}
127+
GITHUB_REPOSITORY_URL: '${{ github.server_url }}/${{ github.repository }}'
128+
TEST_ONLY: ${{ inputs.test-only }}
129+
GOOGLE_DOCUMENT_ID: ${{ inputs.release-sheet-google-document-id }}
130+
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ inputs.google-application-creds-base64 }}
131+
NEW_VERSION: ${{ inputs.semver-version }}
132+
MOBILE_TEMPLATE_SHEET_ID: ${{ inputs.mobile-template-sheet-id }}
133+
EXTENSION_TEMPLATE_SHEET_ID: ${{ inputs.extension-template-sheet-id }}
134+
PLATFORM: ${{ inputs.platform }}
135+
PREVIOUS_VERSION_REF: ${{ inputs.previous-version-ref }}
136+
SEMVER_VERSION: ${{ inputs.semver-version }}
137+
MOBILE_BUILD_VERSION: ${{ inputs.mobile-build-version }}
138+
GIT_USER_NAME: ${{ inputs.git-user-name }}
139+
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
140+
working-directory: ${{ github.workspace }}
141+
run: |
142+
# Execute the script from github-tools
143+
./github-tools/.github/scripts/create-platform-release-pr.sh \
144+
"$PLATFORM" \
145+
"$PREVIOUS_VERSION_REF" \
146+
"$SEMVER_VERSION" \
147+
"$MOBILE_BUILD_VERSION" \
148+
"$GIT_USER_NAME" \
149+
"$GIT_USER_EMAIL"
150+
151+
# Step 6: Upload commits.csv as artifact (if generated)
152+
- name: Upload commits.csv artifact
153+
if: ${{ hashFiles('commits.csv') != '' }}
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: commits-csv
157+
path: commits.csv
158+
if-no-files-found: error
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Post Merge Validation
2+
description: 'Tracks PRs merged to main and updates a Google Spreadsheet with validation status.'
3+
4+
inputs:
5+
repo:
6+
description: 'The repo owner/name to process (e.g. MetaMask/metamask-extension)'
7+
required: true
8+
start-hour-utc:
9+
description: 'The hour of the day (UTC) to start processing the PRs merged in main'
10+
required: true
11+
spreadsheet-id:
12+
description: 'Google Spreadsheet ID to update'
13+
required: false
14+
default: '1tsoodlAlyvEUpkkcNcbZ4PM9HuC9cEM80RZeoVv5OCQ'
15+
lookback-days:
16+
description: 'Number of days to look back for PRs'
17+
required: false
18+
default: '1'
19+
github-token:
20+
description: 'GitHub token with repo access'
21+
required: true
22+
google-application-creds-base64:
23+
description: 'Base64 encoded Google service account credentials'
24+
required: true
25+
github-tools-repository:
26+
description: 'The GitHub repository containing the GitHub tools. Defaults to the GitHub tools action repositor, and usually does not need to be changed.'
27+
required: false
28+
default: ${{ github.action_repository }}
29+
github-tools-ref:
30+
description: 'The SHA of the action to use. Defaults to the current action ref, and usually does not need to be changed.'
31+
required: false
32+
default: ${{ github.action_ref }}
33+
34+
runs:
35+
using: composite
36+
steps:
37+
- name: Checkout GitHub tools repository
38+
uses: actions/checkout@v5
39+
with:
40+
repository: ${{ inputs.github-tools-repository }}
41+
ref: ${{ inputs.github-tools-ref }}
42+
path: ./github-tools
43+
44+
- name: Set up Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version-file: ./github-tools/.nvmrc
48+
cache-dependency-path: ./github-tools/yarn.lock
49+
cache: yarn
50+
51+
- name: Enable Corepack
52+
shell: bash
53+
run: corepack enable
54+
working-directory: ./github-tools
55+
56+
- name: Install dependencies
57+
working-directory: ./github-tools
58+
shell: bash
59+
run: yarn --immutable
60+
61+
- name: Run post-merge-validation script
62+
working-directory: ./github-tools
63+
env:
64+
SHEET_ID: ${{ inputs.spreadsheet-id }}
65+
START_HOUR_UTC: ${{ inputs.start-hour-utc }}
66+
LOOKBACK_DAYS: ${{ inputs.lookback-days }}
67+
REPO: ${{ inputs.repo }}
68+
GITHUB_TOKEN: ${{ inputs.github-token }}
69+
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ inputs.google-application-creds-base64 }}
70+
shell: bash
71+
run: node .github/scripts/post-merge-validation-tracker.mjs
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Stable Sync
2+
description: 'An action to sync the release branch to main for a given semantic version.'
3+
4+
inputs:
5+
semver-version:
6+
required: true
7+
description: 'The semantic version to use for the sync (e.g., x.x.x)'
8+
repo-type:
9+
required: false
10+
description: 'Type of repository (mobile or extension)'
11+
default: 'mobile'
12+
stable-branch-name:
13+
required: false
14+
description: 'The name of the stable branch to sync to (e.g., stable, main)'
15+
default: 'stable'
16+
github-token:
17+
description: 'GitHub token used for authentication.'
18+
required: true
19+
github-tools-repository:
20+
description: 'The GitHub repository containing the GitHub tools. Defaults to the GitHub tools action repositor, and usually does not need to be changed.'
21+
required: false
22+
default: ${{ github.action_repository }}
23+
github-tools-ref:
24+
description: 'The SHA of the action to use. Defaults to the current action ref, and usually does not need to be changed.'
25+
required: false
26+
default: ${{ github.action_ref }}
27+
28+
runs:
29+
using: composite
30+
steps:
31+
- uses: actions/checkout@v5
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Checkout GitHub tools repository
36+
uses: actions/checkout@v5
37+
with:
38+
repository: ${{ inputs.github-tools-repository }}
39+
ref: ${{ inputs.github-tools-ref }}
40+
path: ./github-tools
41+
42+
- name: Setup Node.js Mobile
43+
if: ${{ inputs.repo-type == 'mobile' }}
44+
uses: actions/setup-node@v6
45+
with:
46+
node-version: '18'
47+
48+
- name: Setup Node.js Extension
49+
if: ${{ inputs.repo-type == 'extension' }}
50+
uses: actions/setup-node@v6
51+
with:
52+
node-version: '22.15'
53+
54+
- name: Prepare Yarn
55+
if: ${{ inputs.repo-type == 'extension' }}
56+
shell: bash
57+
run: corepack prepare [email protected] --activate
58+
59+
- name: Prepare Yarn - Enable corepack
60+
if: ${{ inputs.repo-type == 'extension' }}
61+
shell: bash
62+
run: corepack enable
63+
64+
- name: Check if PR exists
65+
id: check-pr
66+
uses: actions/github-script@v7
67+
with:
68+
script: |
69+
const { data: prs } = await github.rest.pulls.list({
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
head: `${context.repo.owner}:stable-main-${process.env.SEMVER_VERSION}`,
73+
base: 'main'
74+
});
75+
return prs.length > 0;
76+
env:
77+
SEMVER_VERSION: ${{ inputs.semver-version }}
78+
79+
- name: Set Git user and email
80+
shell: bash
81+
run: |
82+
git config --global user.name "metamaskbot"
83+
git config --global user.email "[email protected]"
84+
85+
- name: Run stable sync
86+
id: run-stable-sync
87+
# if: steps.check-pr.outputs.result != 'true'
88+
env:
89+
CREATE_BRANCH: 'false' # let the script handle the branch creation
90+
REPO: ${{ inputs.repo-type }} # Default to 'mobile' if not specified
91+
BASE_BRANCH: ${{ inputs.stable-branch-name }}
92+
SEMVER_VERSION: ${{ inputs.semver-version }}
93+
shell: bash
94+
run: |
95+
# Ensure github-tools is in .gitignore to prevent it from being committed
96+
if ! grep -q "^github-tools/" .gitignore 2>/dev/null; then
97+
echo "github-tools/" >> .gitignore
98+
echo "Added github-tools/ to .gitignore"
99+
fi
100+
101+
# Execute the script from github-tools
102+
node ./github-tools/.github/scripts/stable-sync.js "stable-main-$SEMVER_VERSION"
103+
BRANCH_NAME="stable-main-$SEMVER_VERSION"
104+
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
105+
echo "Branch $BRANCH_NAME exists remotely, force pushing to overwrite"
106+
git push origin "$BRANCH_NAME" --force
107+
else
108+
echo "Branch $BRANCH_NAME doesn't exist remotely, pushing with --set-upstream"
109+
git push --set-upstream origin "$BRANCH_NAME"
110+
fi
111+
112+
- name: Create Pull Request
113+
if: steps.check-pr.outputs.result != 'true'
114+
env:
115+
GITHUB_TOKEN: ${{ inputs.github-token }}
116+
BRANCH_NAME: stable-main-${{ inputs.semver-version }}
117+
VERSION: ${{ inputs.semver-version }}
118+
shell: bash
119+
run: |
120+
# Create PR using GitHub CLI
121+
gh pr create \
122+
--title "release: sync stable to main for version $VERSION" \
123+
--body "This PR syncs the stable branch to main for version $VERSION.
124+
125+
*Synchronization Process:*
126+
127+
- Fetches the latest changes from the remote repository
128+
- Resets the branch to match the stable branch
129+
- Attempts to merge changes from main into the branch
130+
- Handles merge conflicts if they occur
131+
132+
*File Preservation:*
133+
134+
Preserves specific files from the stable branch:
135+
- CHANGELOG.md
136+
- bitrise.yml
137+
- android/app/build.gradle
138+
- ios/MetaMask.xcodeproj/project.pbxproj
139+
- package.json
140+
141+
Indicates the next version candidate of main to $VERSION" \
142+
--base main \
143+
--head "$BRANCH_NAME"
144+
#--label "sync" \
145+
#--label "stable"

0 commit comments

Comments
 (0)