2019-08-26 04:59:00 +00:00
2019-08-25 06:14:36 +00:00
# action gh-release [![](https://github.com/softprops/action-gh-release/workflows/Main/badge.svg)](https://github.com/softprops/action-gh-release/actions)
2019-09-09 12:50:33 +00:00
> A GitHub Action for creating GitHub Releases on Linux, Windows, and OSX virtual environments
2019-08-25 06:13:05 +00:00
2019-09-11 10:22:30 +00:00
![Screenshot ](demo.png )
2019-08-28 02:26:08 +00:00
> **⚠️ Note:** To use this action, you must have access to the [GitHub Actions](https://github.com/features/actions) feature. GitHub Actions are currently only available in public beta. You can [apply for the GitHub Actions beta here](https://github.com/features/actions/signup/).
2019-08-25 06:17:36 +00:00
2019-09-09 12:32:05 +00:00
> **⚠️ Note:** This action was previously implemented as a docker container, limiting its use to GitHub Actions Linux virtual environments only. With recent releases, we now support cross platform usage. You'll need to remove the `docker://` prefix in these versions
2019-08-26 04:59:00 +00:00
## 🤸 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
```yaml
name: Main
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Release
2019-09-09 12:35:52 +00:00
uses: softprops/action-gh-release@v1
2019-08-26 04:59:00 +00:00
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
2019-09-09 08:36:46 +00:00
You can also use push config tag filter
```yaml
name: Main
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Release
2019-09-09 12:35:52 +00:00
uses: softprops/action-gh-release@v1
2019-09-09 08:36:46 +00:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
2019-08-26 04:59:00 +00:00
### ⬆️ Uploading release assets
You can can configure a number of options for your
2019-08-28 02:26:08 +00:00
GitHub release and all are optional.
2019-08-26 04:59:00 +00:00
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.
2019-08-25 19:24:49 +00:00
2019-08-26 05:26:13 +00:00
Below is an example of uploading a single asset named `Release.txt`
2019-08-25 19:24:49 +00:00
```yaml
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
2019-08-26 04:59:00 +00:00
- name: Test
run: cat Release.txt
2019-08-25 19:24:49 +00:00
- name: Release
2019-09-09 12:35:52 +00:00
uses: softprops/action-gh-release@v1
2019-08-25 22:37:27 +00:00
if: startsWith(github.ref, 'refs/tags/')
2019-08-25 19:25:36 +00:00
with:
files: Release.txt
2019-08-25 19:24:49 +00:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
2019-08-26 05:00:01 +00:00
2019-08-26 05:26:13 +00:00
### 📝 External release notes
Many systems exist that can help generate release notes for you. This action supports
2019-08-28 02:26:08 +00:00
loading release notes from a path in your repository's build to allow for the flexibility
2019-08-26 05:26:13 +00:00
of using any changelog generator for your releases, including a human 👩💻
```yaml
name: Main
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
2019-09-06 02:30:21 +00:00
- name: Generate Changelog
2019-08-26 05:26:13 +00:00
run: echo "# Good things have arrived" > ${{ github.workflow }}-CHANGELOG.txt
- name: Release
2019-09-09 12:35:52 +00:00
uses: softprops/action-gh-release@v1
2019-08-26 05:26:13 +00:00
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{ github.workflow }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
2019-08-26 04:59:00 +00:00
### 💅 Customizing
2019-08-25 19:24:49 +00:00
2019-08-26 05:00:01 +00:00
#### inputs
2019-08-26 02:32:14 +00:00
2019-08-26 04:59:00 +00:00
The following are optional as `step.with` keys
2019-08-26 05:26:13 +00:00
| 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.
2019-08-26 02:32:14 +00:00
2019-08-26 05:00:01 +00:00
#### environment variables
2019-08-26 02:32:14 +00:00
2019-08-26 04:59:00 +00:00
The following are *required* as `step.env` keys
2019-08-26 02:32:14 +00:00
| Name | Description |
|----------------|--------------------------------------|
| `GITHUB_TOKEN` | GITHUB_TOKEN as provided by `secrets` |
2019-09-06 02:30:21 +00:00
Doug Tangren (softprops) 2019