Skip to content

Commit 1f6989a

Browse files
committed
Refine version bump logic to apply changes only if Python files are modified, defaulting to patch bump otherwise
1 parent d455f42 commit 1f6989a

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,34 @@ jobs:
5858
run: |
5959
VERSION_INCREMENT="${{ steps.gitversion.outputs.MajorMinorPatch }}"
6060
TAG="${{ steps.gitversion.outputs.PreReleaseLabel }}"
61-
61+
6262
# Default bump type
6363
BUMP_TYPE="patch"
6464
65-
# Determine bump type based on GitVersion's calculated version
66-
if [[ "$VERSION_INCREMENT" =~ ^[1-9][0-9]*\.0\.0$ ]]; then
67-
BUMP_TYPE="major"
68-
elif [[ "$VERSION_INCREMENT" =~ ^[0-9]+\.[1-9][0-9]*\.0$ ]]; then
69-
BUMP_TYPE="minor"
70-
elif [[ "$VERSION_INCREMENT" =~ ^[0-9]+\.[0-9]+\.[1-9][0-9]*$ ]]; then
71-
BUMP_TYPE="patch"
72-
fi
73-
74-
# Handle pre-release versions
75-
if [[ -n "$TAG" ]]; then
76-
BUMP_TYPE="pre${BUMP_TYPE}"
65+
# If Python files changed → apply version logic
66+
if [[ "${{ env.python_changed }}" == "true" ]]; then
67+
if [[ "$VERSION_INCREMENT" =~ ^[1-9][0-9]*\.0\.0$ ]]; then
68+
BUMP_TYPE="major"
69+
elif [[ "$VERSION_INCREMENT" =~ ^[0-9]+\.[1-9][0-9]*\.0$ ]]; then
70+
BUMP_TYPE="minor"
71+
elif [[ "$VERSION_INCREMENT" =~ ^[0-9]+\.[0-9]+\.[1-9][0-9]*$ ]]; then
72+
BUMP_TYPE="patch"
73+
fi
74+
75+
# Handle pre-release versions
76+
if [[ -n "$TAG" ]]; then
77+
BUMP_TYPE="pre${BUMP_TYPE}"
78+
fi
79+
else
80+
echo "No Python files changed → forcing patch bump."
7781
fi
7882
7983
echo "Version bump detected: $BUMP_TYPE"
8084
echo "bump_type=$BUMP_TYPE" >> $GITHUB_ENV
8185
8286
8387
88+
8489
- name: Update CHANGELOG.md
8590
if: github.ref == 'refs/heads/main' # Only update for stable releases
8691
uses: release-flow/keep-a-changelog-action@v3.0.0

0 commit comments

Comments
 (0)