Monorepo publishing with lerna and a deploy bot

Viewed 4098

Here's the scenario:

We want a monorepo for several components and would like to use lerna with yarn workspaces for it.

To ensure no problems happen with semantic versioning, it would be nice to have code reviews for the version numbers as well. So the package.json defines a version-bump script that shall only be used to increment package versions.

After the tests running and CR being OK, we'd like a deploy bot to publish the packages to our custom registry for us. For this it would be nice to use lerna publish --skip-git, so that lerna would publish the changed packages only.

The problem here is that lerna publish won't just publish the packages, but asks for their version increments again. It would be nice to know of an option or workaround to publish without incrementing the version.

Our current workaround is to use lerna exec npm publish, but this will try to publish already published packages again. We also cannot use lerna exec yarn publish because in that case yarn asks for version increments.

The setup looks like this:

lerna.json:

{
  "lerna": "2.5.1",
  "version": "independent",
  "npmClient": "yarn",
  "useWorkspaces": true,
  "packages": [
    "packages/*"
  ]
}

package.json

{
  "name": "…",
  "version": "0.0.0",
  "description": "…",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "…"
  },
  "workspaces": [
    "packages/*"
  ],
  "private": true,
  "scripts": {
    "version-bump": "./node_modules/lerna/bin/lerna.js publish --skip-npm",
    "test": "echo well tested"
  },
  "devDependencies": {
    "lerna": "^2.5.1"
  }
}
2 Answers
Related