diff --git a/presets/conventional-commits.sh b/presets/conventional-commits.sh index f28a77b..c918cde 100755 --- a/presets/conventional-commits.sh +++ b/presets/conventional-commits.sh @@ -13,6 +13,8 @@ RELEASE_SKIP_TYPES=("build" "chore" "docs" "test" "style" "ci" "skip ci") RELEASE_PATCH_TYPES=("fix" "close" "closes" "perf" "revert") # shellcheck disable=2034 RELEASE_MINOR_TYPES=("refactor" "feat") +# shellcheck disable=2034 +RELEASE_MAJOR_TYPES=("BREAKING CHANGE") INCLUDE_SCOPE=("refactor" "perf" "revert") @@ -41,11 +43,6 @@ parse_commit() { description="${BASH_REMATCH[4]}" type="BREAKING CHANGE" - - if ! $MAJOR_UPGRADED; then - MAJOR_UPGRADED=true - RELEASE_BODY+="\n## BREAKING CHANGES\n\n" - fi fi # Extract body @@ -53,13 +50,10 @@ parse_commit() { description="$subject" type="BREAKING CHANGE" + fi - if ! $MAJOR_UPGRADED; then - MAJOR_UPGRADED=true - RELEASE_BODY+="\n## BREAKING CHANGES\n\n" - fi # Handle other type of commits - elif is_valid_commit_type "$type" "${RELEASE_SKIP_TYPES[@]}"; then + if is_valid_commit_type "$type" "${RELEASE_SKIP_TYPES[@]}"; then return 0 elif is_valid_commit_type "$type" "${RELEASE_PATCH_TYPES[@]}"; then if ! $PATCH_UPGRADED; then @@ -71,6 +65,11 @@ parse_commit() { MINOR_UPGRADED=true RELEASE_BODY+="\n## Features\n\n" fi + elif is_valid_commit_type "$type" "${RELEASE_MAJOR_TYPES[@]}"; then + if ! $MAJOR_UPGRADED; then + MAJOR_UPGRADED=true + RELEASE_BODY+="\n## BREAKING CHANGES\n\n" + fi fi RELEASE_BODY+="- " diff --git a/presets/workspace.sh b/presets/workspace.sh index 6327ea1..d6806aa 100644 --- a/presets/workspace.sh +++ b/presets/workspace.sh @@ -13,6 +13,8 @@ RELEASE_SKIP_TYPES=("build" "chore" "docs" "test" "style" "ci" "skip ci") RELEASE_PATCH_TYPES=("fix" "close" "closes" "perf" "revert") # shellcheck disable=2034 RELEASE_MINOR_TYPES=("refactor" "feat") +# shellcheck disable=2034 +RELEASE_MAJOR_TYPES=("BREAKING CHANGE") INCLUDE_SCOPE=("refactor" "perf" "revert") @@ -41,11 +43,6 @@ parse_commit() { description="${BASH_REMATCH[4]}" type="BREAKING CHANGE" - - if ! $MAJOR_UPGRADED; then - MAJOR_UPGRADED=true - RELEASE_BODY+="\n## BREAKING CHANGES\n\n" - fi fi # Early catching non-workspace commits @@ -55,16 +52,13 @@ parse_commit() { # Extract body if [[ "$body" =~ $string_commit_major ]]; then - type="BREAKING CHANGE" - description="$subject" - if ! $MAJOR_UPGRADED; then - MAJOR_UPGRADED=true - RELEASE_BODY+="\n## BREAKING CHANGES\n\n" - fi + type="BREAKING CHANGE" + fi + # Handle other type of commits - elif is_valid_commit_type "$type" "${RELEASE_SKIP_TYPES[@]}"; then + if is_valid_commit_type "$type" "${RELEASE_SKIP_TYPES[@]}"; then return 0 elif is_valid_commit_type "$type" "${RELEASE_PATCH_TYPES[@]}"; then if ! $PATCH_UPGRADED; then @@ -76,6 +70,11 @@ parse_commit() { MINOR_UPGRADED=true RELEASE_BODY+="\n## Features\n\n" fi + elif is_valid_commit_type "$type" "${RELEASE_MAJOR_TYPES[@]}"; then + if ! $MAJOR_UPGRADED; then + MAJOR_UPGRADED=true + RELEASE_BODY+="\n## BREAKING CHANGES\n\n" + fi fi if is_valid_commit_type "$type" "${INCLUDE_SCOPE[@]}"; then