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 22 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 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
],
"version": "0.0.0-dev.0"
"packages": ["configs/*", "packages/*", "scripts/docker"],
"version": "independent"
Copy link
Contributor Author

@gagik gagik Dec 18, 2024

Choose a reason for hiding this comment

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

@addaleax I'm a bit unsure how to go about all this to the point where I can feel much confidence;
What I did here is

  1. remove lerna force publish
  2. use lerna independent mode
  3. add the bump script
    I feel like this should hypothetically do the trick. maybe a couple more changes might be all we need.

I tried i.e. running npm run bump-packages locally and I wonder if it is because of the fact that this PR itself technically changes all of the packages, we end up with a bunch of bumps; some reasonable others not so much.

I assume some of these packages we'd like to ignore right? And also some which we should keep at 0.0.0-dev.0 for our development?

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume some of these packages we'd like to ignore right? And also some which we should keep at 0.0.0-dev.0 for our development?

Well, the mongosh and @mongosh/cli-repl packages specifically should still be bumped as part of the process we have now, that can be by using the 0.0.0-dev.0 placeholders but I don't think that's a strict requirement here

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
],
"version": "0.0.0-dev.0"
"packages": ["configs/*", "packages/*", "scripts/docker"],
"version": "independent"
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume some of these packages we'd like to ignore right? And also some which we should keep at 0.0.0-dev.0 for our development?

Well, the mongosh and @mongosh/cli-repl packages specifically should still be bumped as part of the process we have now, that can be by using the 0.0.0-dev.0 placeholders but I don't think that's a strict requirement here

@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

@@ -31,7 +31,5 @@ npm run mark-ci-required-optional-dependencies
# along with its types, but npm wouldn't try and compile the addon
(npm ci && test -e node_modules/mongodb-client-encryption) || npm ci --ignore-scripts

npm run evergreen-release bump
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unless I am misunderstanding something, I don't think this bump was necessary to get the dir-based packages installed for the sake of i.e. tests, etc..
It does seem like that this acted as a preliminary step for different CI runs but the idea going forward is that the repository will have the latest published version and only get bumped before releases and persist for future runs

Copy link
Contributor Author

@gagik gagik Dec 31, 2024

Choose a reason for hiding this comment

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

I will double check this as I did see some weird error with browser-repl tests that may be caused by this

@gagik gagik marked this pull request as ready for review December 31, 2024 11:38
uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
id: app-token
with:
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be already set for us?

"preinstall": "node scripts/sort-workspaces.js"
"preinstall": "node scripts/sort-workspaces.js",
"bump-packages": "npm run bump-packages --workspace @mongosh/build",
"publish-packages": "lerna publish from-package --no-verify-access --no-push --no-git-tag-version --yes"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is 1:1 same as compass, I assume should be fine here also with our lerna setup, unless there's some special option we should pass for mongosh packages.

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
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

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