-
Notifications
You must be signed in to change notification settings - Fork 70
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(changelog-generator): make --version optional when --dry-run is on #116
Conversation
This makes the workflow described in: #87 (comment) a bit easier. Namely, when you are about to cut a release, and you want to preview what will go into the changelog and use that to guide your decision about whether to make this a `--patch`, `--minor` or `--major` (etc) release, you can just run the generator with the `--dry-run` switch, ignoring the usual requirement to pass a `--version`. Test plan: 1. Try running the generator without a `--version` and see it complain: ``` changelog-generator ❯ bin/liferay-changelog-generator.js error: Missing required option: --version; see --help for usage zsh: exit 1 bin/liferay-changelog-generator.js ``` 2. Repeat the test, this time with `--dry-run`, and see this: ``` changelog-generator ❯ bin/liferay-changelog-generator.js --dry-run Using phony version changelog-generator/v0.0.0-placeholder during --dry-run ____________________ (_) ` | | | changelog.js | | ============ | | | | Reporting | | for duty! | | | |__________________| (_)_________________) Fetching remote tags: run with --no-update-tags to skip ## [changelog-generator/v0.0.0-placeholder](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v0.0.0-placeholder) (2020-10-05) [Full changelog](changelog-generator/v1.5.0...changelog-generator/v0.0.0-placeholder) ### 📖 Documentation - docs(changelog-generator): update project links ([\#94](#94)) [--dry-run] Would write ./CHANGELOG.md 6943 bytes ✨ ```
So that in the `--dry-run` without `--version` use case, you won't see the "phony version" message before the banner: ``` Using phony version changelog-generator/v0.0.0-placeholder during --dry-run ____________________ (_) ` | | | changelog.js | | ============ | | | | Reporting | | for duty! | | | |__________________| (_)_________________) Fetching remote tags: run with --no-update-tags to skip ``` Note that this does mean that we're showing the banner in some situations where we didn't show it before, but I think that's ok. Example: ``` changelog-generator ❯ bin/liferay-changelog-generator.js --invalid-option ____________________ (_) ` | | | changelog.js | | ============ | | | | Reporting | | for duty! | | | |__________________| (_)_________________) error: Unrecognized argument --invalid-option; see --help for available options error: Missing required option: --version; see --help for usage zsh: exit 1 bin/liferay-changelog-generator.js --invalid-option ```
This reminded me that I read something about GitHub supporting 2FA tokens now so that one could do automated releases... but can't find the sources now 🤔 |
We used to do that at FB for some packages (basically, pushing a tag would cause Travis to actually cut the release if CI passed), but not for all of them. I get a bit scared of totally automated things like that though; I like to reduce the friction as close as possible to zero, but not actually remove it entirely. |
Yeah, I know you're all about "friction is needed to light a fire" 😂 |
Well I am going to take those two comments as a resounding endorsement and merge this. |
This is still a bit rough (would like to follow up with a refactor commit), but it implements a basic `--interactive` mode which replaces this flow: npx @liferay/changelog-generator --dry-run # preview changes, decide on release type npx @liferay/changelog-generator --patch # actually generate changes git add -p # stage changes yarn version --patch # do release with this: npx @liferay/changelog-generator --interactive yarn version --patch It's a big ugly inside, but effectively we have a little state machine that goes through this cycle: 1. Run like `--dry-run`, and show a preview of what would be changed. 2. Prompt user for a version number (can be "major" etc or an explicit number). 3. Actually write out changes with the version number in effect. 4. Show `git diff` output and offer to `git add`. Test plan: Here's a demo of the basic "happy path" (obviously monochrome, but it's colorized in real life). I tested a few variants along the way and it seems to work for everything that I threw at it. $ node bin/liferay-changelog-generator.js --interactive ____________________________________ (_) ` | | | @liferay/changelog-generator | | ============================ | | | | Reporting for duty! | | | |__________________________________| (_)_________________________________) [--interactive] Using phony version changelog-generator/v0.0.0-placeholder.0 Fetching remote tags: run with --no-update-tags to skip [--interactive] Preview of changes 👀 ## [changelog-generator/v0.0.0-placeholder.0](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v0.0.0-placeholder.0) (2020-10-16) [Full changelog](changelog-generator/v1.5.0...changelog-generator/v0.0.0-placeholder.0) ### 🆕 Features - feat(monorepo): use liferay-npm-scripts for formatting ([\#146](#146)) - feat(changelog-generator): make --version optional when --dry-run is on ([\#116](#116)) ### 📖 Documentation - docs(changelog-generator): update project links ([\#94](#94)) ### 🤹♀️ Refactoring - refactor(js-toolkit): make tests work in monorepo ([\#133](#133)) [--interactive] Would write ./CHANGELOG.md 7413 bytes ✨ 1. major 2. minor 3. patch 4. premajor 5. preminor 6. prepatch 7. prerelease Please choose a version from the list, or provide one in full (or enter to abort): 2 Wrote ./CHANGELOG.md 7371 bytes ✨ [--interactive] git-diff preview 👀 diff --git a/projects/npm-tools/packages/changelog-generator/CHANGELOG.md b/projects/npm-tools/packages/changelog-generator/CHANGELOG.md index fdf781a4..2ccfe5fa 100644 --- a/projects/npm-tools/packages/changelog-generator/CHANGELOG.md +++ b/projects/npm-tools/packages/changelog-generator/CHANGELOG.md @@ -1,3 +1,20 @@ +## [changelog-generator/v1.6.0](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v1.6.0) (2020-10-16) + +[Full changelog](changelog-generator/v1.5.0...changelog-generator/v1.6.0) + +### 🆕 Features + +- feat(monorepo): use liferay-npm-scripts for formatting ([\#146](#146)) +- feat(changelog-generator): make --version optional when --dry-run is on ([\#116](#116)) + +### 📖 Documentation + +- docs(changelog-generator): update project links ([\#94](#94)) + +### 🤹♀️ Refactoring + +- refactor(js-toolkit): make tests work in monorepo ([\#133](#133)) + ## [changelog-generator/v1.5.0](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v1.5.0) (2020-09-29) [Full changelog](changelog-generator/v1.4.1...changelog-generator/v1.5.0) Would you like to stage these changes? (y/n) y $ git status On branch wincent/version-shortcuts Your branch is ahead of 'master' by 6 commits. (use "git push" to publish your local commits) Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: CHANGELOG.md
This is still a bit rough (would like to follow up with a refactor commit), but it implements a basic `--interactive` mode which replaces this flow: npx @liferay/changelog-generator --dry-run # preview changes, decide on release type npx @liferay/changelog-generator --patch # actually generate changes git add -p # stage changes yarn version --patch # do release with this: npx @liferay/changelog-generator --interactive yarn version --patch It's a big ugly inside, but effectively we have a little state machine that goes through this cycle: 1. Run like `--dry-run`, and show a preview of what would be changed. 2. Prompt user for a version number (can be "major" etc or an explicit number). 3. Actually write out changes with the version number in effect. 4. Show `git diff` output and offer to `git add`. Test plan: Here's a demo of the basic "happy path" (obviously monochrome, but it's colorized in real life). I tested a few variants along the way and it seems to work for everything that I threw at it. $ node bin/liferay-changelog-generator.js --interactive ____________________________________ (_) ` | | | @liferay/changelog-generator | | ============================ | | | | Reporting for duty! | | | |__________________________________| (_)_________________________________) [--interactive] Using phony version changelog-generator/v0.0.0-placeholder.0 Fetching remote tags: run with --no-update-tags to skip [--interactive] Preview of changes 👀 ## [changelog-generator/v0.0.0-placeholder.0](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v0.0.0-placeholder.0) (2020-10-16) [Full changelog](changelog-generator/v1.5.0...changelog-generator/v0.0.0-placeholder.0) ### 🆕 Features - feat(monorepo): use liferay-npm-scripts for formatting ([\#146](#146)) - feat(changelog-generator): make --version optional when --dry-run is on ([\#116](#116)) ### 📖 Documentation - docs(changelog-generator): update project links ([\#94](#94)) ### 🤹♀️ Refactoring - refactor(js-toolkit): make tests work in monorepo ([\#133](#133)) [--interactive] Would write ./CHANGELOG.md 7413 bytes ✨ 1. major 2. minor 3. patch 4. premajor 5. preminor 6. prepatch 7. prerelease Please choose a version from the list, or provide one in full (or enter to abort): 2 Wrote ./CHANGELOG.md 7371 bytes ✨ [--interactive] git-diff preview 👀 diff --git a/projects/npm-tools/packages/changelog-generator/CHANGELOG.md b/projects/npm-tools/packages/changelog-generator/CHANGELOG.md index fdf781a4..2ccfe5fa 100644 --- a/projects/npm-tools/packages/changelog-generator/CHANGELOG.md +++ b/projects/npm-tools/packages/changelog-generator/CHANGELOG.md @@ -1,3 +1,20 @@ +## [changelog-generator/v1.6.0](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v1.6.0) (2020-10-16) + +[Full changelog](changelog-generator/v1.5.0...changelog-generator/v1.6.0) + +### 🆕 Features + +- feat(monorepo): use liferay-npm-scripts for formatting ([\#146](#146)) +- feat(changelog-generator): make --version optional when --dry-run is on ([\#116](#116)) + +### 📖 Documentation + +- docs(changelog-generator): update project links ([\#94](#94)) + +### 🤹♀️ Refactoring + +- refactor(js-toolkit): make tests work in monorepo ([\#133](#133)) + ## [changelog-generator/v1.5.0](/~https://github.com/liferay/liferay-frontend-projects/tree/changelog-generator/v1.5.0) (2020-09-29) [Full changelog](changelog-generator/v1.4.1...changelog-generator/v1.5.0) Would you like to stage these changes? (y/n) y $ git status On branch wincent/version-shortcuts Your branch is ahead of 'master' by 6 commits. (use "git push" to publish your local commits) Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: CHANGELOG.md
docs: clarify advice on commit messages
This makes the workflow described in this comment a bit easier.
Namely, when you are about to cut a release, and you want to preview what will go into the changelog and use that to guide your decision about whether to make this a
--patch
,--minor
or--major
(etc) release, you can just run the generator with the--dry-run
switch, ignoring the usual requirement to pass a--version
.Test plan:
Try running the generator without a
--version
and see it complain:Repeat the test, this time with
--dry-run
, and see this: