Skip to content

Commit

Permalink
add draft option
Browse files Browse the repository at this point in the history
Add 'draft' input option to create GH release as draft.
  • Loading branch information
ririsoft authored and taiki-e committed Jun 23, 2021
1 parent 7347627 commit 7bb073a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Currently, changelog format and supported tag names have the following rule:
|-----------|:--------:|----------------------------------------------------------------|--------|---------|
| changelog | false | Path to changelog | String | |
| title | false | Format of title (variables `$tag`, `$version`, and any string) | String | `$tag` |
| draft | false | Create a draft release ('true' or 'false') | String | `false` |

### Example workflow: Basic usage

Expand All @@ -58,6 +59,8 @@ jobs:
with:
# (optional) Path to changelog.
changelog: CHANGELOG.md
# (optional) Create a draft release.
draft: true
env:
# (required) GitHub token for creating GitHub Releases.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: Format of title (variables `$tag`, `$version`, and any string)
required: false
default: '$tag'
draft:
description: Create a draft release ('true' or 'false')
required: false
default: 'false'

runs:
using: node12
Expand Down
10 changes: 9 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parse_changelog_tag="v0.3.0"

title="${INPUT_TITLE:?}"
changelog="${INPUT_CHANGELOG:-}"
draft="${INPUT_DRAFT:-}"

if [[ -z "${GITHUB_TOKEN:-}" ]]; then
error "GITHUB_TOKEN not set"
Expand Down Expand Up @@ -62,5 +63,12 @@ if gh release view "${tag}" &>/dev/null; then
# https://cli.github.com/manual/gh_release_delete
gh release delete "${tag}" -y
fi

gh_options=""

if [[ "$draft" == "true" ]]; then
gh_options="--draft"
fi

# https://cli.github.com/manual/gh_release_create
gh release create "${tag}" ${prerelease:-} --title "${title}" --notes "${notes:-}"
gh release create ${gh_options} "${tag}" ${prerelease:-} --title "${title}" --notes "${notes:-}"

0 comments on commit 7bb073a

Please sign in to comment.