• Stars
    star
    115
  • Rank 295,268 (Top 6 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

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

Repository Details

A GitHub Action to automatically update a "Keep a Changelog" CHANGELOG with the latest release notes.

changelog-updater Action

A GitHub Action to update a changelog with the latest release notes.

The Action …

  • adds a new second level heading for the new release
  • pastes your release notes in the appropriate place in CHANGELOG.md

If your changelog follows the "Keep a Changelog" format and contains an "Unreleased"-heading, the Action will update the heading to point to the compare view between the latest version and HEAD. (Read more about this here)

Don't want to use GitHub Actions? Checkout the changelog-updater CLI that powers this Action. Want to learn more about this Action? Read my introduction blog post.

Usage

The Action is best used in a Workflow that listens to the release-event and the type released. This way, the name and body of your release will be added to the CHANGELOG.

The following is an example Workflow ready to be used.

The Workflow checks out the target branch of the release, updates the ./CHANGELOG.md-file with the name and the contents of the just released release and commits the changes back to your repository using git-auto-commit.

# .github/workflows/update-changelog.yaml
name: "Update Changelog"

on:
  release:
    types: [released]

jobs:
  update:
    runs-on: ubuntu-latest

    permissions:
      # Give the default GITHUB_TOKEN write permission to commit and push the 
      # updated CHANGELOG back to the repository.
      # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
      contents: write

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.release.target_commitish }}

      - name: Update Changelog
        uses: stefanzweifel/changelog-updater-action@v1
        with:
          latest-version: ${{ github.event.release.tag_name }}
          release-notes: ${{ github.event.release.body }}

      - name: Commit updated CHANGELOG
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          branch: ${{ github.event.release.target_commitish }}
          commit_message: Update CHANGELOG
          file_pattern: CHANGELOG.md

To generate the release notes automatically for you, I can recommend using the release-drafter Action.

Note
When you use the publish-input of release-drafter to immediately create the release, the release-event is probably not triggered due to a limitation of GitHub Actions.
Please create a personl access token, add it as a secret to your repository and pass the token to the release-drafter/release-drafter-Action. See this discussion for mor details.

Advanced Usage

Use Tag Date as Release Date

The following workflow is a bit more advanced. It …

  • extracts the exact release date from the git tag
  • optionally, uses the target branch of the release in the "Unreleased" compare URL
  • pushes the created commit to the target branch of the commit

Warning
DO NOT enable the compare-url-target-revision option, if the target of your releases is the default branch (ref/heads/main or main). The action would otherwise receive refs/heads/main as the target revision value and will generate invalid compare URLs.

Show update-changelog.yaml
# .github/workflows/update-changelog.yaml
name: "Update Changelog"

on:
  release:
    types: [released]

jobs:
  update:
    runs-on: ubuntu-latest

    permissions:
      # Give the default GITHUB_TOKEN write permission to commit and push the 
      # updaetd CHANGELOG back to the repository.
      # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
      contents: write

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          # Fetch entire history of repository to ensure relase date can be
          # extracted from commit of the given tag.
          fetch-depth: 0
          # Checkout target branch of this release. Ensures that the CHANGELOG
          # is not out of date.
          ref: ${{ github.event.release.target_commitish }}

      - name: Extract release date from git tag
        id: release_date
        run: |
          echo "date=$(git log -1 --date=short --format=%ad '${{ github.event.release.tag_name }}')" >> $GITHUB_OUTPUT;

      - name: Update Changelog
        uses: stefanzweifel/changelog-updater-action@v1
        with:
          # Pass extracted release date, release notes and version to the Action.
          release-date: ${{ steps.release_date.outputs.date }}
          release-notes: ${{ github.event.release.body }}
          latest-version: ${{ github.event.release.tag_name }}

          # Optional
          # If your project keeps seperate branches for major releases, and you want to point the compare URL
          # in the "Unreleased"-heading to the corresponding major release branch (eg. `2.x`), then enable the option
          # below.
          # `compare-url-target-revision` will change how the compare URL is composed and will replace 
          # `v2.0.1...HEAD` with `v2.0.1...2.x`.
          # WARNING: When you select `main` when creating a new release, the value `refs/heads/main` 
          # is passed to the Action which will generate an invalid compare URL.
          # compare-url-target-revision: ${{ github.event.release.target_commitish }}

      - name: Commit updated CHANGELOG
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          # Push updated CHANGELOG to release target branch.
          branch: ${{ github.event.release.target_commitish }}
          commit_message: Update CHANGELOG
          file_pattern: CHANGELOG.md

