Skip to content
upload

GitHub Action

gh-create-release

v5.0.1 Latest version

gh-create-release

upload

gh-create-release

Automates the creation of releases for GitHub repositories

Installation

Copy and paste the following snippet into your .yml file.

              

- name: gh-create-release

uses: notpeelz/action-gh-create-release@v5.0.1

Learn more about this action in notpeelz/action-gh-create-release

Choose a version

GitHub Create Release

A GitHub action to automate the creation of releases.

Source code available at https://github.com/notpeelz/github-create-release

Parameters

Parameter Description Default
token The GitHub access token.
${{ github.token }}
repository The repository where the release should be created.
For example, octocat/hello-world
${{ github.repository }}
target The git object to tag. This can be a SHA or a ref to a git object.
tag1 The name of the tag associated with the release.
tag-message The message associated with the tag (defaults to the name of the tag)
strategy Determines what should be done if the tag already exists.
Possible values:
fail-fast - aborts with an error if the tag already exists
use-existing-tag - uses an existing tag, replacing associated releases (target parameter is ignored)
replace - replaces the tag along with associated releases
fail-fast
title The title of the release.
title-source Determines where the the title should be read from.
Possible values:
literal - uses the "title" parameter as-is
file - reads from the file specified in the "title" parameter
env - reads from the environment variable specified in the "title" parameter
literal
body The message associated with the release.
body-source Determines where the the body should be read from.
Possible values:
literal - uses the "body" parameter as-is
file - reads from the file specified in the "body" parameter
env - reads from the environment variable specified in the "body" parameter
literal
prerelease If true, the release will be marked as a pre-release.
draft If true, the release will be made into a draft.
discussion-category-name If specified, a discussion of the specified category is created and
linked to the release.
files Newline-separated list of files to upload (supports globbing).
Missing files are ignored.

Outputs

Parameter Description
release-id The unique identifier of the release that was created.
See https://docs.github.com/en/rest/releases/releases#get-a-release

Examples

Publish release when new tags are pushed

name: Publish release

on:
  push:
    tags:
      - "*"

jobs:
  publish-release:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v')
    steps:
      - name: Checkout branch
        uses: actions/checkout@v3
      - name: Build
        run: |
          echo "stuff!" > file1.txt
          echo "more stuff!" > file2.txt
          echo "even more stuff!" > even_more_stuff.txt
          echo "even more stuff! (#2)" > even_more_stuff_v2.txt
      - uses: notpeelz/action-gh-create-release@v5.0.1
        with:
          strategy: existing
          tag: ${{ github.ref_name }}
          title: ${{ github.ref_name }}
          files: |
            file*.txt
            even_more_stuff{,_v2}.txt

Publish release via manual workflow run

name: Create release

on:
  workflow_dispatch:
    inputs:
      version:
        description: "Version"
        required: true
        type: string

jobs:
  create-release:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout branch
        uses: actions/checkout@v3
      - uses: notpeelz/action-gh-create-release@v5.0.1
        with:
          strategy: fail-fast # this is the default
          # TODO: it's probably a good idea to validate the version format
          # in an earlier step.
          tag: v${{ inputs.version }}
          title: v${{ inputs.version }}

Footnotes

  1. required