From 34d3d3b059c097d43ff7f52d4fafd2f7ce36ca97 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 22 Mar 2023 15:22:03 +0100 Subject: [PATCH] Added new input `allow_missing_changelog:boolean` (#23) - Added new input `allow_missing_changelog:boolean` that will allow the build to continue to run even though the targeted version was not found on the changelog file. The default of this input is `false` to stay backwards compatible. --- CHANGELOG.md | 4 ++++ README.md | 1 + action.yml | 7 +++++++ main.sh | 9 ++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 711d709..e0a9b97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +### Added + +- Added new input `allow_missing_changelog:boolean` that will allow the build to continue to run even though the targeted version was not found on the changelog file. The default of this input is `false` to stay backwards compatible. + ## [1.6.3] - 2023-03-19 - Diagnostics improvements. diff --git a/README.md b/README.md index 4bcdf62..6bb0723 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Currently, changelog format and supported tag names have the following rule: |-----------|:------------:|-----------------------------------------------------------------------------|---------|---------| | token | **true** [^1]| GitHub token for creating GitHub Releases (see [action.yml](action.yml) for more) | String | | | changelog | false | Path to changelog (variables `$tag`, `$version`, `$prefix`, and any string) | String | | +| allow_missing_changelog | false | Allows for the build to continue even if the version is not found in the changelog. The default value of the changelog will be an empty string. | Boolean | `false` | | title | false | Format of title (variables `$tag`, `$version`, `$prefix`, and any string) | String | `$tag` | | 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 | | diff --git a/action.yml b/action.yml index 6867054..4f84a65 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,13 @@ inputs: changelog: description: Path to changelog (variables `$tag`, `$version`, `$prefix`, and any string) required: false + allow_missing_changelog: + description: > + If true, it will create the GitHub release with an empty notes for the changelog if the changelog.md file does not + have the appropriate version in it. By default, this action will fail if the version tagged is not found in the + changelog file. + required: false + default: false title: description: Format of title (variables `$tag`, `$version`, `$prefix`, and any string) required: false diff --git a/main.sh b/main.sh index 9bf9480..7217b69 100755 --- a/main.sh +++ b/main.sh @@ -110,7 +110,14 @@ if [[ -n "${changelog}" ]]; then retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://github.com/taiki-e/parse-changelog/releases/download/v${parse_changelog_version}/parse-changelog-${parse_changelog_target}.tar.gz" \ | "${tar}" xzf - parse_changelog_options+=("${changelog}" "${version}") - notes=$(./parse-changelog "${parse_changelog_options[@]}") + + # If allow_missing_changelog is true then default to empty value if version not found + if [[ "${INPUT_ALLOW_MISSING_CHANGELOG}" == "true" ]]; then + notes=$(./parse-changelog "${parse_changelog_options[@]}" || echo "") + else + notes=$(./parse-changelog "${parse_changelog_options[@]}") + fi + rm -f ./parse-changelog fi