From 38e88d5367eddba1a25f5f7c4056b0a9601ff3c9 Mon Sep 17 00:00:00 2001 From: Davidson Bruno Date: Mon, 29 Apr 2024 17:07:11 -0300 Subject: [PATCH] feat: added releases parameter --- .../workflows/create-pre-release-template.yml | 5 +++++ .github/workflows/create-pre-release.yml | 1 + actions/release-versioning/action.yml | 4 ++++ .../release-versioning/release-versioning.sh | 17 ++++++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-pre-release-template.yml b/.github/workflows/create-pre-release-template.yml index b48746b..3258a12 100644 --- a/.github/workflows/create-pre-release-template.yml +++ b/.github/workflows/create-pre-release-template.yml @@ -9,6 +9,9 @@ on: feature_branches: required: false type: string + release_branches: + required: false + type: string hotfix_branches: required: false type: string @@ -85,6 +88,7 @@ jobs: commit_message: ${{ needs.check_major_change.outputs.commit_message }} last_version: ${{ needs.get_last_version.outputs.last_version }} feature_branches: ${{ inputs.feature_branches }} + release_branches: ${{ inputs.release_branches }} hotfix_branches: ${{ inputs.hotfix_branches }} if: ${{ needs.check_major_change.outputs.is_major_change == 'true' }} @@ -107,6 +111,7 @@ jobs: base_commit: ${{ github.event.pull_request.base.sha }} last_version: ${{ needs.get_last_version.outputs.last_version }} feature_branches: ${{ inputs.feature_branches }} + release_branches: ${{ inputs.release_branches }} hotfix_branches: ${{ inputs.hotfix_branches }} if: | always() && !failure() && !cancelled() && diff --git a/.github/workflows/create-pre-release.yml b/.github/workflows/create-pre-release.yml index cac35b3..0ac821b 100644 --- a/.github/workflows/create-pre-release.yml +++ b/.github/workflows/create-pre-release.yml @@ -12,6 +12,7 @@ jobs: with: main_branch: "main" feature_branches: "feature" + release_branches: "release" hotfix_branches: "hotfix" permissions: contents: write diff --git a/actions/release-versioning/action.yml b/actions/release-versioning/action.yml index 07f361f..7228024 100644 --- a/actions/release-versioning/action.yml +++ b/actions/release-versioning/action.yml @@ -19,6 +19,9 @@ inputs: feature_branches: description: "Allowed feature branch names" required: false + release_branches: + description: "Allowed release branch names" + required: false hotfix_branches: description: "Allowed hotfix branch names" required: false @@ -46,6 +49,7 @@ runs: COMMIT_MESSAGE: ${{ inputs.commit_message }} ORIGIN_BRANCH: ${{ inputs.origin_branch }} FEATURE_BRANCHES: ${{ inputs.feature_branches }} + RELEASE_BRANCHES: ${{ inputs.release_branches }} HOTFIX_BRANCHES: ${{ inputs.hotfix_branches }} HEAD_COMMIT: ${{ inputs.head_commit }} BASE_COMMIT: ${{ inputs.base_commit }} diff --git a/actions/release-versioning/release-versioning.sh b/actions/release-versioning/release-versioning.sh index b372da9..42651c3 100755 --- a/actions/release-versioning/release-versioning.sh +++ b/actions/release-versioning/release-versioning.sh @@ -111,6 +111,13 @@ else feature_branches=($FEATURE_BRANCHES) fi +if [[ -z "$RELEASE_BRANCHES" ]]; then + release_branches=("release") + echo "Release branch names not found. Using default value: release." +else + release_branches=($RELEASE_BRANCHES) +fi + if [[ -z "$HOTFIX_BRANCHES" ]]; then hotfix_branches=("hotfix") echo "Hotfix branch names not found. Using default value: hotfix." @@ -126,6 +133,14 @@ for i in "${feature_branches[@]}"; do fi done +for i in "${release_branches[@]}"; do + if [[ "$ORIGIN_BRANCH" == "$i/"* ]]; then + is_release_branch=true + echo "$ORIGIN_BRANCH is a release branch." + break + fi +done + for i in "${hotfix_branches[@]}"; do if [[ "$ORIGIN_BRANCH" == "$i/"* ]]; then is_hotfix_branch=true @@ -135,7 +150,7 @@ for i in "${hotfix_branches[@]}"; do done # Increment the version according to the branch prefix. -if [[ $is_feature_branch == true ]]; then +if [[ $is_feature_branch == true || $is_release_branch == true ]]; then minor_version=$((minor_version + 1)) patch_version=0 elif [[ $is_hotfix_branch == true ]]; then