• Stars
    star
    137
  • Rank 265,118 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GitHub Action to generate changelogs, release notes, whatever

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.1.0'
    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.

More Repositories

1

docker-action-examples

Makefile
135
star
2

docker-ecs-compose

HTML
21
star
3

docker-circleci-example

Makefile
6
star
4

dotfiles

Shell
3
star
5

earthly-python-example

An Python Flask app built with Earthly
Makefile
2
star
6

dagger-hello

Go
2
star
7

bashpod

One stop shop for Bash centric dotfiles for Gitpod, WSL, and Mac
Shell
2
star
8

ubuntu-box

Shell
2
star
9

gpsh

Shell
2
star
10

gitpod-helpers

Helpers for installing self-hosted Gitpod
Shell
2
star
11

gitpod-py-centos

Python
2
star
12

clever

TypeScript
1
star
13

ender3v2

G-code
1
star
14

slacker-bash

Simple wrapper for my favorite Slack CLI commands
Shell
1
star
15

hub-cli

Docker Hub Repo Create/Delete
JavaScript
1
star
16

demo-podman

1
star
17

gmail-cleanup-script

Google Script App to keep Gmail clean
JavaScript
1
star
18

docker-simple-flask

HTML
1
star
19

secscanblob

Python
1
star
20

composer

Python
1
star
21

rocktreemountain

SCSS
1
star
22

myexample

Go
1
star
23

dotcloud

Lightweight dotfiles for remote cloud environments like Codespaces and Daytona.
Shell
1
star
24

gitpod-docs-test

HTML
1
star
25

compose-workaround

Can we work around the Docker Compose shutdown issue?
Shell
1
star
26

easy-button-main

Change a GitHub repository's default branch from the CLI
Ruby
1
star
27

slacker

Slacker in Go
Go
1
star
28

sbtest

Created with StackBlitz ⚡️
Vue
1
star
29

golang-template

Go
1
star
30

cloud-ranges

Python Script to Get AWS, GCP, and Azure IP ranges
Python
1
star
31

jumpbox

VPN/Mosh Dev Env on Digital Ocean
HCL
1
star
32

newdot

New Dotfiles
Shell
1
star
33

two-build-pushes

Dockerfile
1
star
34

minecraft

1
star
35

docker-artifactory-hol

Docker Artifactory Hands on Lab
Shell
1
star
36

gitpod-this

A cross Linux script to do all the things that Gitpod workspaces need
Shell
1
star
37

metcalfc

Chad Metcalf
1
star
38

tailzone

Create a BIND Zone from the devices in a Tailscale account
Python
1
star
39

stevedore

A common Vagrant environment for developing, testing or playing with the Docker ecosystem.
Shell
1
star