Trigger Action on workflow_dispatch event

HannesWell uses the Action in a worfklow triggered by the workflow_dispatch: See workflow.

The workflow …

  • is manually triggered
  • builds a Java project
  • uses the content between the Unreleased and Previous Release heading as relase notes and updates the CHANGELOG.md
  • commits the changes and pushes them to GitHub
  • creates a new GitHub release and points in the release notes to the right heading for the just released version

This workflow uses the output variables generated by this Action to accomplish this task.

Inputs

Checkout action.yml for a full list of supported inputs. Check the README of the underlying CLI to learn more about them.

Expected Changelog Formats

At minimum, the Action requires an empty CHANGELOG.md file to exist in your repository. When executed, the Action will place the release notes at the bottom of the document. If your changelog already contains a second level heading, the Action will put the release notes above previous release notes in the document.

Your changelog will look something like this:

# Changelog

## v1.1.0 - 2021-02-01

### Added

- New Feature A

## v1.0.0 - 2021-01-01

- Initial Release

If you want to learn more on how the Action determines the place for the release notes, read the the notes in the README of the CLI that powers this Action.

Outputs

The Action exposes some outputs you can further use in your workflow. The Action currently supports the following outputs:

release_compare_url

The generated compare URL for the just created relase. For example https://github.com/org/repo/compare/v1.0.0...v1.1.0. The value is only available, if the Action could generate a compare URL based on the available CHANGELOG data.

release_url_fragment

The URL fragment for the just created release. For example '#v100---2021-02-01'. You can use this to generate URLs that point to the newly created release in your CHANGELOG.

unreleased_compare_url

The generated compare URL between the latest version and the target revision. For example https://github.com/org/repo/compare/v1.0.0...HEAD. The value is only available, if the Action could generate a compare URL based on the available CHANGELOG data.

See action.yml for details.

See workflow below on how to use these output values in your workflow.

- name: Update Changelog
  uses: stefanzweifel/changelog-updater-action@v1
  id: "changelog-updater"
  with:
    # Pass extracted release date, release notes and version to the Action.
    release-date: ${{ steps.release_date.outputs.date }}
    release-notes: ${{ github.event.release.body }}
    latest-version: ${{ github.event.release.tag_name }}
    compare-url-target-revision: ${{ github.event.release.target_commitish }}

- name: "release_compare_url"
  # https://github.com/org/repo/compare/v1.0.0...v1.1.0
  run: "echo ${{ steps.changelog-updater.outputs.release_compare_url }}"

- name: "release_url_fragment"
  # #v100---2021-02-01
  run: "echo ${{ steps.changelog-updater.outputs.release_url_fragment }}"

- name: "unreleased_compare_url"
  # https://github.com/org/repo/compare/v1.0.0...HEAD
  run: "echo ${{ steps.changelog-updater.outputs.unreleased_compare_url }}"

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

We also provide major version tags to make it easier to always use the latest release of a major version. For example you can use stefanzweifel/changelog-updater-action@v1 to always use the latest release of the current major version. (More information about this here.)

Credits

License

This project is licensed under the MIT License - see the LICENSE file for details.

More Repositories

1

git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
Shell
1,752
star
2

laravel-stats

πŸ“ˆ Get insights about your Laravel or Lumen Project
PHP
1,691
star
3

screeenly

πŸ“Έ Screenshot as a Service
PHP
478
star
4

sidecar-browsershot

A Sidecar function to run Browsershot on Lambda.
PHP
184
star
5

laravel-sends

A package to keep track of outgoing emails in your Laravel application.
PHP
154
star
6

laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.
PHP
145
star
7

diary-app

πŸ”An End-To-End Encrypted Diary Web App
PHP
93
star
8

laravel-github-actions-demo

A demo application to showcase useful GitHub Actions for PHP developers
PHP
29
star
9

kirby-json-feed

Kirby Plugin to serve a JSON Feed
PHP
26
star
10

imgubox

[Deprecated] Store Imgur favorites in Dropbox
PHP
22
star
11

ScreeenlyClient

PHP API Wrapper for Screeenly
PHP
22
star
12

laravel-phpinsights-action

Run PHP Insights in Laravel in Github Actions
Dockerfile
21
star
13

