@@ -2,6 +2,12 @@ name: Release to Main
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ dry_run :
7+ description : ' Dry run (merge but do not push)'
8+ required : false
9+ default : ' false'
10+ type : boolean
511
612jobs :
713 merge-to-main :
@@ -13,10 +19,47 @@ jobs:
1319 fetch-depth : 0
1420 token : ${{ secrets.GITHUB_TOKEN }}
1521
22+ - name : Extract main branch version
23+ id : main-version
24+ run : |
25+ git checkout main
26+ MAIN_VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
27+ MAIN_PARENT_VERSION=$(grep -A1 'infinispan-build-configuration-parent' pom.xml | grep '<version>' | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
28+ echo "project=$MAIN_VERSION" >> $GITHUB_OUTPUT
29+ echo "parent=$MAIN_PARENT_VERSION" >> $GITHUB_OUTPUT
30+ echo "Main project version: $MAIN_VERSION"
31+ echo "Main parent version: $MAIN_PARENT_VERSION"
32+
1633 - name : Merge development into main
1734 run : |
1835 git config user.name "github-actions[bot]"
1936 git config user.email "github-actions[bot]@users.noreply.github.com"
2037 git checkout main
2138 git merge origin/development -m "Release: merge development into main"
22- git push origin main
39+
40+ - name : Restore main branch versions
41+ run : |
42+ MAIN_VERSION="${{ steps.main-version.outputs.project }}"
43+ MAIN_PARENT_VERSION="${{ steps.main-version.outputs.parent }}"
44+ DEV_VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
45+ DEV_PARENT_VERSION=$(grep -A1 'infinispan-build-configuration-parent' pom.xml | grep '<version>' | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
46+
47+ echo "Replacing project version: $DEV_VERSION -> $MAIN_VERSION"
48+ echo "Replacing parent version: $DEV_PARENT_VERSION -> $MAIN_PARENT_VERSION"
49+
50+ # Replace SNAPSHOT versions with main versions in all pom.xml files
51+ find . -name "pom.xml" -not -path "./.git/*" -exec sed -i "s|$DEV_VERSION|$MAIN_VERSION|g" {} +
52+ find . -name "pom.xml" -not -path "./.git/*" -exec sed -i "s|$DEV_PARENT_VERSION|$MAIN_PARENT_VERSION|g" {} +
53+
54+ git add -A
55+ git diff --cached --quiet || git commit -m "chore: restore main branch versions ($MAIN_VERSION)"
56+
57+ - name : Push to main
58+ if : ${{ inputs.dry_run != 'true' }}
59+ run : git push origin main
60+
61+ - name : Dry run summary
62+ if : ${{ inputs.dry_run == 'true' }}
63+ run : |
64+ echo "DRY RUN - not pushing. Merge result:"
65+ git log --oneline -5
0 commit comments