Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add draft option #4

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:-}"