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 15 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
22 changes: 22 additions & 0 deletions .depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"ignores": [
"@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"
]
}
1 change: 1 addition & 0 deletions .github/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enableScripts: false
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: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Feature Request 💡
url: https://github.com/ieow/react-native-google-acm/discussions/new?category=ideas
url: https://github.com/Metamask/react-native-acm/discussions/new?category=ideas
about: If you have a feature request, please create a new discussion on GitHub.
- name: Discussions on GitHub 💬
url: https://github.com/ieow/react-native-google-acm/discussions
url: https://github.com/Metamask/react-native-acm/discussions
about: If this library works as promised but you need help, please ask questions there.
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
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?

Are there any issues or other links reviewers should consult to understand this pull request better? For instance:

* Fixes #12345
* See: #67890
-->

## Examples

<!--
Are there any examples of this change being used in another repository?

When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later.
-->
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
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ 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
Expand Down Expand Up @@ -135,13 +133,11 @@ 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
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 }}
93 changes: 93 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Main

on:
push:
branches: [main]
pull_request:

jobs:
check-workflows:
name: Check workflows
runs-on: ubuntu-latest
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
- name: Download actionlint
id: download-actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23
shell: bash
- name: Check workflow files
run: ${{ steps.download-actionlint.outputs.executable }} -color
shell: bash

analyse-code:
name: Code scanner
needs: check-workflows
uses: ./.github/workflows/security-code-scanner.yml
permissions:
actions: read
contents: read
security-events: write
secrets:
SECURITY_SCAN_METRICS_TOKEN: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }}
APPSEC_BOT_SLACK_WEBHOOK: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }}

build-lint-test:
name: Build, lint, and test
uses: ./.github/workflows/build-lint-test.yml

all-jobs-completed:
name: All jobs completed
runs-on: ubuntu-latest
needs:
- check-workflows
- analyse-code
- build-lint-test
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"

all-jobs-pass:
name: All jobs pass
if: ${{ always() }}
runs-on: ubuntu-latest
needs: all-jobs-completed
steps:
- name: Check that all jobs have passed
run: |
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
exit 1
fi

is-release:
# Filtering by `push` events ensures that we only release from the `main` branch, which is a
# requirement for our npm publishing environment.
# The commit author should always be 'github-actions' for releases created by the
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally
# triggering a release.
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions')
needs: all-jobs-pass
outputs:
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
runs-on: ubuntu-latest
steps:
- uses: MetaMask/action-is-release@v1
id: is-release

publish-release:
needs: is-release
if: needs.is-release.outputs.IS_RELEASE == 'true'
name: Publish release
permissions:
contents: write
uses: ./.github/workflows/publish-release.yml
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading
Loading