Skip to content

Commit

Permalink
Add ref input option
Browse files Browse the repository at this point in the history
Co-authored-by: kirrg001 <[email protected]>
  • Loading branch information
taiki-e and kirrg001 committed Sep 8, 2022
1 parent 1b162d4 commit 7baad32
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

- Add `token` input option to use the specified token instead of `GITHUB_TOKEN` environment variable.

- Add `ref` input option to use the specified tag ref instead of `GITHUB_REF` environment variable.

- Update `parse-changelog` to 0.5.1. This includes a bug fix and performance improvements.

## [1.5.0] - 2022-02-17
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Currently, changelog format and supported tag names have the following rule:
| draft | false | Create a draft release (`true` or `false`) | Boolean | `false` |
| branch | false | Reject releases from commits not contained in branches that match the specified pattern (regular expression) | String | |
| prefix | false | An optional pattern that matches a prefix for the release tag, before the version number (see [action.yml](action.yml) for more) | String | |
| ref | false | Fully-formed tag ref for this release (see [action.yml](action.yml) for more) | String | |

[^1]: Required one of `token` input option or `GITHUB_TOKEN` environment variable.

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ inputs:
If not set this option, the GITHUB_TOKEN environment variable will be used.
required: false
ref:
description: >
Fully-formed tag ref for this release.
If not set this option, the GITHUB_REF environment variable (automatically set by GitHub Actions) will be used.
required: false

outputs:
computed-prefix:
Expand Down
7 changes: 4 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ draft="${INPUT_DRAFT:-}"
branch="${INPUT_BRANCH:-}"
prefix="${INPUT_PREFIX:-}"
token="${INPUT_TOKEN:-"${GITHUB_TOKEN:-}"}"
ref="${INPUT_REF:-"${GITHUB_REF:-}"}"

if [[ -z "${token:-}" ]]; then
bail "neither GITHUB_TOKEN environment variable nor 'token' input option is set."
fi

if [[ "${GITHUB_REF:?}" != "refs/tags/"* ]]; then
bail "this action can only be used on 'push' event for 'tags' (GITHUB_REF should start with 'refs/tags/': '${GITHUB_REF}')"
if [[ "${ref:?}" != "refs/tags/"* ]]; then
bail "tag ref should start with 'refs/tags/': '${ref}'"
fi
tag="${GITHUB_REF#refs/tags/}"
tag="${ref#refs/tags/}"

release_options=("${tag}")
parse_changelog_options=()
Expand Down

0 comments on commit 7baad32

Please sign in to comment.