lerna / lerna/lerna

Version/publish based on tags only?

Open
#2,337 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
Dominant language
TypeScript
Stars
36.1k
Forks
2.3k
Avg merge
1d 4h
Merged PRs (30d)
50

Description

It'd be nice to have the option to make the lerna version command not edit my source code at all. Instead, it could do something similar to semantic-release by managing versions purely based on git tags. Similarly, changelogs could be replaced by Github releases (or equivalents on other platforms).

Expected Behavior

lerna version from-tags

This would:

  • find the git hashes for the most recent tag in semver format for each package (pkg-a:1.2.3, pkg-b:4.5.6)
  • use lerna changed or similar to find the commits affecting each package since then
  • calculate the new version for each package based on semver, following dependencies etc. just like lerna version does now
  • push tags with the new version for all updated packages without updating source code or pushing any commits

At that point, I think lerna publish from-git would pick up all the new tags and publish them. If not, maybe there would need to be some kind of a lerna publish from-tags too.

Current Behavior

Right now lerna modifies the source code, which can complicate CI. Either the number of commits to master effectively double, with half of them being version bumps; or we can use the --amend option which I think risk weird git merge conflicts. Presumably using that flag from CI involves force-pushing to master, which it'd be great to be able to avoid. Both of those options could be troublesome if two people commit to master faster than CI can complete.

Possible Solution

I haven't dived into the source code of @lerna/version yet, but based on my understanding on what it does, my hope is it wouldn't be too hard. The tagging and commit parsing is already there, but with a different method for fetching the "current version" of each package (checking tags rather than parsing package.json).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the @lerna/version implementation and its existing tagging and commit-parsing behavior, then compare how lerna changed and lerna publish from-git identify package updates. Done means a version workflow can derive package versions from semver tags, create new tags, and avoid modifying source files or pushing version-bump commits.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
release
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.