📦 :octocat: GitHub Action for creating GitHub Releases
Go to file
2019-09-09 20:03:40 +09:00
__tests__ refactor for cross platform use 2019-09-09 17:10:07 +09:00
.github/workflows fix workflow test 2019-09-09 17:11:42 +09:00
lib debug workflow 2019-09-09 18:42:19 +09:00
node_modules node_modules 2019-09-09 20:03:40 +09:00
src debug workflow 2019-09-09 18:42:19 +09:00
tests/data/foo extract, test and fix path selection to only include files 2019-08-25 15:13:13 -04:00
.gitignore node_modules 2019-09-09 20:03:40 +09:00
action.yml top level env 2019-09-09 18:26:06 +09:00
jest.config.js refactor for cross platform use 2019-09-09 17:10:07 +09:00
LICENSE lic 2019-08-25 02:17:01 -04:00
package-lock.json update actions deps 2019-09-09 18:24:28 +09:00
package.json update actions deps 2019-09-09 18:24:28 +09:00
README.md move env to top level 2019-09-09 17:36:46 +09:00
release.sh dump release trick specific to actions node_modules management 2019-09-09 19:53:59 +09:00
tsconfig.json refactor for cross platform use 2019-09-09 17:10:07 +09:00

action gh-release

A GitHub Action for creating GitHub Releases

⚠️ Note: To use this action, you must have access to the GitHub Actions feature. GitHub Actions are currently only available in public beta. You can apply for the GitHub Actions beta here.

🤸 Usage

🚥 Limit releases to pushes to tags

Typically usage of this action involves adding a step to a build that is gated pushes to git tags. You may find step.if field helpful in accomplishing this as it maximizes the resuse value of your workflow for non-tag pushes.

Below is a simple example of step.if tag gating

name: Main

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Release
        uses: softprops/action-gh-release
        if: startsWith(github.ref, 'refs/tags/')
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

You can also use push config tag filter

name: Main

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Release
        uses: softprops/action-gh-release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

⬆️ Uploading release assets

You can can configure a number of options for your GitHub release and all are optional.

A common case for GitHub releases is to upload your binary after its been validated and packaged. Use the with.files input to declare a comma-separated list of glob expressions matching the files you wish to upload to GitHub releases. If you'd like you can just list the files by name directly.

Below is an example of uploading a single asset named Release.txt

name: Main

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Build
        run: echo ${{ github.sha }} > Release.txt
      - name: Test
        run: cat Release.txt
      - name: Release
        uses: softprops/action-gh-release
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: Release.txt
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

📝 External release notes

Many systems exist that can help generate release notes for you. This action supports loading release notes from a path in your repository's build to allow for the flexibility of using any changelog generator for your releases, including a human 👩‍💻

name: Main

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master
      - name: Generate Changelog
        run: echo "# Good things have arrived" > ${{ github.workflow }}-CHANGELOG.txt
      - name: Release
        uses: softprops/action-gh-release
        if: startsWith(github.ref, 'refs/tags/')
        with:
          body_path: ${{ github.workflow }}-CHANGELOG.txt
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

💅 Customizing

inputs

The following are optional as step.with keys

Name Type Description
body String Text communicating notable changes in this release
body_path String Path to load text communicating notable changes in this release
draft Boolean Indicator of whether or not this release is a draft
files String Comma-delimited globs of paths to assets to upload for release
name String Name of the release. defaults to tag name

💡When providing a body and body_path at the same time, body_path will be attempted first, then falling back on body if the path can not be read from.

environment variables

The following are required as step.env keys

Name Description
GITHUB_TOKEN GITHUB_TOKEN as provided by secrets

Doug Tangren (softprops) 2019