Git Product home page Git Product logo

changelog-generator's Introduction

Get a changelog between two references

This Action returns a markdown formatted changelog between two git references. There are other projects that use milestones, labeled PRs, etc. Those are just too much work for simple projects.

I just wanted a simple way to populate the body of a GitHub Release.

Example Release Notes

Inputs

mytoken

A GITHUB_TOKEN with the ability to pull from the repo in question. This is required.

Why do we need myToken? Read more here: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token#about-the-github_token-secret

head-ref

The name of the head reference. Default ${{github.sha}}.

base-ref

The name of the second branch. Defaults to the tag_name of the latest GitHub release. This must be a GitHub release. Git tags or branches will not work.

reverse

Whether the order of commits should be printed in reverse. Default: 'false'

fetch

Whether this action should pull in all other branches and tags. Default: 'true'

Outputs

changelog

Markdown formatted changelog.

Example usage

There are two blocks you will need:

First block

First you will need to generate the changelog itself. To get the changelog between the SHA of the commit that triggered the action and the tag of the latest release:

- name: Generate changelog
  id: changelog
  uses: metcalfc/[email protected]
  with:
    myToken: ${{ secrets.GITHUB_TOKEN }}

Or, if you have two specific references you want:

- name: Generate changelog
  id: changelog
  uses: metcalfc/[email protected]
  with:
    myToken: ${{ secrets.GITHUB_TOKEN }}
    head-ref: 'v0.0.2'
    base-ref: 'v0.0.1'

