GithubHelp home page GithubHelp logo

rhysd / changelog-from-release Goto Github PK

View Code? Open in Web Editor NEW
74.0 3.0 13.0 162 KB

Simple changelog generator via GitHub releases

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

License: MIT License

Ruby 0.97% Go 83.44% Shell 14.46% Dockerfile 1.13%
changelog generator github releases

changelog-from-release's Introduction

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 }}

For more usage, see -help output.

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)

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 footer.

EOS

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

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

This is a footer.
EOS

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

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

This is a header.

$(changelog-from-release -l 2)

This is a footer.
EOS

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

If you're using the action, use header and footer inputs to insert texts before/after the generated changelog.

- uses: rhysd/changelog-from-release/action@v3
  with:
    file: CHANGELOG.md
    github_token: ${{ secrets.GITHUB_TOKEN }}
    args: -l 2
    header: |
      Changelog
      =========

      This is header.
    footer: |-

      This is footer.

How to ignore some release tags?

For example, if your project has nightly tag release for nightly builds, it should be excluded from changelog.

In this case, use -i command line option to ignore some release tags by regular expression:

changelog-from-release -i '^nightly$' > CHANGELOG.md

How to extract some release tags?

For example, if your project uses v{major}.{minor}.{patch} format for release tags, a changelog should be created with extracting them.

In this case, use -e command line option to extract some release tags by regular expression:

changelog-from-release -e '^v\d+\.\d+\.\d+$' > CHANGELOG.md

How to ignore draft releases?

If you're using the GitHub Action and don't want draft releases to be included in the changelog, you can use the -d flag to omit them:

changelog-from-release -d=false > CHANGELOG.md

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

changelog-from-release's People

Contributors

bnzo avatar ferhatelmas avatar linde12 avatar paescuj avatar rhysd avatar spl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

changelog-from-release's Issues

Could not get URL of remote 'master'

Ran into this even with the GitHub Enterprise GITHUB_API_BASE_URL exported before running the command:

Error: Could not get URL of remote 'master': : Git command "config" [remote.master.url] failed with output "": exit status 1

Found the INPUT_GITHUB_TOKEN env var and it made me curious why the tool isn't using the git credential helper to access it instead, since that's how my PAT (Personal Access Token) is generally used by git to execute commands against the GH Enterprise instance.

It seems odd that despite having that PAT accessible via the GitHub credential helper I would have to submit/export it before issuing changelog-from-release commands.

Looks like it's this call to git config that causes the error:

