From ea196c959cca311328d6ca02fb155f540d28c726 Mon Sep 17 00:00:00 2001 From: Ririsoft Date: Sat, 19 Jun 2021 17:50:27 +0200 Subject: [PATCH] add draft option Add 'draft' input option to create GH release as draft. --- README.md | 3 +++ action.yml | 4 ++++ main.sh | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3b4fce..37fe14e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 }} diff --git a/action.yml b/action.yml index e63132c..d851dd6 100644 --- a/action.yml +++ b/action.yml @@ -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 ('0' or '1') + required: false + default: '0' runs: using: node12 diff --git a/main.sh b/main.sh index f2ccdb3..b49fe85 100755 --- a/main.sh +++ b/main.sh @@ -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" @@ -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:-}"