If you want to point to a branch containing forward slashes (#179) do the following:

# let the checkout action do the fetching
- uses: actions/checkout@v3
  with:
    fetch-depth: 0

- name: Generate changelog
  id: changelog
  uses: metcalfc/[email protected] #TODO: bump this after release
  with:
    myToken: ${{ secrets.GITHUB_TOKEN }}
    head-ref: 'origin/my/branch/with/slashes' #add 'origin/` in front of your branch name
    base-ref: 'v4.3.1'
    fetch: false

Second block

Then you can use the resulting changelog:

- name: Get the changelog
  run: |
    cat << "EOF"
    ${{ steps.changelog.outputs.changelog }}
    EOF

Simple output modifications

Some folks have asked if the action can support changing the output. For example:

  • Reverse order UPDATE as of 2021/11/22 chronological is the default and it can be reversed by setting reverse: 'true' in the workflow.
  • Ignore entries that include this string.
  • Etc

In order to keep this action as simple as possible we aren't planning to add more flags or options. However since the output is just text you can write a command line to do anything you want. In issue #93 we had a user that wanted to list the changelog in reverse order and drop any entries with gh-pages. Here is how they can do that but using Bumping as the restrict word because it shows up in this projects history:

      - name: Modify the changelog
        id: modified
        run: |
          set -o noglob
          log=$(cat << "EOF" | grep -v Bumping | tac
          ${{ steps.changelog.outputs.changelog }}
          EOF
          )
          log="${log//'%'/'%25'}"
          log="${log//$'\n'/'%0A'}"
          log="${log//$'\r'/'%0D'}"
          echo "log=$log" >> $GITHUB_OUTPUT

      - name: Print the modified changelog
        run: |
          cat << "EOF"
          ${{ steps.modified.outputs.log }}
          EOF

You might be wondering about that set of escaping for the log. Thats because GitHub Actions doesn't support multiline output. Read more here.

Example use case

Generating the release notes for a GitHub Release.

Open Discussions for feature requests or questions

Issues are for folks who are actively using the action and running into an "issue" (bug, missing doc, etc).

Feature requests should be in the discussion section.. Just to set expectations the bar for a new feature getting added is going to be very high. There is a cost to adding features in the development and maintainance of the feature. So if you want to jump in and help develop and maintain lets discuss. If you want to fire off feature ideas, go for it. Just understand its very likely that without someone willing to take up the task, they won't get implemented.

Keep up-to-date with GitHub Dependabot

Since Dependabot has native GitHub Actions support, to enable it on your GitHub repo all you need to do is add the .github/dependabot.yml file:

version: 2
updates:
  # Maintain dependencies for GitHub Actions
  - package-ecosystem: 'github-actions'
    directory: '/'
    schedule:
      interval: 'daily'

Troubleshooting

Error not found

Error: Not Found

If you are seeing this error its likely that you do not yet have a GitHub release. You might have a git tag and that shows up in the release tab. The API this Action uses only works with GitHub Releases. Convert one of your tags to a release and you'll be on your way. You can check out how this repository uses this action and GitHub releases for an example.

Acknowledgements

I took the basic framework for this action from: jessicalostinspace/commit-difference-action. Thanks @jessicalostinspace.

changelog-generator's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar metcalfc avatar nielstenboom avatar tamsky avatar wibbuffey 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  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  avatar

changelog-generator's Issues

Support '/' in branch names

Hi there!

Wanted to try out your action. I set the head-ref to the current branch which has a / in it and got the following error:

Error: Branch names must contain only numbers, strings, underscores, periods, and dashes.

Would it be possible to support branch names with slashes? Thanks!

Node version is deprecated warning

Receiving the following issue when using this action:

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: actions/checkout, metcalfc/changelog-generator

Commit hash as "view commit" link

Hey,

Would it be possible to have an input that allows us to use the shortened commit hash i.e. dcb19ff as the link to the commit itself?

It could be in the format:

[`dcb19ff`](example.com) - Commit message

Quite happy to make a PR if you don't have time to work on this?

Permission error

The action was doing very well last week and today it crashes due to insufficient privilege ...

Do you have an idea from where it could come ?

Run metcalfc/[email protected]
  with:
    myToken: ***
    head-ref: ed1baa724edbfca616424d27fb92ddf6cfc6bb28
    base-ref: v3.0-1
head-ref: ed1baa724edbfca616424d27fb92ddf6cfc6bb28
base-ref: v3.0-1
/home/runner/work/_actions/metcalfc/changelog-generator/v0.4.4/dist/changelog.sh ed1baa724edbfca616424d27fb92ddf6cfc6bb28 v3.0-1 ovh/debian-cis
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed
Error: Could not generate changelog between references because: The process '/home/runner/work/_actions/metcalfc/changelog-generator/v0.4.4/dist/changelog.sh' failed with exit code 128

Here is the workflow :
https://github.com/ovh/debian-cis/runs/1761796044?check_suite_focus=true

[error]Not Found

image

I don't know why, some errors occurred during my use.
This is my configuration file:

name: autoRelease
on:
  push:
    tags:
      - 'v*'

jobs:
  autoRelease:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Generate changelog
        id: changelog
        uses: metcalfc/[email protected]
        with:
          myToken: ${{ secrets.GITHUB_TOKEN }}

      - name: Create Release
        id: create_release
        uses: actions/create-release@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: ${{ steps.changelog.outputs.changelog }}
          draft: false
          prerelease: false

According to my investigation, ${{ secrets.GITHUB_TOKEN }} here does not need to be added, it is generated by default, so I have not done anything except add this file.
If I did something wrong, please let me know, thank you for your work and look forward to your reply.

no commit hash url text

Releases have this text for me:

* [](http://github.com/../../../) - Update VERSION
* [](http://github.com/../../../) - Update buildRelease.yml
* [](http://github.com/../../../) - Update buildRelease.yml

The URL works and is complete but the text is missing, thus its displaying a line as:

  • - Update VERSION

I am building a release like this (in case this has to do something with it):

    - name: Create Release
      run: |
        set -x
        assets=()
        for asset in ./*.zip; do
          assets+=("-a" "$asset")
        done
        hub release create "${assets[@]}" -d -m "Release v${{ steps.set-version.outputs.version }}
        
        ${{ steps.changelog.outputs.changelog }}" "v${{ steps.set-version.outputs.version }}"
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Command not found - commit hashes processed as commands

When I run the action with version 1.0.1, I get a series of errors, one for each commit:

/home/runner/work/_temp/905f1d11-4c4e-435f-a04c-b37f0f4ad41f.sh: line 22: 4c090fc: command not found

I think because the commit hashes are being rendered between ` instead of ', bash interprets them As commands.

what’s the recommended fix?

[Recommendation]: Option to skip commit

Hi,

I using this action for a monorepo

I like to skip some kind of commit such as [mv2]: * . This is necessary for monorepos because there are commits that are not related to each other.

Could not Generate Changelog

Hi,

I'm using this changelog generator and it works perfectly fine before but now I am getting this error: Could not generate changelog between references because: The process '/home/runner/work/_actions/metcalfc/changelog-generator/v3.0.0/dist/changelog.sh' failed with exit code 128

Changelog fails on run

I'm getting the following error when trying to run the changelog.

Run metcalfc/[email protected]
head-ref: ad8b927c8892dbdf0[5](https://github.com/Bearsampp/Bearsampp/runs/8104605776?check_suite_focus=true#step:2:6)871b11ffdd1eac8b1b[6](https://github.com/Bearsampp/Bearsampp/runs/8104605776?check_suite_focus=true#step:2:7)53d
base-ref: 2022.08.14
/home/runner/work/_actions/metcalfc/changelog-generator/v3.0.0/dist/changelog.sh ad8b92[7](https://github.com/Bearsampp/Bearsampp/runs/8104605776?check_suite_focus=true#step:2:8)c[8](https://github.com/Bearsampp/Bearsampp/runs/8104605776?check_suite_focus=true#step:2:9)8[9](https://github.com/Bearsampp/Bearsampp/runs/8104605776?check_suite_focus=true#step:2:10)2dbdf05871b11ffdd1eac8b1b653d 2022.08.14 Bearsampp/Bearsampp false
fatal: not a git repository (or any of the parent directories): .git
Error: Could not generate changelog between references because: The process '/home/runner/work/_actions/metcalfc/changelog-generator/v3.0.0/dist/changelog.sh' failed with exit code 128

my action is here https://github.com/Bearsampp/Bearsampp/blob/main/.github/workflows/changelog.yml

changelog in reverse order?

I want ${{ steps.changelog.outputs.changelog }} is reverse order
Changelog
7381c2c - add body
6c58ae2 - add console 2020年12月08日10:28:02
9253cb6 - add console 2020年12月08日10:37:08
6dd71dc - add console 2020年12月08日10:42:03
eeb7ae0 - Update release-drafter.yml
f411180 - Update release-drafter.yml
ad14d75 - no message

same error as issue #20 in version v0.4.4

In a repository with several (pre-release) tags I'm getting this:

  with:
    myToken: ***
  env:
    VERSION: 0.3.1-1
    pythonLocation: /opt/hostedtoolcache/Python/3.7.9/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.9/x64/lib
Error: Not Found

when trying to create a new release (not a pre-release) using github actions. Looking at the closed bug I still can't figure out what the "correct" usage is.

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.