dotfiles

🐼 My dotfiles
Shell
21
star
14

php-changelog-updater

PHP CLI to add latest release notes to a CHANGELOG
PHP
21
star
15

reusable-workflows

A collection of reusable GitHub Actions workflows I use in my public and private projects.
21
star
16

php-swiss-cantons

πŸ‡¨πŸ‡­ Find Swiss Canton by abbreviation, name or zipcode.
PHP
17
star
17

alfred-emoji-pack

PHP Script to generate Snippets for Alfred with all available Emojis.
PHP
14
star
18

mp3-to-m4r-converter

Bulk-convert mp3 to m4r-files
Shell
12
star
19

deployer-on-github-actions-example

Example Repository showcasing how to run deployer on GitHub Actions
PHP
12
star
20

laravel-file-encryption-example

Example project to showcase backend file encryption
PHP
12
star
21

laravel-download-statistics-app

Aggregated download statistics for Laravel.
PHP
12
star
22

phpinsights-action

Run PHP Insights in Github Actions
Dockerfile
11
star
23

commonmark-mark-extension

Render ==highlighted== texts as <mark> elements in league/commonmark
PHP
11
star
24

dropshare-landingpage

A minimal landingpage for Dropshare.app
HTML
7
star
25

esbuild-mix-manifest-plugin

esbuild plugin to generate mix-manifest.json file compatible with Laravel Mix.
TypeScript
7
star
26

uberspaceScripts

My personal collection of useful scripts, when hosting on uberspace.de
Shell
7
star
27

commonmark-markdown-renderer

Render a league/commonmark AST back to Markdown.
PHP
6
star
28

dirby

An opinionated Kirby theme for documentations
CSS
6
star
29

dropshare-tailwind-landingpage

Simple landingpage to use with Dropshare
JavaScript
5
star
30

js-swiss-cantons

πŸ‡¨πŸ‡­ Find Swiss Canton by abbreviation or name
JavaScript
5
star
31

vue-tailwind-css-modules-demo

Demo application highlighting the use of Tailwind CSS in Vue Components
JavaScript
5
star
32

getting-started-with-bash-testing

Example Bash Project to get started with testing with Bats.
Shell
5
star
33

kirby-laravel-mix-helper

Helper to use Version Busting of Laravel Mix
PHP
5
star
34

icq-christmas-card

Revive one of the old ICQ Christmas Cards from 2002.
HTML
4
star
35

multi-photo-crop

πŸ™ A tool to crop and split photos from a single image
PHP
4
star
36

swiss-canton-iconfont

Serve the 26 Swiss Cantons in a simple icon font
CSS
3
star
37

asana-expander-extension

Browser Extension to automatically expand long comments in Asana
TypeScript
3
star
38

example-advanced-eloquent-with-pivot

Example project mentioned in an article of mine.
PHP
3
star
39

laravel-encryption-key-generator

A simple app to generate new Laravel encryption keys for you.
PHP
3
star
40

photon-the-archive-theme

A "The Archive" theme based on the PHPStorm Theme "Photon" by Brent Roose
3
star
41

alfred-emoji-pack-node

Emojis at your fingertips as Alfred Snippets
JavaScript
2
star
42

radio-srf-menubarapp

πŸ“» A simple menubar application to play Radio SRF stations
Swift
2
star
43

faker-swiss-locations

Provider to generate valid Swiss location data for Faker PHP.
PHP
2
star
44

php-search-string-parser

[In Development] Use Search Input Strings similar to Github
PHP
2
star
45

oh-dear-request-run-action

Trigger Oh Dear runs through GitHub Actions.
2
star
46

git-auto-commit-action-demo-app

A demo application to test git-auto-commit Github Action
PHP
2
star
47

life-expectancy-visualisation

A small application to visualise the life expectancy of different people around the world.
TypeScript
2
star
48

scratchpad

Minimal Scratchpad
HTML
1
star
49

stefanzweifel

1
star
50

chrome-facebook-to-wikipedia-redirect

Read a Wikipedia Article instead of your Newsfeed
JavaScript
1
star
51

user-agent-analyzer

User Agent analysis as a Service.
PHP
1
star
52

sidecar-browsershot-layer

AWS Lambda Layer containing puppeteer-core. Used by sidecar-browsershot
Shell
1
star
53

git-auto-commit-demo-app

A demo application to test the git-auto-commit Action.
1
star