77 types :
88 - closed
99
10+ permissions :
11+ contents : write
12+
1013jobs :
1114 tag-version :
1215 if : github.event.pull_request.merged == true
13- runs-on : ubuntu-latest
16+ runs-on :
17+ group : databricks-solutions-protected-runner-group
1418
1519 steps :
1620 - name : Checkout repo
1721 uses : actions/checkout@v4
1822 with :
19- fetch-depth : 0 # So tags are available
23+ ref : main
24+ fetch-depth : 0
2025
21- - name : Get latest tag
22- id : get_tag
26+ - name : Read current version
27+ id : current
2328 run : |
24- LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
25- echo "LAST_TAG=$LAST_TAG"
26- echo "last_tag=$LAST_TAG" >> $GITHUB_OUTPUT
29+ VERSION=$(cat VERSION | tr -d '[:space:]')
30+ VERSION=${VERSION#v}
31+ IFS='.' read -r MAJOR MINOR FIX <<< "$VERSION"
32+ echo "major=$MAJOR" >> $GITHUB_OUTPUT
33+ echo "minor=$MINOR" >> $GITHUB_OUTPUT
34+ echo "fix=$FIX" >> $GITHUB_OUTPUT
35+ echo "Current version: $MAJOR.$MINOR.$FIX"
2736
28- - name : Compute next version
37+ - name : Determine version bump from branch name
2938 id : bump
3039 run : |
31- OLD=${{ steps.get_tag.outputs.last_tag }}
32- VERS=${OLD#v}
33- IFS='.' read -r MAJOR MINOR PATCH <<< "$VERS"
34- PATCH=$((PATCH + 1))
35- NEW="v$MAJOR.$MINOR.$PATCH"
36- echo "NEW_VERSION=$NEW"
37- echo "new_version=$NEW" >> $GITHUB_OUTPUT
38-
39- - name : Fail if version is not incremented
40- run : |
41- if [ "${{ steps.get_tag.outputs.last_tag }}" = "${{ steps.bump.outputs.new_version }}" ]; then
42- echo "❌ Version not incremented. Current tag (${{ steps.get_tag.outputs.last_tag }}) is the same as the new tag."
43- exit 1
40+ BRANCH="${{ github.event.pull_request.head.ref || github.ref_name }}"
41+ BRANCH_LOWER=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')
42+ echo "Merged branch: $BRANCH (normalized: $BRANCH_LOWER)"
43+
44+ MAJOR=${{ steps.current.outputs.major }}
45+ MINOR=${{ steps.current.outputs.minor }}
46+ FIX=${{ steps.current.outputs.fix }}
47+
48+ if [[ "$BRANCH_LOWER" == feature* ]]; then
49+ MINOR=$((MINOR + 1))
50+ FIX=0
51+ echo "Feature branch — bumping minor, resetting fix to 0"
52+ elif [[ "$BRANCH_LOWER" == fix* ]]; then
53+ FIX=$((FIX + 1))
54+ echo "Fix branch — bumping fix"
55+ else
56+ echo "::warning::Branch '$BRANCH' does not start with 'feature' or 'fix'. Skipping version bump."
57+ echo "skip=true" >> $GITHUB_OUTPUT
58+ exit 0
4459 fi
4560
61+ NEW_VERSION="$MAJOR.$MINOR.$FIX"
62+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
63+ echo "New version: $NEW_VERSION"
64+
4665 - name : Write VERSION file
66+ if : steps.bump.outputs.skip != 'true'
4767 run : |
48- echo "${{ steps.bump.outputs.new_version }}" | sed 's/^v//' > VERSION
68+ echo "v ${{ steps.bump.outputs.new_version }}" > VERSION
4969 cat VERSION
5070
51- - name : Tag and push
71+ - name : Commit, tag, and push
72+ if : steps.bump.outputs.skip != 'true'
5273 env :
53- TAG : ${{ steps.bump.outputs.new_version }}
74+ NEW_VERSION : ${{ steps.bump.outputs.new_version }}
5475 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5576 run : |
5677 git config user.name "github-actions"
5778 git config user.email "github-actions@github.com"
58- git tag $TAG
59- git push origin $TAG
79+ git add VERSION
80+ git commit -m "Bump version to $NEW_VERSION"
81+ git tag "v$NEW_VERSION"
82+ git push origin HEAD --tags
0 commit comments