if s, err = git.Exec("config", fmt.Sprintf("remote.%s.url", ss[0])); err != nil {

No output after waiting several minutes

I am running the GO binary whilst inside a private repo. I exported a github token, with the correct permissions.

../../../go/bin/changelog-from-release > CHANGELOG.md

The MD file is created, but after waiting several minutes, nothing is happening, with the program seemingly hanging?

No errors etc are output in the console, so I'm not sure what's going on.

go install error

I'm pretty new to Go so please excuse me if I am doing this wrong. Following the instructions to install the package gives me version v2.2.2. I read that @latest does not work, when trying to specify a version, that does not work either:

# does not work since I'm installing this in a blank directory
$ go install github.com/rhysd/changelog-from-release
go: 'go install' requires a version when current directory is not in a module
	Try 'go install github.com/rhysd/changelog-from-release@latest' to install the latest version

# using @latest does work (even though README says it does not)
$ go install github.com/rhysd/changelog-from-release@latest
go: finding module for package golang.org/x/oauth2
go: finding module for package github.com/google/go-github/github
go: finding module for package github.com/pkg/errors
go: found github.com/google/go-github/github in github.com/google/go-github v17.0.0+incompatible
go: found github.com/pkg/errors in github.com/pkg/errors v0.9.1
go: found golang.org/x/oauth2 in golang.org/x/oauth2 v0.0.0-20220808172628-8227340efae7
go: finding module for package github.com/google/go-querystring/query
go: found github.com/google/go-querystring/query in github.com/google/go-querystring v1.1.0

# confirm old version
$ ./go/bin/changelog-from-release -v
v2.2.2

# specifying version does not work
$ go install github.com/rhysd/[email protected]
go: github.com/rhysd/[email protected]: github.com/rhysd/[email protected]: invalid version: module contains a go.mod file, so module path must match major version ("github.com/rhysd/changelog-from-release/v3")
$ go version
go version go1.19 darwin/amd64

Disable automatic tag addition to title

We started using this automation in some of our projects and noticed that after the release title there is always the tag. But since we already have the version number in the release title anyway, it is now twice in a row. e.g. Minesweeper (Privacy Friendly) v1.2.0 (v1.2.0).

Is it possible to turn off the automatic addition of the tag or leave the tag out if it is already in the title? It's only a minor inconvenience, but would be great if that would be possible.

โ” Supporting images for a private repository

Question
I have a private repository that belongs to the organisation that I work for and it isn't possible to make it public.

Is there any way to support images that are used in the release notes?

The output currently doesn't show the image that exists in the release notes:

image

I assume this is because the documentation cannot access the image asset due to it being private.

Any help with this is much appreciated!

Github actions failed when the branch protection is on

I have turned branch protection on (only Require a pull request before merging and Require approvals) for my repo, and when I run the actions, it failed with the output:

+ git push --force ***github.com/user/repo.git
remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: error: At least 1 approving review is required by reviewers with write access.        
To https://github.com/user/repo.git
 ! [remote rejected] main -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/user/repo.git'

There is no reason this would fail since it's a push rather than a pr. After I disable the branch protection, the CHANGELOG.md can be generated.

Endless loop when more than one page of github releases

We started to hit this weird bug that CHANGELOG.md started to get really big and the action takes very long, basically until github actions interrupts it.

Now by looking at the code it seems that changelog-from-release only checks that is the nextPage 0 but does not use that for the iterative call of list releases so this causes endless loop.

I hope you could release a fix for this since this is a nice tool, but currently can not be used if there is more than 30 releases.

Most likely this is cause for those couple old bug reports regarding just spinning action no output since this causes the step to run as long as github actions lets it.

Version 3.5.2 and up causes a 404 error

Starting at version 3.5.2, I get the following error:
image

Downgrading back to 3.5.1 makes the action work as expected again:
image

For reference in case it's useful, the workflow is set up in the following way:

  • Checkout (actions/checkout@v3)
  • Create new branch (peterjgrainger/[email protected])
  • Checkout to new branch (actions/checkout@v3)
  • Generate changelog

(The workflow was naturally created before the PR-option for this action was avaliable, which is the reasoning for the branching).

Private repository does not work

I have trouble running this program on private repository. I get this error Error: Cannot get releases from repository.

Even adding a Github Token to $GITHUB_TOKEN does not help.

404 error when trying to use as GitHub Action on private repo

Not sure if this comment was being seen on a closed issue:

#1

I'm experiencing the same error as the OP when trying to use your tool as a GitHub Action on my private repo. I've setup a personal access token with repo permissions. I then added a new secret in my repo settings titled 'secrets.ACTIONS_TOKEN' with that personal access token as the value. But when I post a release and the action runs, it fails on this step:

Run rhysd/changelog-from-release/action@v2

With the following...

Run rhysd/changelog-from-release/action@v2
/usr/bin/docker run --name e4032e435f149b4c569e828c56674284ca_986d31 --label 5588e4 --workdir /github/workspace --rm -e INPUT_FILE -e INPUT_GITHUB-TOKEN -e INPUT_VERSION -e INPUT_COMMIT -e INPUT_PUSH -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/<repo>":"/github/workspace" <id>
changelog-from-release version: v2.2.0
+ GITHUB_TOKEN= /changelog-from-release
Error: Cannot get releases from repository <repo> via GitHub API: GET https://api.github.com/repos/<repo>/releases: 404 Not Found []

Any help you can give would be greatly appreciated. Your action is exactly what I was wanting, if I can just get it to work. ๐Ÿ˜ƒ

Originally posted by @DavidCannon in #1 (comment)

Update changelog before adding the release tag in Github action.

In FAQ section of README, there is a description the way how to update changelog before adding the release tag.

I'm trying to do such things with Github actions, but it seems that there is no such features at this moment.
Am I correct? If so, it would be great to have a such feature.

feature request: list releases with second level headings

It would be amazing if there was a feature (possibly called with a command line argument) that would list releases as second level headings, possibly prepended by something like a "# Changelog" first level heading.

It would be useful when including the .md file in an index, without having all single releases showing up in the toctree.

I would contribute myself, but unfortunately i know very little of Go. Do you think this is worth implementing? Thanks ๐Ÿš€

Runner doesn't support git-lfs

My repository in which I am trying to use the action, it looks like it does not support git-lfs and my repo is configured with git-lfs.

changelog-from-release version: v3.7.1
+ '[' true '=' true ]
+ git checkout -b changelog-v4.4.2
Switched to a new branch 'changelog-v4.4.2'
\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n

