Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Update to Lerna v3 and switch to a 2-stage release process #1325

Merged
merged 3 commits into from
Mar 17, 2019
Merged

Update to Lerna v3 and switch to a 2-stage release process #1325

merged 3 commits into from
Mar 17, 2019

Conversation

edmorley
Copy link
Member

Releases will now occur in two phases, with the first being code-only changes that can be reviewed in a PR, followed by the tagging/publishing phase once it's merged.

Fixes #639.
Closes #1311.

@edmorley edmorley self-assigned this Mar 15, 2019
@edmorley
Copy link
Member Author

@edmorley edmorley requested a review from eliperelman March 15, 2019 21:47
Copy link
Member

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

Finally! This was so needed. I added a couple comments to see if they could make things a little easier.

## Releasing a new version

1. Decide whether the new version should be a major/minor/patch/prerelease version bump.
2. From the root of the Neutrino repository, run: `git checkout -b version-bump master`
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this git checkout -b version-bump upstream/master to ensure we are using this from upstream or does that not matter? Also should we pair this with:

git fetch upstream --quiet && git checkout -b version-bump upstream/master

to ensure master is up to date?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea :-)


If bumping to a new major version, or incrementing the pre-release version,
you will want to manually increase the presets' version of `neutrino` in
`peerDependencies`.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could also add a note here on how to make this easier via sed? This is the command I use on macOS:

sed -i '' -- 's/"neutrino": "^9.0.0-0"/"neutrino": "^9.0.0-rc.0"/g' packages/*/package.json(D.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah good idea. The example sed command in your comment didn't work for me, however this did:
sed -i 's/"neutrino": "^9.0.0-0"/"neutrino": "^9.0.0-rc.0"/g' packages/*/package.json

It might be worth testing that on your machine to check the OS X sed (which iirc is a little quirky) handles that form ok (or whether it needs an additional -e before the script command).

package.json Outdated
"release:prepare": "lerna version",
"release:publish": "lerna publish from-package",
"release:publish-next": "yarn release:publish --dist-tag next",
"release:ci": "lerna publish prerelease --registry http://localhost:4873 --no-git-reset --yes",
Copy link
Member

Choose a reason for hiding this comment

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

I don't see prerelease as a valid positional for the lerna publish command, am I missing something?

https://github.com/lerna/lerna/tree/master/commands/publish#positionals

Copy link
Member

Choose a reason for hiding this comment

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

It also appears that SKIP_CHANGELOG isn't being respected:

https://travis-ci.org/neutrinojs/neutrino/jobs/506989820#L606

Copy link
Member

Choose a reason for hiding this comment

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

I think updating the version script to the following should work:

[ -z $SKIP_CHANGELOG ] || yarn changelog --package && git add CHANGELOG.md

Copy link
Member Author

@edmorley edmorley Mar 17, 2019

Choose a reason for hiding this comment

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

I don't see prerelease as a valid positional for the lerna publish command, am I missing something?

The lerna publish command is a superset of lerna version, so supports the options lerna version supports:
https://github.com/lerna/lerna/tree/master/commands/version#semver-bump

I'd originally wanted to have the yarn release:ci command follow the actual release process as closely as possible - ie: make it do something like:
yarn release:prepare prerelease --yes && yarn release:publish --registry http://localhost:4873 --yes

However it turns out when lerna publish is run using either of the from-git or from-package options, lerna insists that the working directory is clean, which it won't be in CI, since we deliberately miss out the Commit the changes using: `git commit -a -m 'vN.N.N' step that is performed during a real release.

As such, I avoided this by making yarn release:ci perform the publish in one step, by running lerna publish in "do all steps" mode (ie: by specifying a version bump, rather than from-git or from-package).

It also appears that SKIP_CHANGELOG isn't being respected:

Yeah I saw that locally on Windows too. Yarn must not propagate the modified env for sub-commands, strange.

package.json Outdated
"release:prepare": "lerna version",
"release:publish": "lerna publish from-package",
"release:publish-next": "yarn release:publish --dist-tag next",
"release:ci": "lerna publish prerelease --registry http://localhost:4873 --no-git-reset --yes",
Copy link
Member

@eliperelman eliperelman Mar 16, 2019

Choose a reason for hiding this comment

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

Suggested change
"release:ci": "lerna publish prerelease --registry http://localhost:4873 --no-git-reset --yes",
"release:ci": "SKIP_CHANGELOG=true lerna publish from-package --registry http://localhost:4873 --no-git-reset --yes --canary prerelease",

Copy link
Member Author

@edmorley edmorley Mar 17, 2019

Choose a reason for hiding this comment

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

Re this suggested change - moving the SKIP_CHANGELOG here is a good idea, however the from-package option conflicts with the other options passed, so doesn't make sense in this context. See:
https://github.com/lerna/lerna/blob/a7ad9b60d27b390fde21fd2837f2d97320c4603e/commands/publish/index.js#L135-L143

Re --canary, we used to use that, however it used to append the Git SHA to the version in a way that created a semver-spec-violating version string if the Git SHA happened to have a leading zero (which caused errors in Verdaccio), so stopped doing so. However it looks like that was fixed in lerna v3 (lerna/lerna/issues/1118), so we can switch back to using it :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

However it looks like that was fixed in lerna v3 (lerna/lerna/issues/1118), so we can switch back to using it :-)

Ah --canary ignores the Neutrino version in lerna.json and instead tries to base it on the Git tags, which (a) doesn't work well on Travis (see https://travis-ci.org/neutrinojs/neutrino/jobs/507436675#L564), (b) means it uses a v8.x.x version rather than v9.x.x, since we don't yet have any Neutrino v9 Git tags.

Given we're not actually the packages in canary form, we don't benefit much from --canary, so I've just switched this back to how it was before.

@eliperelman
Copy link
Member

I tested out this PR in Travis with: #1327 and it appears to be working with my suggestions.

@edmorley edmorley requested a review from eliperelman March 17, 2019 11:04
Copy link
Member

@eliperelman eliperelman left a comment

Choose a reason for hiding this comment

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

LGTM!

Releases will now occur in two phases, with the first being code-only
changes that can be reviewed in a PR, followed by the tagging/publishing
phase once it's merged.

Fixes #639.
Closes #1311.
Since it relies on git tags, which doesn't work well on Travis, plus
means it tries to using a v8.x.x version number rather than v9.x.x, since
there are no git tags for v9 yet. When `--canary` isn't used, the new
version will instead be based on that in `lerna.json` which works fine.
@edmorley edmorley merged commit 83689e5 into neutrinojs:master Mar 17, 2019
@edmorley edmorley deleted the lerna3 branch March 17, 2019 17:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

2 participants