Update generate-and-release.yaml #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Increment artifactVersion | |
run: | | |
current_version=$(xmlstarlet sel -t -v "//*[local-name()='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 "//*[local-name()='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 |