From 1d9659b6df0d63ed17432e677ee77a4c17d2f2f3 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Sun, 29 Jun 2025 14:09:24 +0200 Subject: [PATCH] feat(action): add support for non-main branch releases - Introduce an input to allow releases from non-main branches - Update logic to conditionally permit version checks outside 'main' --- action.yml | 5 +++++ scripts/detect-version-change.sh | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index eb764cc..989f0c5 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: description: "Commit-Autore-Mail" required: false default: "" + allow-non-main-release: + description: "Allow publishing releases from branches other than 'main'." + required: false + default: "false" runs: using: "composite" @@ -25,6 +29,7 @@ runs: GITHUB_EVENT_BEFORE: ${{ github.event.before || '' }} GITHUB_SHA: ${{ github.sha || '' }} GITHUB_REF: ${{ github.ref || '' }} + ALLOW_NON_MAIN_RELEASE: ${{ inputs.allow-non-main-release }} run: | ${{ github.action_path }}/scripts/detect-version-change.sh diff --git a/scripts/detect-version-change.sh b/scripts/detect-version-change.sh index 479aea4..8e0d178 100755 --- a/scripts/detect-version-change.sh +++ b/scripts/detect-version-change.sh @@ -6,14 +6,17 @@ GIT_REF="${GITHUB_REF:-}" COMMIT_BEFORE="${GITHUB_EVENT_BEFORE:-}" COMMIT_AFTER="${GITHUB_SHA:-}" VERSION_FILE="VERSION" +ALLOW_NON_MAIN_RELEASE="${ALLOW_NON_MAIN_RELEASE:-false}" echo "🔍 Comparing commits:" echo "Before: $COMMIT_BEFORE" echo "After: $COMMIT_AFTER" +echo "Ref: $GIT_REF" +echo "Allow release from non-main branches: $ALLOW_NON_MAIN_RELEASE" # Check branch condition -if [[ "$GIT_REF" != "refs/heads/main" ]]; then - echo "Not on 'main' branch – skipping version check." +if [[ "$ALLOW_NON_MAIN_RELEASE" != "true" && "$GIT_REF" != "refs/heads/main" ]]; then + echo "🚫 Not on 'main' branch and non-main releases are disabled – skipping version check." echo "version_changed=false" >> "$GITHUB_OUTPUT" exit 0 fi