Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish packages with their current version (from package) #1648

Closed
joebowbeer opened this issue Sep 4, 2018 · 12 comments · Fixed by #1708, opencomponents/base-templates#370 or JetBrains/ring-ui#525

Comments

@joebowbeer
Copy link

joebowbeer commented Sep 4, 2018

See #1056 and #1610 for background.

I want to divide the publication process into 2 stages, similar to how it is done when publishing single npm packages in CI:

First I want to manually raise the package version on a branch:

lerna version [bump] --no-git-tag-version

Then, after PR approval and merge to master, I want to publish the bumped versions in CI:

lerna publish from-package

Here, from-package is a positional argument that publishes the versions that are already in the package.json files. I imagine the implementation would only attempt to publish versions that have not already been published.

@evocateur
Copy link
Member

I would prefer it to be a positional argument in the same pattern as lerna publish from-git:

lerna publish from-package

Otherwise, sounds fine to me.

@joebowbeer
Copy link
Author

@evocateur Thanks for the correction. I updated the description.

chriscasola added a commit to chriscasola/lerna that referenced this issue Oct 2, 2018
Publish un-published releases by reading versions from
the package.json files and publishing any that are not
already available in the registry.

Fixes lerna#1648
chriscasola added a commit to chriscasola/lerna that referenced this issue Oct 2, 2018
Publish un-published releases by reading versions from
the package.json files and publishing any that are not
already available in the registry.

Fixes lerna#1648
chriscasola added a commit to chriscasola/lerna that referenced this issue Oct 16, 2018
Publish un-published releases by reading versions from
the package.json files and publishing any that are not
already available in the registry.

Fixes lerna#1648
@StarpTech
Copy link

Hi, what's the state? Can I help?

@StarpTech
Copy link

StarpTech commented Nov 17, 2018

@evocateur @joebowbeer your workflow includes that the versions are tagged after publish right? Otherwise, I don't know how changes are detected correctly by Lerna.

@joebowbeer
Copy link
Author

@StarpTech In my workflow I use --no-git-tag-version (or that is effectively what is used because the CI account doesn't have write access to the git repo). The versions published to our private npm repo are the only versions important to us. Can lerna detect changes by comparing each package.json version against the latest version in the npm repo? I guess it is possible to enable git tag pushes from CI..

@StarpTech
Copy link

Hi @joebowbeer so I guess that you don't use tags at all right? My workflow should look like this:

  1. I want to manually raise the package version on a branch:

lerna version [bump] --no-git-tag-version

  1. After PR approval and merge to master, I want to publish the bumped versions in CI:

lerna publish from-package

  1. After successfully publish new tags are created for all unpublished packages. Without tags lerna isn't capable to check if a package was changed.

e.g

lerna exec -- ls or lerna bootstrap --since could run only in changed packages and its dependants. This will improve the performance.

@StarpTech
Copy link

StarpTech commented Nov 18, 2018

Here is a working prototype of the workflow. It includes the from-package feature with some fixes + the optional feature to tag the unpublished versions.
https://github.com/StarpTech/lerna/tree/feature/publish-from-package

It can achieve the following workflow:

  1. Separate version bump from tagging e.g if you want to build and publish on CI.
  2. Use versions from package.json for publishing and tagging

Example:

  1. (Locally) lerna version --no-git-tag-version
  2. (CI) lerna bootstrap --since --registry http://localhost:4873/
  3. (CI) lerna exec --since -- ls
  4. (CI) lerna publish from-package --yes --registry http://localhost:4873/ (you can disable creating tags by --no-git-tag-version)

@evocateur would you accept a PR?

@evocateur
Copy link
Member

I guess I was initially thinking of this as a "recover from broken publish after successful tagging/push" mode, not a way to free oneself from using git tags properly. I'm also not a huge fan of version changes being made in a PR (or feature branch), since that is not the right time to make those choices*.

  • When was the last time you accepted a PR to a "traditional" npm package that included a bump to the package.json version field?

@StarpTech
Copy link

StarpTech commented Nov 23, 2018

@evocateur I don't talk about the possibility to bump inside feature-branches. This could be done from the master or with conventional-commits. I would like to build and publish inside CI but also being flexible at the same time what version is changed. From my understanding lerna doesn't allow it. Most of the users of lerna build and publish locally which is in my opinion not ideal because we want to do it in a production like environment with high reproducibility (in other words CI/CD).

@joebowbeer
Copy link
Author

@evocateur we only/always publish traditional npm packages from CI, after pushing to master, using a builder account that does not have write access to git. (Furthermore, the master branch is protected from unreviewed pushes.)

Each PR is required to be up to date with the head of master, and must include the version bump.

chriscasola added a commit to chriscasola/lerna that referenced this issue Nov 28, 2018
Publish un-published releases by reading versions from
the package.json files and publishing any that are not
already available in the registry.

Fixes lerna#1648
@evocateur
Copy link
Member

Without git tags somewhere Lerna can't make decisions about what packages have changed. By using lerna publish from-package, you are essentially committing to always using the keyword, as no other arguments to lerna publish will make sense after breaking the git tag ceremony.

@lock
Copy link

lock bot commented Feb 27, 2019

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.