Prerequisites
This is a continuation of my previous article: Monorepo using Lerna, Conventional commits, and Github packages. The prereq...
For further actions, you may consider blocking this person and/or reporting abuse
thanks, great post! One comment though, I would look into replacing the custom token with
GITHUB_TOKEN
to follow best practices security wise. according to their docs"GitHub Packages allows you to push and pull packages through the GITHUB_TOKEN available to a GitHub Actions workflow."
docs.github.com/en/packages/managi...
Great suggestion Ben. I was doubtful about wether the
GITHUB_TOKEN
would allow authenticating against package registries and I see it does!What an awesome series, clarified lot of Lerna sticking points for me.
Questions-
1) lets say you keep add 3 merges to
development
without pulling tomain
so how does the versions work out?
a) after 1st merge (fix) in development 2.1.0-beta.0 --> 2.1.0-beta.1 ? or 2.1.1-beta.0?
b) assuming 2.1.1-beta.0, then 2nd merge (fix) in development 2.1.2-beta.0
c) then 3rd merge (fix) in development 2.1.3-beta.0
Now when we merge to
main
then it becomes 2.1.3? hence directly jumping from2.1.0 to 2.1.3 in
main
?Any good reading resources on semantic relases apart from the dry semVer doc??
2) Do you see if there is a need to changes fetch depth in the YAML - github.com/lerna/lerna/issues/2542
How can we add conventional commits for a git commit message which involves ay changes in 3 packages - pkg1, pkg2, pkg3 ?
Scenario
Previously,
pkg1 - 1.0.0
pkg1 - 1.0.0
pkg1 - 1.0.0
git commit -m "
feat(pkg1): added button color
fix(pkg2): fixed typo
fix(pkg3): fixed header
"
Now,
pkg1 - 1.1.0
pkg1 - 1.0.1
pkg1 - 1.0.1
Is that so? Also how to add breaking changes in the multiple package change commit where 1 of the packages have a breaking change, others do not.
Thanks!!!
Hi! I would commit the changes of each package separately (one commit for each package)
I'm facing this issue:
Any idea?
Had a query on the usage of the packages after they are published-
let's say
step1) changes merged to
dev
--> publishes --> 1.0.1-beta.0step2) the changes from
dev
are now merged tomain
--> publishes --> 1.0.1Now can an end user
install
both1.0.1-beta.0
&1.0.1
?Yes, they are published and available in the registry unless you delete them.
Thanks for post, great help! Question for me is how do you upgrade project version? After you merge to master, it removes
-beta
postfix, but how do you upgrade package version from2.1.0
further to2.1.0-beta.0
? And how can it determine if to change major, minor or patch number?Hi SFilisnky. Lerna parses the conventional commit history, which include of the scope change, to determine the major, minor or patch version (see conventional commits specification). For the -beta removal, it’s the other way around. Let’s say you are in 2.1.0 and you merge a patch PR against development. Then, Lerna will bump to 2.1.1-beta.0 and when merging against master it will remove the suffix, leaving the final 2.1.1 version. Does that make sense?
Thank you for the great post! Got everything working except one thing that is bugging me:
When using
--conventional-prerelease
, lerna creates the correct changelogs(with the correct commit history)but when I use
--conventional-graduate
, lerna only puts this into my changelog:Note: Version bump only for package
Also this only happens when running the command in github action, outside of it, it's fine!
Do you know why? Thanks!
Is this still a workable solution? I followed your steps but on the version/publish step I get the error:
EUNCOMMIT Working tree has uncommitted changes, please commit or remove the following changes before continuing:
because the version command has updated the package.json and is therefore not able to carry on.
Hi Some Edge Cases I wanted to discuss
So we have master and dev branch merging to dev branch npm ci works perfectly and versioning is performed and beta is applied. But now if you try to merge this branch into master your lockfile is outdated npm ci would throw error cant perform installing node_modules.
PS: using pnpm as package manager
This is a great post, thanks. When I create a new Pull Request from development against master (main), in my case, I end up with merge conflict. The issue is that the development branch has beta versions and the main has major versions. So there is a conflict everywhere the version is defined. This can't be the desired behavior but I can't see a way around it... Maybe I misunderstand something about the workflow? Any Ideas about where I am going wrong?
have you found a better branching approach to solve that problem?
Hi.
for me the packages doesn't appear on the repository, and other thing, how can I list the same packages on npmjs.com?