Skip to content

Update increment-version.yaml #3

Update increment-version.yaml

Update increment-version.yaml #3

name: Increment Version in pom.xml
on:
push:
branches:
- test-workflow
workflow_dispatch:
schedule:
- cron: '0 * * * *' # At :00 every hour
jobs:
increment-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install xmlstarlet
run: sudo apt-get update && sudo apt-get install -y xmlstarlet
- name: Print pom.xml
run: cat pom.xml
- name: Increment artifactVersion
run: |
set -e
current_version=$(xmlstarlet sel -t -v "//artifactVersion" pom.xml)
echo "Current version: $current_version"
IFS='.-' read -r -a parts <<< "$current_version"
new_patch=$((parts[2] + 1))
new_version="${parts[0]}.${parts[1]}.$new_patch-${parts[3]}"
echo "New version: $new_version"
xmlstarlet ed --inplace --update "//artifactVersion" --value "$new_version" pom.xml
echo "Updated version to $new_version"
- name: Commit changes
run: |
git config user.name "Automated"
git config user.email "[email protected]"
git add pom.xml
git commit -m "Increment version to ${new_version}"
git push origin test-workflow