Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions .github/workflows/publish-preview-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Notify about new "Publish preview" workflow

on:
issue_comment:
types: created

permissions: {}

jobs:
notify:
name: Notify about new "Publish preview" workflow
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot publish-preview') }}
permissions:
pull-requests: write
environment: default-branch
runs-on: ubuntu-latest
steps:
- name: Notify
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const { owner, repo } = context.repo;
const workflowUrl = `https://github.com/${owner}/${repo}/actions/workflows/publish-preview.yml`;

const commentBody = [
'The "Publish preview" workflow has been updated to a new version that uses OIDC for authentication. Please use the new workflow instead of this one.',
'',
`To trigger the new workflow, go to the [Publish a preview build](${workflowUrl}) workflow, click "Run workflow", and enter \`${context.issue.number}\` as the pull request number.`,
].join('\n');

await github.rest.issues.createComment({
owner,
repo,
issue_number: context.issue.number,
body: commentBody,
});
45 changes: 38 additions & 7 deletions .github/workflows/publish-preview.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,54 @@
name: Publish a preview build

on:
issue_comment:
types: created
workflow_dispatch:
inputs:
pull-request:
description: 'Pull request number to publish a preview build for. Mutually exclusive with "branch".'
required: false
type: number
branch:
description: 'Branch in this repository to publish a preview build for. Mutually exclusive with "pull-request".'
required: false
type: string
default: ''
packages:
description: 'Comma-separated list of packages to publish, e.g., "@metamask/bitcoin-wallet-snap, tron-wallet-snap". Mutually exclusive with "only-changed-packages". Leave empty to publish all packages.'
required: false
type: string
default: ''
only-changed-packages:
description: 'Only publish packages changed compared to the base branch. Mutually exclusive with "packages".'
required: false
type: boolean
default: true
dry-run:
description: 'Perform a dry run.'
type: boolean
required: false
default: false

permissions:
contents: read
pull-requests: write

jobs:
publish-preview:
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot publish-preview') }}
uses: MetaMask/github-tools/.github/workflows/publish-preview.yml@88836cf1473f73a64848a809cf89e616ed6ed692 # v1.22.0
name: Publish preview
permissions:
contents: read
id-token: write
pull-requests: write
uses: MetaMask/github-tools/.github/workflows/publish-preview-oidc.yml@a4c45d2f30cf1d30b0ee43303bb8ea6441cb54c2 # v1.27.0
with:
pull-request: ${{ fromJSON(inputs.pull-request || '0') }}
branch: ${{ inputs.branch }}
packages: ${{ inputs.packages }}
only-changed-packages: ${{ inputs.only-changed-packages }}
dry-run: ${{ inputs.dry-run }}
rename-after-install-and-build: true
environment: default-branch
environment: npm-preview

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an intentional change. I will make sure the environment is configured before merging.

docs-url: 'https://github.com/MetaMask/internal-snaps/blob/main/docs/processes/preview-builds.md'
secrets:
PUBLISH_PREVIEW_NPM_TOKEN: ${{ secrets.PUBLISH_PREVIEW_NPM_TOKEN }}
BUILD_ENV: |
{
"LOG_LEVEL": "error",
Expand Down
4 changes: 2 additions & 2 deletions docs/processes/preview-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Generally, when working with preview builds, you will follow this process:
To publish preview builds:

1. Create a pull request with the changes to your package(s).
2. Post a comment on the pull request with the text `@metamaskbot publish-preview`. The `publish-preview` GitHub action will kick off to generate and publish preview builds for all packages in the monorepo.
3. After a few minutes, you will see a new comment that lists the newly published packages along with their versions.
2. Go to the [Publish a preview build](https://github.com/MetaMask/internal-snaps/actions/workflows/publish-preview.yml) workflow, click "Run workflow", and enter the pull request number (or a branch name). By default, only packages changed compared to the base branch are published; you can instead provide a list of packages to publish.
3. After a few minutes, you will see a new comment on the pull request that lists the newly published packages along with their versions.

This workflow is available to members of the MetaMask engineering team on GitHub. Independent contributors should use [local builds](./local-builds.md) instead.

Expand Down