Obviously the step does not require LFS files so maybe it should do a shallow clone or something?

Credentials in the changelog

I think it would be great to strip credentials provided in .git/config

Here is the result if you're using GitHub personal tokens.

<a name="v1.0.10"></a>
 # [v1.0.10](https://maxim-smirnov:[email protected]/maxim-smirnov/homebridge-neptun-smart/releases/tag/v1.0.10) - 11 May 2022

 **fix:** Now using unique name for valves of the second group

 **Full Changelog**: https://github.com/maxim-smirnov/homebridge-neptun-smart/compare/v1.0.9...v1.0.10

 [Changes][v1.0.10]

Links don't follow the repository rename

Repro

  1. Create a repository named foo
  2. git clone https://github.com/you/foo.git
  3. Rename the repository from foo to foo-renamed
  4. Run changelog-from-release in the directory cloned at 2.

Expected behavior

Links should point to the renamed repository foo-renamed

Actual behavior

Links point to the repository foo, before the rename

Description

GitHub redirects the links to the renamed repository so this is not an immediate issue. But outdated links should not be used as much as possible.

How to make the action get just the last release and insert in changelog.md file?

I had a big old changelog.md.

recently I've migrated all realeases o Github. I've converted my old local changlog to your format and updated the chamglog.md file.
I need that on every nre relese the action insert just the last relase on top of the file, preserving my old history.

It's required because I cant recrate my local history in github, since I'm already usign Github releases

403 error with the Action

I'm trying to use the Action on https://github.com/nhoizey/eleventy-plugin-pack11ty

The changelog file is generated, but I get a 403 error when the Action tries to push the result.

Here's the end of the Action log (without the file content):

+ GITHUB_TOKEN=*** /changelog-from-release
changelog-from-release version: v3.7.0
+ CHANGELOG='โ€ฆ'
+ set +x
+ '[' false '=' true ]
+ git add CHANGELOG.md
+ git -c 'user.name=nhoizey' -c '[email protected]' commit -m 'Update changelog for "v1.7.1"

    This commit was created by changelog-from-release in '"'"'Update CHANGELOG'"'"' CI workflow'
+ '[' true '=' true ]
+ git push --force ***github.com/nhoizey/eleventy-plugin-pack11ty.git
 1 file changed, 155 insertions(+)
 create mode 100644 CHANGELOG.md
remote: Permission to nhoizey/eleventy-plugin-pack11ty.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/nhoizey/eleventy-plugin-pack11ty.git/': The requested URL returned error: 403

Here's the workflow: https://github.com/nhoizey/eleventy-plugin-pack11ty/blob/main/.github/workflows/changelog-from-release.yml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.