Home

Awesome

create-gh-release-action

release github actions

GitHub Action for creating GitHub Releases based on changelog.

Usage

This action creates GitHub Releases based on changelog that specified by changelog option.

Currently, changelog format and supported tag names have the following rule:

Inputs

NameRequiredDescriptionTypeDefault
tokentrue 1GitHub token for creating GitHub Releases (see action.yml for more)String
changelogfalsePath to changelog (variables $tag, $version, $prefix, and any string)String
allow-missing-changelogfalseCreate the release even if the changelog entry corresponding to the version is missing. The default value of the changelog will be an empty string.Booleanfalse
titlefalseFormat of title (variables $tag, $version, $prefix, and any string)String$tag
draftfalseCreate a draft release (true or false)Booleanfalse
branchfalseReject releases from commits not contained in branches that match the specified pattern (regular expression)String
prefixfalseAn optional pattern that matches a prefix for the release tag, before the version number (see action.yml for more)String
reffalseFully-formed tag ref for this release (see action.yml for more)String

Outputs

NameDescription
computed-prefixThe computed prefix, including '-' and 'v'.
versionThe version number extracted from the tag. The tag name is a concatenation of computed-prefix and version.

Example workflow: Basic usage

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (Optional) Path to changelog.
          changelog: CHANGELOG.md
          # (Required) GitHub token for creating GitHub Releases.
          token: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Create a draft release

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (Optional) Path to changelog.
          changelog: CHANGELOG.md
          # (Optional) Create a draft release.
          # [default value: false]
          draft: true
          # (Required) GitHub token for creating GitHub Releases.
          token: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Custom title

You can customize the title of the release by title option.

Example of the created release.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (Optional)
          changelog: CHANGELOG.md
          # (Optional) Format of title.
          # [default value: $tag]
          # [possible values: variables $tag, $version, and any string]
          title: $version
          # (Required) GitHub token for creating GitHub Releases.
          token: ${{ secrets.GITHUB_TOKEN }}

Example workflow: No changelog

If the changelog option is not specified, the changelog is ignored and only the release created.

Example of the created release.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (Required) GitHub token for creating GitHub Releases.
          token: ${{ secrets.GITHUB_TOKEN }}

Example workflow: Reject releases from outside of main branch

You can reject releases from commits not contained in branches that match the specified pattern by using branch option.

name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - v[0-9]+.*

jobs:
  create-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          # (Optional) Path to changelog.
          changelog: CHANGELOG.md
          # (Optional) Reject releases from commits not contained in branches
          # that match the specified pattern (regular expression)
          branch: main
          # (Required) GitHub token for creating GitHub Releases.
          token: ${{ secrets.GITHUB_TOKEN }}

Other examples

Supported events

The following two events are supported by default:

You can create a release from arbitrary event to arbitrary tag by specifying the ref input option.

For example, to create a release to the my_tag tag, specify ref input option as follows:

with:
  ref: refs/tags/my_tag

Compatibility

This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows). To use this action in self-hosted runners or in containers, at least the following tools are required:

Related Projects

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Footnotes

  1. Required one of token input option or GITHUB_TOKEN environment variable.