Publish preview builds to NPM instead of GitHub#1622
Conversation
|
@metamaskbot publish-preview |
6 similar comments
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
f75235e to
e2b730a
Compare
| done < <(yarn workspaces list --no-private --json | jq --slurp --raw-output 'map(select(.location != ".")) | map([.location, .name]) | map(@tsv) | .[]') | ||
|
|
||
| echo "Installing dependencies..." | ||
| yarn install --no-immutable |
There was a problem hiding this comment.
Yarn will use --immutable by default when it detects it's being run in a CI environment. We have to turn this off because we have to regenerate the lockfile (since we are changing the names of packages etc.). If we don't do this then we won't be able to run any Yarn commands following this script.
package.json
Outdated
| "prepack": "./scripts/prepack.sh", | ||
| "prepare-preview-builds": "yarn workspaces foreach --parallel run prepare-manifest:preview", | ||
| "publish-previews": "yarn workspaces foreach --parallel run publish:preview", | ||
| "prepare-preview-builds": "scripts/prepare-preview-builds.sh", |
There was a problem hiding this comment.
We let the script take care of applying changes across the monorepo instead of adding a script to each package and using yarn workspaces foreach. We do this because once we change a manifest we have to run yarn install in order to run another Yarn command. yarn workspaces foreach is not intelligent; it's more or less a shortcut for:
for each workspace in the monorepo
yarn <whatever command you want to run>
end
And so if we use yarn workspaces foreach, the first package in the list of workspaces will get updated but none of the other packages will get updated because Yarn will fail.
Currently, when publishing core packages, we use NPM for "production" releases but GitHub Package Registry for "preview" builds. This works to keep the list of production versions free of clutter and mitigate the risk of publishing preview builds as production releases accidentally, but it also introduces a major pain point. Usually in order to access a package with a preview build, the developer must instruct Yarn to use GitHub Package Registry instead of NPM along with an authentication token, and then update the version of the package in the manifest to use the preview version. If, however, the package introduces a new transitive dependency that is not available in preview form, the developer must undo the changes to the Yarn configuration or even temporarily add the dependency explicitly to the project in order to fully install it. In some cases, these steps don't work at all. To remove this pain point, this commit changes how preview builds are published so that instead of using a separate registry, we use a separate NPM scope. This preserves the separation between preview builds and non-preview builds, and it means that the developer can mix non-preview and preview versions in the manifest without needing to reconfigure Yarn.
e2b730a to
9cd5809
Compare
|
We'll need to update |
|
Looks great! Once the docs are updated I think it will be ready |
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Currently, when publishing core packages, we use NPM for "production" releases but GitHub Package Registry for "preview" builds. This works to keep the list of production versions free of clutter and mitigate the risk of publishing preview builds as production releases accidentally, but it also introduces a major pain point. Usually in order to access a package with a preview build, the developer must instruct Yarn to use GitHub Package Registry instead of NPM along with an authentication token, and then update the version of the package in the manifest to use the preview version. If, however, the package introduces a new transitive dependency that is not available in preview form, the developer must undo the changes to the Yarn configuration or even temporarily add the dependency explicitly to the project in order to fully install it. In some cases, these steps don't work at all. To remove this pain point, this commit changes how preview builds are published so that instead of using a separate registry, we use a separate NPM scope. This preserves the separation between preview builds and non-preview builds, and it means that the developer can mix non-preview and preview versions in the manifest without needing to reconfigure Yarn. Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Currently, when publishing core packages, we use NPM for "production" releases but GitHub Package Registry for "preview" builds. This works to keep the list of production versions free of clutter and mitigate the risk of publishing preview builds as production releases accidentally, but it also introduces a major pain point. Usually in order to access a package with a preview build, the developer must instruct Yarn to use GitHub Package Registry instead of NPM along with an authentication token, and then update the version of the package in the manifest to use the preview version. If, however, the package introduces a new transitive dependency that is not available in preview form, the developer must undo the changes to the Yarn configuration or even temporarily add the dependency explicitly to the project in order to fully install it. In some cases, these steps don't work at all. To remove this pain point, this commit changes how preview builds are published so that instead of using a separate registry, we use a separate NPM scope. This preserves the separation between preview builds and non-preview builds, and it means that the developer can mix non-preview and preview versions in the manifest without needing to reconfigure Yarn. Co-authored-by: Mark Stacey <markjstacey@gmail.com>
## **Description** CI has a step where it sets up an alternative registry for `@metamask`- scoped packages specifically for draft PRs. This was intended to support the older stype of `MetaMask/core` preview builds, which used an alternative npm registry. Preview builds today now use the normal npm registry, so this step is no longer needed. ## **Related issues** Originally added here: #5270 Some related changes here: #5807 (these were already removed) The old preview build method was replaced here: MetaMask/core#1622 ## **Manual testing steps** N/A ## **Screenshots/Recordings** N/A ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
Explanation
Currently, when publishing core packages, we use NPM for "production" releases but GitHub Package Registry for "preview" builds. This works to keep the list of production versions free of clutter and mitigate the risk of publishing preview builds as production releases accidentally, but it also introduces a major pain point.
Usually in order to access a package with a preview build, the developer must instruct Yarn to use GitHub Package Registry instead of NPM along with an authentication token, and then update the version of the package in the manifest to use the preview version. If, however, the package introduces a new transitive dependency that is not available in preview form, the developer must undo the changes to the Yarn configuration or even temporarily add the dependency explicitly to the project in order to fully install it. In some cases, these steps don't work at all.
To remove this pain point, this commit changes how preview builds are published so that instead of using a separate registry, we use a separate NPM scope. This preserves the separation between preview builds and non-preview builds, and it means that the developer can mix non-preview and preview versions in the manifest without needing to reconfigure Yarn.
References
Fixes #1075.
Fixes #1585.
Changelog
(No consumer-facing changes)
Checklist