From 7baad324bf8604622a36baf485d48c8e4f473cc0 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 7 Sep 2022 20:18:30 +0900 Subject: [PATCH] Add ref input option Co-authored-by: kirrg001 --- CHANGELOG.md | 2 ++ README.md | 1 + action.yml | 6 ++++++ main.sh | 7 ++++--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba7d447..f1719f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index f1717e2..c769643 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/action.yml b/action.yml index be71260..6867054 100644 --- a/action.yml +++ b/action.yml @@ -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: diff --git a/main.sh b/main.sh index e1f31a5..08a4cbe 100755 --- a/main.sh +++ b/main.sh @@ -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=()