lerna conventional versioning with github actions

1k Views Asked by At

I've setup the github actions to run on PRs against development and main. Then in the workflow I have a task as follow:

if [ ${{ github.base_ref }} = development ]; then
  npx lerna version --conventional-prerelease --preid beta --yes
else
  npx lerna version --conventional-graduate --yes
fi

Basically version a beta release, then publish development when a PR is against that branch while graduating the last beta release and publishing from main when PR is against main branch. This works great except when graduating a beta release, development maintains its last beta version while main bumps up to the graduated production version (e.g. development is 1.0.1-beta.0 while main is 1.0.1). There's also difference in the CHANGELOG.md content when graduating a beta version. This behavior causes main and development to get out of sync because the CHANGELOG.md and the production version in main never propagate into development branch. How do you fix this issue?

Idea

Merge main back into development after every beta graduation. This goes against the git flow.

Here's the lerna.json:

{
  "packages": [
    "packages/*"
  ],
  "version": "independent",
  "publishConfig": {
    "access": "public"
  },
  "command": {
    "publish": {
      "conventionalCommits": true,
      "verifyAccess": false,
      "commitHooks": false,
      "ignoreChanges": [
        "*.md",
        "*(\\.|-)test.ts"
      ],
      "version": {
        "message": "chore(release): version and release commit"
      }
    }
  }
}
0

There are 0 best solutions below