diff --git a/.github/workflows/create-update-issues.yml b/.github/workflows/create-update-issues.yml deleted file mode 100644 index 93ae77b..0000000 --- a/.github/workflows/create-update-issues.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Create Update Issues - -on: - workflow_call: - -permissions: - contents: read - -jobs: - create-update-issues: - environment: default-branch - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - steps: - - name: Checkout head - uses: actions/checkout@v5 - - name: Fetch tags - run: git fetch --prune --unshallow --tags - - name: Get extension token - id: extension-token - uses: MetaMask/github-tools/.github/actions/get-token@v1 - with: - token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }} - target-repository: 'MetaMask/metamask-extension' - permissions: | - contents: read - issues: write - metadata: read - - name: Get mobile token - id: mobile-token - uses: MetaMask/github-tools/.github/actions/get-token@v1 - with: - token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }} - target-repository: 'MetaMask/metamask-mobile' - permissions: | - contents: read - issues: write - metadata: read - - name: Create issues in extension and mobile repositories - run: ./scripts/create-update-issues.sh --no-dry-run - env: - EXTENSION_GITHUB_TOKEN: ${{ steps.extension-token.outputs.token }} - MOBILE_GITHUB_TOKEN: ${{ steps.mobile-token.outputs.token }} diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index 5f5046b..ceae7f2 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -37,7 +37,6 @@ jobs: - lint:misc:check - constraints - lint:dependencies - - lint:teams - readme-content:check steps: - name: Checkout and setup environment diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 781af33..5bc310d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -118,15 +118,6 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - create-update-issues: - name: Create update issues - needs: [is-release, publish-release] - if: needs.is-release.outputs.IS_RELEASE == 'true' - uses: ./.github/workflows/create-update-issues.yml - permissions: - contents: read - id-token: write - all-jobs-complete: name: All jobs complete runs-on: ubuntu-latest diff --git a/.github/workflows/publish-preview.yml b/.github/workflows/publish-preview.yml index d3446a8..8835511 100644 --- a/.github/workflows/publish-preview.yml +++ b/.github/workflows/publish-preview.yml @@ -18,3 +18,14 @@ jobs: docs-url: 'https://github.com/MetaMask/core/blob/main/docs/processes/preview-builds.md' secrets: PUBLISH_PREVIEW_NPM_TOKEN: ${{ secrets.PUBLISH_PREVIEW_NPM_TOKEN }} + BUILD_ENV: | + { + "LOG_LEVEL": "${{ secrets.LOG_LEVEL }}", + "DEFAULT_ADDRESS_TYPE": "${{ secrets.DEFAULT_ADDRESS_TYPE }}", + "ESPLORA_BITCOIN": "${{ secrets.ESPLORA_BITCOIN }}", + "ESPLORA_TESTNET": "${{ secrets.ESPLORA_TESTNET }}", + "ESPLORA_TESTNET4": "${{ secrets.ESPLORA_TESTNET4 }}", + "ESPLORA_SIGNET": "${{ secrets.ESPLORA_SIGNET }}", + "ESPLORA_REGTEST": "${{ secrets.ESPLORA_REGTEST }}", + "PRICE_API_URL": "${{ secrets.PRICE_API_URL }}" + } diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 1ddf617..1a4a80f 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -7,6 +7,22 @@ on: required: false SLACK_WEBHOOK_URL: required: true + LOG_LEVEL: + required: false + DEFAULT_ADDRESS_TYPE: + required: false + ESPLORA_BITCOIN: + required: false + ESPLORA_TESTNET: + required: false + ESPLORA_TESTNET4: + required: false + ESPLORA_SIGNET: + required: false + ESPLORA_REGTEST: + required: false + PRICE_API_URL: + required: false permissions: contents: read @@ -17,6 +33,7 @@ concurrency: jobs: publish-release: + environment: default-branch permissions: contents: write runs-on: ubuntu-latest @@ -29,6 +46,15 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: yarn build + env: + LOG_LEVEL: ${{ secrets.LOG_LEVEL }} + DEFAULT_ADDRESS_TYPE: ${{ secrets.DEFAULT_ADDRESS_TYPE }} + ESPLORA_BITCOIN: ${{ secrets.ESPLORA_BITCOIN }} + ESPLORA_TESTNET: ${{ secrets.ESPLORA_TESTNET }} + ESPLORA_TESTNET4: ${{ secrets.ESPLORA_TESTNET4 }} + ESPLORA_SIGNET: ${{ secrets.ESPLORA_SIGNET }} + ESPLORA_REGTEST: ${{ secrets.ESPLORA_REGTEST }} + PRICE_API_URL: ${{ secrets.PRICE_API_URL }} - name: Upload build artifacts uses: actions/upload-artifact@v6 with: diff --git a/AGENTS.md b/AGENTS.md index df8a4d6..e9941d0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,7 +38,6 @@ The monorepo uses a hierarchical configuration approach for different tools. For ### Contributing teams and codeowners - `CODEOWNERS` defines which GitHub teams own which packages in the monorepo. -- `teams.json` instructs the `create-update-issues` GitHub workflow which labels to assign issues that are created when there are new major version releases of packages. ### Yarn diff --git a/package.json b/package.json index 72244c6..90ee368 100644 --- a/package.json +++ b/package.json @@ -22,14 +22,13 @@ "changelog:validate": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:validate", "create-release-branch": "create-release-branch --formatter oxfmt", "create-package": "tsx scripts/create-package", - "lint": "yarn lint:eslint && echo && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn lint:teams && yarn readme-content:check", + "lint": "yarn lint:eslint && echo && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn readme-content:check", "lint:dependencies": "depcheck && yarn dedupe --check", "lint:dependencies:fix": "depcheck && yarn dedupe", "lint:eslint": "yarn build:only-clean && NODE_OPTIONS='--max-old-space-size=6144' yarn eslint", "lint:fix": "yarn lint:eslint --fix --prune-suppressions && echo && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix && yarn readme-content:update", "lint:misc": "oxfmt --ignore-path .gitignore", "lint:misc:check": "yarn lint:misc --check", - "lint:teams": "tsx scripts/lint-teams-json.ts", "prepack": "./scripts/prepack.sh", "prepare-preview-builds": "./scripts/prepare-preview-builds.sh", "readme-content:check": "tsx scripts/update-readme-content.ts --check", diff --git a/scripts/create-update-issues.sh b/scripts/create-update-issues.sh deleted file mode 100755 index a1206b4..0000000 --- a/scripts/create-update-issues.sh +++ /dev/null @@ -1,272 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -DEFAULT_REF="HEAD" -DEFAULT_LABEL="client-controller-update" -EXTENSION_REPO="MetaMask/metamask-extension" -MOBILE_REPO="MetaMask/metamask-mobile" - -print-usage() { - cat < gh issue create --title \"$title\" --body \"$body\" --repo \"$repo\" --label \"$labels\"" - else - GH_TOKEN="$token" gh issue create --title "$title" --body "$body" --repo "$repo" --label "$labels" - fi -} - -create-issue() { - local dry_run="$1" - local repo="$2" - local package_name="$3" - local version="$4" - local team_labels="$5" - local token="$6" - - local title="Upgrade ${package_name} to version ${version}" - local body="A new major version of \`${package_name}\`, ${version}, is now available. This issue has been assigned to you and your team because you code-own this package in the \`core\` repo. If this package is present in this project, please prioritize upgrading it soon to unblock new features and bugfixes." - local labels="$DEFAULT_LABEL" - if [[ -n $team_labels ]]; then - labels+=",$team_labels" - fi - - local exitcode - - echo - echo "Creating issue in ${repo} with labels: \"${labels}\"..." - - echo "----------------------------------------" - set +e - run-create-issue-command "$dry_run" "$repo" "$title" "$body" "$labels" "$token" - exitcode=$? - set -e - echo "----------------------------------------" - - if [[ $exitcode -eq 0 ]]; then - if [[ -n $team_labels ]]; then - if [[ $dry_run -eq 1 ]]; then - echo "✅ Would have successfully created issue!" - else - echo "✅ Successfully created issue!" - fi - else - if [[ $dry_run -eq 1 ]]; then - echo "⚠️ Would have successfully created issue, but you would need to assign the correct team label." - else - echo "⚠️ Successfully created issue, but you will need to assign the correct team label (see URL above)." - fi - fi - else - echo "❌ Issue was not created. Please create an issue manually which requests that ${package_name} be updated to version ${version}, assigning the correct team labels." - fi - - return $exitcode -} - -main() { - local tag_array - local package_name - local package_name_without_leading_at - local version - local found_team_labels - local team_labels - - local exitcode=0 - local dry_run=1 - local ref="$DEFAULT_REF" - - while [[ $# -gt 0 ]]; do - case "$1" in - --ref|-r) - if [[ -n "${2:-}" ]] && ! [[ "$2" =~ ^- ]]; then - ref="$2" - shift 2 - else - ref="" - shift - fi - ;; - --no-dry-run) - dry_run=0 - shift - ;; - --help|-h) - print-usage - exit 0 - ;; - *) - echo "ERROR: Unknown argument: $1" - echo "---------------------" - print-usage - exit 1 - ;; - esac - done - - if [[ -z "$ref" ]]; then - echo "ERROR: Missing ref." - echo "---------------------" - print-usage - exit 1 - fi - - local full_ref - if ! full_ref="$(git rev-parse "$ref" 2>/dev/null)"; then - echo "ERROR: Unknown ref \"$ref\"." - echo "---------------------" - print-usage - exit 1 - fi - - if [[ $dry_run -eq 1 ]]; then - echo "[[[ DRY-RUN MODE ]]]" - echo - fi - - if [[ "$full_ref" == "$ref" ]]; then - echo "Looking for release tags pointing to $full_ref for major-bumped packages..." - else - echo "Looking for release tags pointing to $ref ($full_ref) for major-bumped packages..." - fi - tag_array=() - while IFS= read -r line; do - if [[ "$line" =~ ^@metamask/[^@]+@[0-9]+\.0\.0$ ]]; then - tag_array+=("$line") - fi - done < <(git tag --points-at "$full_ref" 2>/dev/null || true) - - if [[ "${#tag_array[@]}" -eq 0 ]]; then - echo "No tags to process, nothing to do." - exit 0 - fi - - echo - - local all_issues_extension - echo "Fetching issues on $EXTENSION_REPO with label $DEFAULT_LABEL..." - if ! all_issues_extension="$(GH_TOKEN="${EXTENSION_GITHUB_TOKEN:-}" gh issue list --repo "$EXTENSION_REPO" --label "$DEFAULT_LABEL" --state all --json number,title,url 2>&1)"; then - echo "❌ Failed to fetch issues from ${EXTENSION_REPO}" - echo "$all_issues_extension" - exit 1 - fi - - local all_issues_mobile - echo "Fetching issues on $MOBILE_REPO with label $DEFAULT_LABEL..." - if ! all_issues_mobile="$(GH_TOKEN="${MOBILE_GITHUB_TOKEN:-}" gh issue list --repo "$MOBILE_REPO" --label "$DEFAULT_LABEL" --state all --json number,title,url 2>&1)"; then - echo "❌ Failed to fetch issues from ${MOBILE_REPO}" - echo "$all_issues_mobile" - exit 1 - fi - - for tag in "${tag_array[@]}"; do - # The tag name looks like "@", - # and "" looks like "@metamask/*" - package_name="${tag%@*}" - package_name_without_leading_at="${package_name#@}" - version="${tag##*@}" - - echo - echo "=== ${package_name} ${version} ===" - echo - - # Use teams.json to determine which teams code-own this package, and what their labels are - found_team_labels=$(jq --raw-output --arg key "${package_name_without_leading_at}" '.[$key]' teams.json) - if [[ $found_team_labels == "null" ]]; then - echo "Did not find team labels for ${package_name}. Creating issues anyway..." - team_labels="" - exitcode=1 - else - echo "Found team labels for ${package_name}: \"${found_team_labels}\". Creating issues..." - team_labels="$found_team_labels" - fi - - # Create the extension issue, if it doesn't exist yet - echo - echo "Checking for existing issues in ${EXTENSION_REPO}..." - if existing-issue-found "${EXTENSION_REPO}" "$package_name" "$version" "$all_issues_extension"; then - if [[ $dry_run -eq 1 ]]; then - echo "⏭️ Would not have created issue because it already exists" - else - echo "⏭️ Not creating issue because it already exists" - fi - elif ! create-issue "$dry_run" "$EXTENSION_REPO" "$package_name" "$version" "$team_labels" "${EXTENSION_GITHUB_TOKEN:-}"; then - exitcode=1 - fi - - # Create the mobile issue, if it doesn't exist yet - echo - echo "Checking for existing issues in ${MOBILE_REPO}..." - if existing-issue-found "${MOBILE_REPO}" "$package_name" "$version" "$all_issues_mobile"; then - if [[ $dry_run -eq 1 ]]; then - echo "⏭️ Would not have created issue because it already exists" - else - echo "⏭️ Not creating issue because it already exists" - fi - elif ! create-issue "$dry_run" "$MOBILE_REPO" "$package_name" "$version" "$team_labels" "${MOBILE_GITHUB_TOKEN:-}"; then - exitcode=1 - fi - done - - if [[ $exitcode -ne 0 ]]; then - echo - echo "One or more warnings or errors were found. See above for details." - fi - - return $exitcode -} - -main "$@" diff --git a/scripts/lint-teams-json.ts b/scripts/lint-teams-json.ts deleted file mode 100644 index 7fcb68b..0000000 --- a/scripts/lint-teams-json.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { readJsonFile } from '@metamask/utils/node'; -import execa from 'execa'; -import path from 'path'; - -type Workspace = { - location: string; - name: string; -}; - -// Run the script immediately. -main().catch((error) => { - console.error(error); - process.exitCode = 1; -}); - -/** - * The entrypoint to this script. - * - * Cross-checks the packages listed in `teams.json` against the public packages - * in the monorepo. If there are any packages missing from `teams.json`, prints - * an error and exits with a non-zero code. - */ -async function main(): Promise { - const releaseableWorkspaces = await getPublicWorkspaces(); - const releaseablePackageNames = releaseableWorkspaces.map((workspace) => { - // The package names in teams.json omit the leading "@", so we do that here - // too in order to be consistent - return workspace.name.slice(1); - }); - - const teams = await readJsonFile>( - path.resolve(__dirname, '../teams.json'), - ); - const assignedPackageNames = Object.keys(teams); - - const missingPackageNames = releaseablePackageNames.filter( - (releaseablePackageName) => { - return !assignedPackageNames.includes(releaseablePackageName); - }, - ); - - if (missingPackageNames.length > 0) { - console.error( - 'ERROR: teams.json is invalid. Please add the following packages:', - ); - for (const missingPackageName of missingPackageNames) { - console.error(`- ${missingPackageName}`); - } - process.exitCode = 1; - } -} - -/** - * Uses the `yarn` executable to gather the Yarn workspaces inside of this - * project (the packages that are matched by the `workspaces` field inside of - * `package.json`). - * - * @returns The list of workspaces. - */ -async function getPublicWorkspaces(): Promise { - const { stdout } = await execa('yarn', [ - 'workspaces', - 'list', - '--json', - '--no-private', - ]); - - return stdout ? stdout.split('\n').map((line) => JSON.parse(line)) : []; -} diff --git a/teams.json b/teams.json deleted file mode 100644 index 4b836b4..0000000 --- a/teams.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "metamask/sample-snap": "team-networks", - "metamask/bitcoin-wallet-snap": "team-networks" -}