Skip to content

Commit bccca7f

Browse files
authored
ci: migrate publish-preview workflow to MetaMask/github-tools (#73)
## Explanation <!-- 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 changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> Replace the bespoke publish-preview workflow and its supporting scripts with a call to the reusable workflow from MetaMask/github-tools. The reusable workflow (with is-snap: true) now handles manifest renaming, publishing, and PR comment generation, so the local helper scripts are no longer needed. Build-time configuration is forwarded to the reusable workflow via the new BUILD_ENV secret. Note: the workflow is temporarily pinned to the mikesposito/snap-previews branch of github-tools for testing. This should be updated to a tagged release before merging. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> N/A ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
1 parent 9c43641 commit bccca7f

6 files changed

Lines changed: 27 additions & 169 deletions

File tree

.github/workflows/publish-preview.yml

Lines changed: 27 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,32 @@ on:
44
issue_comment:
55
types: created
66

7-
jobs:
8-
is-fork-pull-request:
9-
name: Determine whether this issue comment was on a pull request from a fork
10-
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot publish-preview') }}
11-
runs-on: ubuntu-latest
12-
outputs:
13-
IS_FORK: ${{ steps.is-fork.outputs.IS_FORK }}
14-
steps:
15-
- uses: actions/checkout@v5
16-
- name: Determine whether this PR is from a fork
17-
id: is-fork
18-
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT"
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
PR_NUMBER: ${{ github.event.issue.number }}
7+
permissions:
8+
contents: read
9+
pull-requests: write
2210

11+
jobs:
2312
publish-preview:
24-
name: Publish build preview
25-
needs: is-fork-pull-request
26-
permissions:
27-
pull-requests: write
28-
# This ensures we don't publish on forks. We can't trust forks with this token.
29-
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }}
30-
runs-on: ubuntu-latest
31-
steps:
32-
- uses: actions/checkout@v5
33-
- name: Check out pull request
34-
run: gh pr checkout "${PR_NUMBER}"
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
PR_NUMBER: ${{ github.event.issue.number }}
38-
- name: Checkout and setup environment
39-
uses: MetaMask/action-checkout-and-setup@v2
40-
with:
41-
is-high-risk-environment: true
42-
- name: Build
43-
run: yarn build:prod
44-
env:
45-
ENVIRONMENT: production
46-
LOG_LEVEL: all
47-
RPC_URL_MAINNET: ${{ secrets.RPC_URL_MAINNET }}
48-
HORIZON_URL_MAINNET: ${{ secrets.HORIZON_URL_MAINNET }}
49-
EXPLORER_MAINNET_BASE_URL: ${{ secrets.EXPLORER_MAINNET_BASE_URL }}
50-
RPC_URL_TESTNET: ${{ secrets.RPC_URL_TESTNET }}
51-
HORIZON_URL_TESTNET: ${{ secrets.HORIZON_URL_TESTNET }}
52-
EXPLORER_TESTNET_BASE_URL: ${{ secrets.EXPLORER_TESTNET_BASE_URL }}
53-
TOKEN_API_BASE_URL: ${{ secrets.TOKEN_API_BASE_URL }}
54-
STATIC_API_BASE_URL: ${{ secrets.STATIC_API_BASE_URL }}
55-
PRICE_API_BASE_URL: ${{ secrets.PRICE_API_BASE_URL }}
56-
- name: Get commit SHA
57-
id: commit-sha
58-
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
59-
- name: Prepare preview builds
60-
run: yarn prepare-preview-builds @metamask-previews ${{ steps.commit-sha.outputs.COMMIT_SHA }}
61-
- name: Publish preview build
62-
run: yarn publish-previews
63-
env:
64-
YARN_NPM_AUTH_TOKEN: ${{ secrets.PUBLISH_PREVIEW_NPM_TOKEN }}
65-
- name: Generate preview build message
66-
run: yarn tsx scripts/generate-preview-build-message.ts
67-
- name: Post build preview in comment
68-
run: gh pr comment "${PR_NUMBER}" --body-file preview-build-message.txt
69-
env:
70-
COMMIT_SHA: ${{ steps.commit-sha.outputs.COMMIT_SHA }}
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72-
PR_NUMBER: ${{ github.event.issue.number }}
13+
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot publish-preview') }}
14+
uses: MetaMask/github-tools/.github/workflows/publish-preview.yml@mikesposito/snap-previews
15+
with:
16+
is-snap: true
17+
environment: default-branch
18+
build-command: yarn workspace @metamask/stellar-wallet-snap build:prod
19+
docs-url: 'https://github.com/MetaMask/core/blob/main/docs/processes/preview-builds.md'
20+
secrets:
21+
PUBLISH_PREVIEW_NPM_TOKEN: ${{ secrets.PUBLISH_PREVIEW_NPM_TOKEN }}
22+
BUILD_ENV: |
23+
{
24+
"ENVIRONMENT": "production",
25+
"LOG_LEVEL": "all",
26+
"RPC_URL_MAINNET": "${{ secrets.RPC_URL_MAINNET }}",
27+
"HORIZON_URL_MAINNET": "${{ secrets.HORIZON_URL_MAINNET }}",
28+
"EXPLORER_MAINNET_BASE_URL": "${{ secrets.EXPLORER_MAINNET_BASE_URL }}",
29+
"RPC_URL_TESTNET": "${{ secrets.RPC_URL_TESTNET }}",
30+
"HORIZON_URL_TESTNET": "${{ secrets.HORIZON_URL_TESTNET }}",
31+
"EXPLORER_TESTNET_BASE_URL": "${{ secrets.EXPLORER_TESTNET_BASE_URL }}",
32+
"TOKEN_API_BASE_URL": "${{ secrets.TOKEN_API_BASE_URL }}",
33+
"STATIC_API_BASE_URL": "${{ secrets.STATIC_API_BASE_URL }}",
34+
"PRICE_API_BASE_URL": "${{ secrets.PRICE_API_BASE_URL }}"
35+
}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
"lint:misc": "yarn workspaces foreach --all --parallel --verbose run lint:misc",
3030
"lint:types": "yarn workspaces foreach --all --parallel --verbose run lint:types",
3131
"format": "yarn workspaces foreach --all --parallel --verbose run format",
32-
"prepare-preview-builds": "./scripts/prepare-preview-builds.sh",
33-
"publish-previews": "yarn workspaces foreach --all --no-private --parallel --verbose run publish:preview",
3432
"start": "yarn workspaces foreach --all --parallel --verbose --interlaced run start",
3533
"test": "yarn workspace @metamask/stellar-wallet-snap run test",
3634
"test:integration": "yarn workspace @metamask/stellar-wallet-snap run test:integration"

packages/snap/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"lint:types": "tsc --noEmit",
3636
"format": "prettier '**/*.ts' '**/*.tsx' --write",
3737
"prepublishOnly": "mm-snap manifest",
38-
"publish:preview": "yarn npm publish --tag preview",
3938
"serve": "mm-snap serve",
4039
"start": "node scripts/update-manifest-local.js && concurrently \"mm-snap watch\" \"yarn build:locale:watch\"",
4140
"test": "jest --passWithNoTests --coverage=false",

scripts/generate-preview-build-message.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

scripts/prepare-preview-builds.jq

Lines changed: 0 additions & 9 deletions
This file was deleted.

scripts/prepare-preview-builds.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)