Skip to content
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

chore(ci): add individual publishing of packages MONGOSH-1871 #2289

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Dec 10, 2024

This adds the ability to individually publish packages in mongosh. Also, notably, all packages's version inside package.json will now match the latest released version and update accordingly upon release.

Structure

Package Bumping

With this change, there are 2 types of package bumping depending on what package it is:

  1. mongosh release-related packages bump
    mongosh and @mongosh/cli-repl are bumped only at mongosh release and have their versions synced.
    This gets triggered only during a mongosh release.
  2. npm auxiliary packages bump
    All other packages are bumped independently of mongosh using bump-packages from monorepo-tools. Each package can have divergent versions as a result.
    This can be triggered anytime using GitHub actions which will create PR for bump package versions, merging of which will cause CI to publish the packages.

Individual Package Release

You can release an individual package by running a bump packages GitHub Action and merging the created PR.

mongosh Release

A mongosh release will cause both an npm package bump and a mongosh release bump before starting the release.

@gagik gagik force-pushed the gagik/individual-publishing branch from 879eb0f to 40d6e71 Compare December 10, 2024 11:17
@gagik gagik force-pushed the gagik/individual-publishing branch from f48cc5c to a2f246b Compare December 18, 2024 12:05
lerna.json Show resolved Hide resolved
lerna.json Show resolved Hide resolved
packages/snippet-manager/package.json Show resolved Hide resolved
packages/build/src/npm-packages/publish.ts Show resolved Hide resolved
packages/build/src/release.ts Show resolved Hide resolved
lerna.json Show resolved Hide resolved
@gagik gagik force-pushed the gagik/individual-publishing branch from 8c9c214 to 41bc10a Compare December 20, 2024 14:55
@gagik
Copy link
Contributor Author

gagik commented Dec 20, 2024

@addaleax Didn't get to spend too much time on this before my holiday with some VSCode and coverage test back and forths. Would be happy to jump back into it in a week but if it'd be better to finish this earlier, feel free to pick it up 🙂 I have some WIP files that I may polish up and push at a later time also though not sure how useful they are; will see.

@gagik gagik force-pushed the gagik/individual-publishing branch from 41bc10a to ad630dc Compare December 30, 2024 11:48
@gagik gagik changed the title WIP: individual publishing of packages chore(ci): add individual publishing of packages MONGOSH-1871 Dec 31, 2024
@@ -917,6 +917,9 @@ functions:
{
export NODE_JS_VERSION=${node_js_version}
source .evergreen/setup-env.sh
npm run evergreen-release bump
git add .
git commit --no-allow-empty -m "chore(release): bump to prepare for mongosh release"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea here is that this will bump both "independent" and mongosh packages before the release draft and push it to main, so our branch is consistent with what we're releasing.
It might also make sense to only persist this after the release is published.

I am assuming this should work? Though not sure if the evergreen git setup has ability to push to main like this?

export const MONGOSH_RELEASE_PACKAGES = ['mongosh', '@mongosh/cli-repl'];

/** Packages which always get ignored when doing a release or bump */
export const IGNORE_BUMP_PACKAGES = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignoring these since these are private, unless it'd make sense to publish anyways?

@@ -1,6 +1,6 @@
{
"name": "@mongosh/arg-parser",
"version": "0.0.0-dev.0",
"version": "2.3.7",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were all set to 2.3.7 manually to get the current repository consistent with the latest release

@gagik gagik marked this pull request as ready for review December 31, 2024 11:38
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

I know this is modeled after what we already have and I'm not opposed to merging it as-is. That being said, I'd prefer if we move to a different publishing model, where we run the publish packages workflow on the bump packages PR, merge that PR, and only then tag the versions on main. That way we would eliminate a case where we have versions committed in main that haven't been published due to a glitch somewhere.

Additionally, we should move the npm token to an environment secret, which will require approvals for the workflow to run.

.github/workflows/bump-packages.yml Outdated Show resolved Hide resolved
.github/workflows/release-packages.yml Outdated Show resolved Hide resolved
.github/workflows/release-packages.yml Outdated Show resolved Hide resolved
gagik and others added 2 commits December 31, 2024 13:18
@gagik
Copy link
Contributor Author

gagik commented Dec 31, 2024

@nirinchev Agree, wanted to ask before expanding the scope but I think it'd be a lot nicer and cleaner with this setup. I can clean that up and the documentation

@gagik gagik force-pushed the gagik/individual-publishing branch from 9d0bd42 to 4086802 Compare January 6, 2025 13:31
@gagik gagik force-pushed the gagik/individual-publishing branch 2 times, most recently from 1561be9 to 3c557da Compare January 6, 2025 13:41
@gagik gagik force-pushed the gagik/individual-publishing branch from 3c557da to 68e3e62 Compare January 6, 2025 14:04
.github/workflows/publish-auxiliary-packages.yml Outdated Show resolved Hide resolved
.github/workflows/publish-auxiliary-packages.yml Outdated Show resolved Hide resolved
packages/build/src/config/config.ts Outdated Show resolved Hide resolved
packages/build/src/npm-packages/publish.ts Show resolved Hide resolved
packages/build/src/npm-packages/publish.ts Show resolved Hide resolved
packages/build/src/npm-packages/bump.ts Outdated Show resolved Hide resolved
`Refusing to publish packages with multiple versions: ${versions}`
if (isAuxiliaryOnly) {
packages = packages.filter(
(packageConfig) => !MONGOSH_RELEASE_PACKAGES.includes(packageConfig.name)
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double-checking, on a mongosh release we're still publishing the full list of packages, right?

How does this interact with the GH action scripts for publishing independent packages? Do we just need to be careful not to trigger them while a release is pending?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I suppose that would be problematic if both happened at the same time. Perhaps if we move this to GitHub Actions we could also enforce that a Release action doesn't start if there's another Release aux. packages etc. one is running

@@ -1,6 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know where we need to to leave this comment, so I'll leave it here – in shell-api.ts, we fetch the current mongosh version via require('../package.json').version. We should replace that with a new method on EvaluationListener that we then call from there, so that the mongosh CLI can provide the correct version to the shell-api package (and probably also add an e2e test that mongosh --eval 'version()' and mongosh --version print the same output).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants