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

feat(publish): Add a "from-package" argument #1708

Merged
merged 5 commits into from Nov 29, 2018

Conversation

chriscasola
Copy link
Contributor

@chriscasola chriscasola commented 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 #1648

Description

This is an initial attempt at implementing lerna publish from-package. The "from-package" option will inspect each package.json and determine if the version has been published to the registry. If it hasn't it will publish it.

Motivation and Context

This change will allow users to prepare a release, review it and commit it, and then later publish it in CI.

The change will also make it much easier to attempt to publish again if some or all of the packages failed to publish to the registry in a prior run of lerna publish.

This may address #1648 and #1668

How Has This Been Tested?

Added unit tests.

Did the following on a test repo:

lerna version # committed and tagged
lerna publish from-package # published
lerna publish from-package # exit success, nothing to publish

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@chriscasola chriscasola changed the title WIP: feat(publish): Add a "from-git" argument WIP: feat(publish): Add a "from-package" argument Oct 2, 2018
@chriscasola chriscasola changed the title WIP: feat(publish): Add a "from-package" argument feat(publish): Add a "from-package" argument Oct 16, 2018
@chriscasola
Copy link
Contributor Author

I'm not sure why the CI job for window/node10 failed, but I think I finished everything that I had left WIP.

@mlavina
Copy link
Contributor

mlavina commented Nov 9, 2018

Hello @evocateur

Any chance you can take a look at this PR anytime soon?

My team is also running into similar issues and this PR would be super helpful. Currently, we are forced to basically roll back the git changes and remove git tags and what not on intermittent fails. This would definitely be super helpful for us.

Thank you,
Michael

@StarpTech
Copy link

@chriscasola it was an installation issue by travis itself. Could you retrigger the build?

@StarpTech
Copy link

@chriscasola rebase from master the .travis.yml was changed completly!

@StarpTech
Copy link

StarpTech commented Nov 16, 2018

Hi,
according to #1648 I expected that the new command lerna publish from-package will tag the versions after all packages were published. If you check #1648 we want to archieve following workflow:

  1. I want to manually or autoamtically (conventional comments) raise the package version on a branch:
lerna version [bump] --no-git-tag-version
  1. Then, after PR approval and merge to master, I want to publish the bumped versions in CI:
lerna publish from-package
  1. (Currently missing) The versions from the package.json are used to create new git-tags

  2. (Impossible when the version are tagged before CI) After the successfully publish lerna changed should return no changes.

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies for the delay, this is looking good so far! Would you mind switching to pacote for the packument fetching? (the add command uses the .manifest() method [here])

commands/publish/lib/get-unpublished-packages.js Outdated Show resolved Hide resolved
commands/publish/lib/get-unpublished-packages.js Outdated Show resolved Hide resolved
@evocateur
Copy link
Member

@StarpTech

(Currently missing) The versions from the package.json are used to create new git-tags

This would only apply in independent versioning mode, yes? In the default "fixed" versioning, the tag will already be present when a partial publish occurs.

@StarpTech
Copy link

StarpTech commented Nov 22, 2018

This would only apply in independent versioning mode, yes? In the default "fixed" versioning, the tag will already be present when a partial publish occurs.

@evocateur No in both because it doesn't create a git-tag in "fixed" mode in the current implementation. Please have a look at lerna-workflow to better understand the goals with #1648

The following fork https://github.com/StarpTech/lerna/tree/feature/publish-from-package will show you the idea.

@chriscasola
Copy link
Contributor Author

chriscasola commented Nov 28, 2018

@evocateur if the workflow described in #1648 is what we're trying to follow here, where would the git tags be created? lerna version is run with --no-git-tag-version.

I'm not sure it makes sense for lerna publish from-package to create the git tags. At least in my organization, our CI usually doesn't push back to our git repos, so ideally the tags would already exist and we'd just be publishing to the registry. I take that back, our CI does do the release and pushes the publish commit to the repo. So I think we'd want lerna publish from-package to create the git tag and publish to npm.

I updated this PR with your other feedback, thanks!

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@evocateur
Copy link
Member

I'm okay with not making the tags, it's overcomplicating the issue and teetering closer to patterns that I consider outside Lerna's scope.

@evocateur evocateur merged commit 16611be into lerna:master Nov 29, 2018
@chriscasola chriscasola deleted the feat/publish-from-package branch November 29, 2018 17:28
@Clarence-pan
Copy link

It's very useful. 👍
Does anyone know when will it be published to npm? And which version?

@lock
Copy link

lock bot commented Jan 29, 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 Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

publish packages with their current version (from package)
5 participants