Sync Fork and Build Without LavaMoat #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync Fork and Build Without LavaMoat | |
on: | |
# Trigger on new releases in the original repo | |
repository_dispatch: | |
types: [upstream-release] | |
# Allow manual trigger | |
workflow_dispatch: | |
# Check for updates every day | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
sync-and-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
- name: Add upstream remote | |
run: | | |
git remote add upstream https://github.com/MetaMask/metamask-extension.git | |
git fetch upstream | |
- name: Sync with upstream | |
env: | |
PAT_TOKEN: ${{ secrets.PAT_TOKEN }} | |
RELEASE_TAG: ${{ github.event.client_payload.release }} | |
run: | | |
git checkout develop | |
git fetch upstream --tags # Fetch all tags | |
# If triggered by monitor, checkout the specific release tag | |
if [ -n "$RELEASE_TAG" ]; then | |
git checkout $RELEASE_TAG | |
else | |
git merge upstream/develop | |
fi | |
git push origin develop | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Setup environment | |
env: | |
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }} | |
run: | | |
# Copy the dist file | |
cp .metamaskrc.dist .metamaskrc | |
# Use different sed syntax for Linux | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
sed -i '' "s/INFURA_PROJECT_ID=.*/INFURA_PROJECT_ID=$INFURA_PROJECT_ID/g" .metamaskrc | |
else | |
sed -i "s/INFURA_PROJECT_ID=.*/INFURA_PROJECT_ID=$INFURA_PROJECT_ID/g" .metamaskrc | |
fi | |
- name: Install dependencies | |
run: yarn install | |
- name: Build without LavaMoat | |
run: yarn dist --apply-lavamoat=false | |
- name: Create Release | |
env: | |
GH_TOKEN: ${{ secrets.PAT_TOKEN }} | |
RELEASE_TAG: ${{ github.event.client_payload.release }} | |
run: | | |
# Use the tag version if provided, otherwise use package.json | |
if [ -n "$RELEASE_TAG" ]; then | |
VERSION=${RELEASE_TAG#v} # Remove 'v' prefix if present | |
else | |
VERSION=$(node -p "require('./package.json').version") | |
fi | |
# Check if release already exists | |
if gh release view "v${VERSION}-no-lavamoat" --repo ${{ github.repository }} &>/dev/null; then | |
echo "Release v${VERSION}-no-lavamoat already exists. Skipping release creation." | |
exit 0 | |
fi | |
# Create the release | |
gh release create "v${VERSION}-no-lavamoat" \ | |
--repo ${{ github.repository }} \ | |
--title "v${VERSION} (No LavaMoat)" \ | |
--notes "MetaMask v${VERSION} built without LavaMoat" \ | |
./builds/metamask-chrome-*.zip \ | |
./builds/metamask-firefox-*.zip |