Skip to content

Commit

Permalink
feat: added releases parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsonbrsilva committed Apr 29, 2024
1 parent 3ea5fc7 commit 38e88d5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/create-pre-release-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
feature_branches:
required: false
type: string
release_branches:
required: false
type: string
hotfix_branches:
required: false
type: string
Expand Down Expand Up @@ -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' }}

Expand All @@ -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() &&
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/create-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
with:
main_branch: "main"
feature_branches: "feature"
release_branches: "release"
hotfix_branches: "hotfix"
permissions:
contents: write
4 changes: 4 additions & 0 deletions actions/release-versioning/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
17 changes: 16 additions & 1 deletion actions/release-versioning/release-versioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 38e88d5

Please sign in to comment.