Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/gitflow-next-snapshot-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Update Develop to SNAPSHOT Version

on:
push:
tags:
- 'v*' # Trigger only when release tags v* are pushed (e.g., v1.2.0)

jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write # Needed to push to develop branch

steps:
- name: Checkout develop branch
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Get release tag version
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
with_v: false # Returns version without 'v' prefix

- name: Calculate next SNAPSHOT version
id: version_calc
run: |
# Parse the version components (1.2.0 → 1.2.1-SNAPSHOT)
IFS='.' read -ra VERSION_PARTS <<< "${{ steps.tag_version.outputs.new_version }}"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}

# Increment patch version by convention
NEXT_PATCH=$((PATCH + 1))
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-SNAPSHOT"

echo "Next version: $NEXT_VERSION"
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT

- name: Update POM version
run: |
mvn versions:set -DnewVersion=${{ steps.version_calc.outputs.NEXT_VERSION }}
mvn versions:commit # Clean up backup files

- name: Commit and push version update
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add pom.xml
git commit -m "Update to ${{ steps.version_calc.outputs.NEXT_VERSION }} [skip ci]"
git pull --rebase # Handle potential concurrent changes
git push origin develop

- name: Verify the update
run: |
echo "Version updated to:"
mvn help:evaluate -Dexpression=project.version -q -DforceStdout
Loading