xeolabs / changelog-from-release

Simple changelog generator via GitHub releases

Home Page:https://github.com/rhysd/changelog-from-release/blob/master/CHANGELOG.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate Changelog from GitHub Releases

CI

changelog-from-release is a (too) small command line tool to generate changelog from GitHub Releases. It fetches releases of the repository via GitHub API and generates changelog in Markdown format.

For example, CHANGELOG.md was generated from the releases page.

Other real-world examples:

Installation

Download binary from the releases page or build from sources with Go toolchain.

$ go install github.com/rhysd/changelog-from-release/v3@latest

Usage

Running changelog-from-release with no argument outputs a changelog text in Markdown format to stdout. Please redirect the output to your changelog file.

$ cd /path/to/repo
$ changelog-from-release > CHANGELOG.md
$ cat CHANGELOG.md

Automation with GitHub Actions is also offered. Please read action's README for more details.

- uses: rhysd/changelog-from-release/action@v3
  with:
    file: CHANGELOG.md
    github_token: ${{ secrets.GITHUB_TOKEN }}

FAQ

How to update changelog before adding the release tag?

For example, how to include changes for v1.2.3 in CHANGELOG.md before creating a Git tag v1.2.3?

Please use a release draft.

  1. Click 'Draft a new release' button in releases page and write up release note for the next release
  2. Click 'Choose a tag' drop down and enter a tag name for the release which is not created yet. Then click '+ Create new tag: ... on publish' item in the drop down.
  3. Save the draft by clicking 'Save draft'
  4. Run changelog-from-release with setting a personal access token to $GITHUB_TOKEN environment variable
  5. Commit the generated changelog
  6. Create and push the new Git tag. Ensure the tag name is the same as one entered at 2.
  7. Go to the draft release page created at 1. and publish the release by clicking 'Publish release' button

Setting a personal access token at 2. is mandatory since release drafts are private information. API token associated with your account is necessary to fetch it. If you use the action, an API token is automatically generated by GitHub Actions so you don't need to create a token by yourself.

How to insert some templates at top/bottom of generated changelog?

Since changelog-from-release command just generates changelog history, you can insert your favorite templates before/after redirecting the generated output to CHANGELOG.md file.

# Insert header
cat <<-EOS > CHANGELOG.md
Changelog
=========

This is a changelog for [my-project](https://github.com/owner/my-project

EOS

changelog-from-release -l 2 >> CHANGELOG.md

# Insert footer
cat <<-EOS >> CHANGELOG.md

Releases on GitHub: https://github.com/owner/my-project/releases
EOS

If your shell supports $(), header and footer can be inserted once.

cat <<-EOS > CHANGELOG.md
Changelog
=========

This is a changelog for [my-project](https://github.com/owner/my-project

$(changelog-from-release -l 2)

Releases on GitHub: https://github.com/owner/my-project/releases
EOS

-l 2 means using ## instead of # for each release section. Please adjust it for your use case.

Reference auto linking

References in a release note are automatically converted to links by changelog-from-release.

  • Issue references like #123 are converted to links to the issue pages
  • User references like @rhysd are converted to links to the user profile pages
  • Commit references like 93e1af6ec49d23397baba466fba1e89cc8b6de39 are converted to links to the commit pages. To avoid false-positives, only full-length (40 characters) commit hashes are converted.

For example,

Commit: 93e1af6ec49d23397baba466fba1e89cc8b6de39
Author: @rhysd
Issue:  #123

is converted to

Commit: [`93e1af6ec4`](https://github.com/owner/repo/commit/93e1af6ec49d23397baba466fba1e89cc8b6de39)
Author: [@rhysd](https://github.com/rhysd)
Issue:  [#123](https://github.com/owner/repo/issues/123)

Environment variables

GITHUB_API_BASE_URL

For GitHub Enterprise, please set GITHUB_API_BASE_URL environment variable to configure API base URL.

export GITHUB_API_BASE_URL=https://github.your-company.com/api/v3

GITHUB_TOKEN

If changelog-from-release reported API rate limit exceeded or no permission to access the repository, consider to specify a personal access token.

export GITHUB_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

License

the MIT License

About

Simple changelog generator via GitHub releases

https://github.com/rhysd/changelog-from-release/blob/master/CHANGELOG.md

License:MIT License


Languages

Language:Go 84.0%Language:Shell 13.6%Language:Dockerfile 1.3%Language:Ruby 1.1%