Home

Awesome

Git Changelog Github Release Action

This is a GitHub action that can draft release in GitHub generated from template using git-changelog-lib.

<kbd><img src="git-changelog-github-release-draft.png" width="300" /></kbd>

Draft releases

name: Git Changelog Github Release

on: [workflow_dispatch, workflow_call, push]

jobs:
  build:
    runs-on: 'ubuntu-latest'
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-tags: 'true'
          fetch-depth: '0'
      - name: Setup java
        uses: actions/setup-java@v2
        with:
          distribution: 'zulu'
          java-version: 17
      - uses: tomasbjerre/git-changelog-github-release@main
        env:
          # Needs write permission in Github menu '/settings/actions'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Running example in this repo.

Triggering release when publishing draft

You may want to have GitHub trigger a workflow when drafted release is published. Perhaps to build it and upload a release. Perhaps something like this:

name: Release
on:
  release:
    types: [published]
jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - name: Determine new version
        id: new_version
        run: |
          NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
          echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
      - name: Publish
        run:
          echo Whatever command to release version ${{
          steps.new_version.outputs.new_version }}

Publish releases when tags pushed

If you already have some other way of releasing, you may want to just publish those releases.

This will render the release content with the difference between the last 2 tags.

name: Publish release on tag push

on:
  workflow_dispatch:
  workflow_call:
  push:
    tags:
      - '*'

jobs:
  build:
    runs-on: 'ubuntu-latest'
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-tags: 'true'
          fetch-depth: '0'
      - name: Setup java
        uses: actions/setup-java@v2
        with:
          distribution: 'zulu'
          java-version: 17
      - uses: tomasbjerre/git-changelog-github-release@main
        env:
          # Needs write permission in Github menu '/settings/actions'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          draft: false

Running example in this repo.