Skip to content

add github workflow for npm release #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
615d6a7
feat: support rn 0.76
ieow May 6, 2025
3ad58f4
fix: require @react-native-community/cli
ieow May 6, 2025
971cd07
fix: filterByAuthorizedAccounts
ieow Jun 24, 2025
f3ef39a
Merge branch 'main' into feat/rn0.76
ieow Jun 24, 2025
97d5133
feat: rename package
ieow Jun 24, 2025
568a680
feat: github ci workflow
ieow Jun 26, 2025
cbf746d
chore: remove node 18.x ci check
ieow Jun 26, 2025
24a0bf5
fix: add allowscript
ieow Jun 26, 2025
67a22e9
chore: add build script
ieow Jun 26, 2025
fe99fad
fix: yarn
ieow Jun 26, 2025
8fff19d
fix: update corepack enable
ieow Jun 26, 2025
7f7e88a
fix: yarn v4 ci
ieow Jun 26, 2025
439623f
fix: ci syntax
ieow Jun 26, 2025
e59bc81
fix: ci syntax
ieow Jun 26, 2025
87748e0
chore: use jq
ieow Jun 26, 2025
7f49bb8
fix: yarn 4.9.2
ieow Jun 27, 2025
23ec411
chore: update checkout and setup action
ieow Jun 27, 2025
c09f320
fix: ci syntax
ieow Jun 27, 2025
5886efa
fix: remove unused file
ieow Jun 27, 2025
caf8e34
fix: add matrix version
ieow Jun 27, 2025
a25e5a3
chore: update changelog.md
ieow Jun 27, 2025
0af287f
chore: remove .yarnrc
ieow Jun 27, 2025
e8407cd
Merge branch 'main' into feat/github-workflow
ieow Jun 30, 2025
45307c9
feat: update yarn, lib
ieow Jun 30, 2025
6e9a070
fix: syntax
ieow Jun 30, 2025
508a069
fix: call all lint's script in lint
ieow Jun 30, 2025
ecbfca0
fix: changelog
ieow Jun 30, 2025
25e30a7
chore: add depcheck ignore
ieow Jun 30, 2025
e657dac
chore: update depcheck ignore
ieow Jun 30, 2025
5ddd553
fix: address comment
ieow Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"ignores": [
"@commitlint/config-conventional",
"@evilmartians/lefthook",
"@react-native-community/cli",
"@react-native/eslint-config",
"@release-it/conventional-changelog",
"@typescript-eslint/eslint-plugin",
"commitlint",
"turbo",
"@lavamoat/allow-scripts",
"@lavamoat/preinstall-always-fail",
"@metamask/auto-changelog",
"@metamask/eslint-config",
"@metamask/eslint-config-*",
"@types/*",
"@typescript-eslint/utils",
"@vitest/coverage-istanbul",
"@vitest/eslint-plugin",
"@yarnpkg/types",
"eslint-config-*",
"eslint-import-resolver-typescript",
"eslint-plugin-*",
"prettier-plugin-packagejson",
"ts-node",
"typedoc",
"typescript-eslint",
"vite"
]
}
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

* @MetaMask/engineering
4 changes: 4 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ runs:
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Enable Corepack
run: corepack enable
shell: bash

- name: Restore dependencies
id: yarn-cache
Expand Down
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
time: '06:00'
allow:
- dependency-name: '@metamask/*'
target-branch: 'main'
versioning-strategy: 'increase-if-necessary'
open-pull-requests-limit: 10
117 changes: 117 additions & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build, Lint, and Test

on:
workflow_call:

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

build:
name: Build
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn build
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

lint:
name: Lint
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog --rc
- name: Validate changelog
if: ${{ !startsWith(github.head_ref, 'release/') }}
run: yarn lint:changelog
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

test:
name: Test
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- run: yarn test
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi

compatibility-test:
name: Compatibility test
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
- name: Install dependencies via Yarn
run: rm yarn.lock && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn
- run: yarn test
- name: Restore lockfile
run: git restore yarn.lock
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
88 changes: 51 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

- name: Lint files
run: yarn lint
Expand All @@ -28,38 +32,50 @@ jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage

build-library:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

- name: Build package
run: yarn prepare

build-android:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
env:
TURBO_CACHE_DIR: .turbo/android
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

- name: Cache turborepo for Android
uses: actions/cache@v4
Expand All @@ -71,17 +87,13 @@ jobs:

- name: Check turborepo cache for Android
run: |
# Execute yarn command and capture JSON output into a shell variable
JSON_OUTPUT=$(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)

JSON_OUTPUT=$(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry-run=json)
# Use node -p to parse the JSON *string* and extract the status
# Note the use of JSON.parse() and backticks (`) for the string literal
TURBO_CACHE_STATUS=$(node -p "JSON.parse(\`$JSON_OUTPUT\`).tasks.find(t => t.task === 'build:android').cache.status")

# TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
TURBO_CACHE_STATUS=$(echo "$JSON_OUTPUT" | jq -r ".tasks[] | select(.task == \"build:android\") | .cache.status // \"MISS\"")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
echo "turbo_cache_hit=1" >> "$GITHUB_ENV"
fi

- name: Install JDK
Expand Down Expand Up @@ -115,14 +127,18 @@ jobs:

build-ios:
runs-on: macos-latest
strategy:
matrix:
node-version: [22.x]
env:
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '22.x' }}

- name: Cache turborepo for iOS
uses: actions/cache@v4
Expand All @@ -135,16 +151,14 @@ jobs:
- name: Check turborepo cache for iOS
run: |
# Execute yarn command and capture JSON output into a shell variable
JSON_OUTPUT=$(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)
JSON_OUTPUT=$(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry-run=json)

# Use node -p to parse the JSON *string* and extract the status
# Note the use of JSON.parse() and backticks (`) for the string literal
TURBO_CACHE_STATUS=$(node -p "JSON.parse(\`$JSON_OUTPUT\`).tasks.find(t => t.task === 'build:ios').cache.status")

# TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
TURBO_CACHE_STATUS=$(echo "$JSON_OUTPUT" | jq -r ".tasks[] | select(.task == \"build:ios\") | .cache.status // \"MISS\"")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
echo "turbo_cache_hit=1" >> "$GITHUB_ENV"
fi

- name: Restore cocoapods
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create Release Pull Request

on:
workflow_dispatch:
inputs:
base-branch:
description: 'The base branch for git operations and the pull request.'
default: 'main'
required: true
release-type:
description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".'
required: false
release-version:
description: 'A specific version to bump to. Mutually exclusive with "release-type".'
required: false

jobs:
create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: true

# This is to guarantee that the most recent tag is fetched. This can
# be configured to a more reasonable value by consumers.
fetch-depth: 0

# We check out the specified branch, which will be used as the base
# branch for all git operations and the release PR.
ref: ${{ github.event.inputs.base-branch }}

- uses: MetaMask/action-create-release-pr@v4
with:
release-type: ${{ github.event.inputs.release-type }}
release-version: ${{ github.event.inputs.release-version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading
Loading