Lerna sync with latest version from registry

We have a monorepo setup (using lerna) to handle multiple packages. Now when some updates are made to certain packages, the version number are bumped up and published via a jenkins job that also commits back the updated version no. to the branch that was used to run the jenkins build with.

The issue we’re currently facing is that when a new version is published from a certain branch say “feature/A”, it would update the version of that same package from 1.0.0 to 1.0.1 in this branch. But all the other branches are still at version 1.0.0, and if a user B with branch “feature/B” tries to run a the same publish jenkins job, they see an error stating that version 1.0.1 already exists and so the publish fails.

So we’re looking for a way that allows the user to run a local script or lerna command on their branch “feature/B” locally that pulls the latest version from registry and updates the version in local their to 1.0.1, so that when user B pushes this code and runs the publish job, he is able to publish 1.0.2 successfully.
An equally helpful solution would be if somehow we can ask lerna to skip already existing package version nos and just publish the next version no. i.e skip for 1.0.1 and directly go to publish 1.0.2.

Similar question to – How to manage canary version bump in monorepo with lerna from different branches

We are currently manually updating the package version nos locally when we encounter this issue which isn’t ideal and we would like to automate this.