woocommerce/plugins/woocommerce-blocks/bin/changelog
Darren Ethier db14accc64 Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655)
This pull:

- removes zenhub option from package.json
- installs and implement `merge-config` package. This allows for usage of environment variables and command line variables along with `package.json` configuration for the changelog generation.
- implements new variable: `devNoteLabel` for indicating what label indicates the pull has (or requires) a devnote. Pull Requests with this label will have `[DN]` appended to the changelog entry.
- adds new variable: `changelogSrcType` for indicating what source to use for generating changelogs (can be `MILESTONE` or `ZENHUB_RELEASE`). Implemented detection of this in code, defaults to `MILESTONE`.
- Modify initial setup text so if user already has api key(s) setup, then we don't give instructions again. Also improve the output when keys aren't set to make it clear what needs done.
- Make the environment variable for Zenhub Api token consistent with Github token (`ZH_API_TOKEN` instead of `ZH_API_KEY`).
- Update package.json with changelog script variation for running it with zenhub release as the source.
- Update `RELEASE.md` docs to clarify changelog script options
- Add a `README.md` doc for the changelog script.
2020-01-28 08:47:26 -05:00
..
common Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655) 2020-01-28 08:47:26 -05:00
github Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655) 2020-01-28 08:47:26 -05:00
zenhub Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655) 2020-01-28 08:47:26 -05:00
README.md Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655) 2020-01-28 08:47:26 -05:00
config.js Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655) 2020-01-28 08:47:26 -05:00
index.js Update changelog script. (https://github.com/woocommerce/woocommerce-blocks/pull/1655) 2020-01-28 08:47:26 -05:00

README.md

Changelog Script

This folder contains the logic for a changelog script that can be used for generating changelog entries from either pull requests added to a Github milestone, or pull requests that are part of a Zenhub release.

Usage:

By default, changelog entries will use the title of pull requests. However, you can also customize the changelog entry by adding to the description of the pull custom text in the following format.

### Changelog

> Fix bug in Safari and other Webkit browsers.

You can implement the script in your package.json in the simplest form by adding the following to the "scripts" property (assuming it is installed in ./bin):

{
  "scripts": {
    "changelog": "node ./bin/changelog",
  }
}

Configuration

The following configuration options can be set for the changelog script. Note: you can use all of these options but environment variables overwrite package.json config and command line arguments overwrite environment variables.

package.json configuration should be added on a top level changelog property.

The 'variable' in the following table can be used in package.json or as a cli arg.

variable description
labelPrefix Any labels prefixed with this string will be used to derive the "type" of change (defaults to type:).
skipLabel Any pull having this label will be skipped for the changelog (defaults to no-changelog).
defaultPrefix When there is no label with the labelPrefix on a pull, this is the default type that will be used for the changelog entry (defaults to dev).
changelogSrcType Either "MILESTONE" (default) or "ZENHUB_RELEASE". This determines what will serve as the source for the changelog entries.
devNoteLabel If a pull has this label then [DN] will be appended to the end of the changelog. It's a good way to indicate what entries have (or will have) dev notes.
repo This is the namespace for the github repository used as the source for pulls used in the changelog entries. Example: 'woocommerce/woocommerce-gutenberg-products-block'
ghApiToken You can pass your github api token to the script. NOTE: Strongly recommend you use environment variable for this.
zhApiKey You can pass your zenhub api key to the script using this config. NOTE: Strongly recommend you use environment variable for this.

The two environment variables you can use are:

Environment Variable Description
GH_API_TOKEN Github API token for authorizing on the github API.
ZH_API_TOKEN Zenhub api token used for authorizing against the zenhub API.

Examples:

package.json:

{
  "changelog": {
    "labelPrefix": "type:",
    "skipLabel": "skip-changelog",
    "defaultPrefix": "dev",
    "repo": "woocommerce/woocommerce-gutenberg-products-block"
  },
}

Environment Variable

GH_API_TOKEN="1343ASDFQWER13241REASD" node ./bin/changelog

Command Line

node ./bin/changelog --labelPrefix="type:" --skipLabel="skip-changelog" --defaultPrefix="dev" --repo="woocommerce/woocommerce-gutenberg-products-block" --ghApiToken="1343ASDFQWER13241REASD"