Skip to content

Commit 7d4881b

Browse files
Feature/update version release workflow
2 parents d42b2c4 + 13d4595 commit 7d4881b

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

.github/workflows/release.yaml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Workflow: Release and publish artifacts to Maven Central
22
# Purpose: Builds, signs, and publishes Maven artifacts to Sonatype OSSRH, then tags the released version.
33
# Prerequisites: pom.xml must be on a *-SNAPSHOT version; We need to change logic for non-SNAPSHOT versions.
4-
# Notes: Adjust version computation logic if patch releases are desired instead of minor bumps (e.g., 1.2.3-SNAPSHOT to 1.3.0-SNAPSHOT).
4+
# Notes:
5+
# - release/* branches: major version increment (e.g., 1.2.3-SNAPSHOT to 2.0.0-SNAPSHOT)
6+
# - hotfix/* branches: minor version increment (e.g., 1.2.3-SNAPSHOT to 1.3.0-SNAPSHOT)
7+
# Adjust version computation logic if patch releases are desired instead of minor bumps (e.g., 1.2.3-SNAPSHOT to 1.3.0-SNAPSHOT).
58

69
name: "Release and publish artifacts to Maven Central"
710

@@ -17,6 +20,7 @@ on:
1720
push:
1821
branches:
1922
- 'release/*'
23+
- 'hotfix/*'
2024

2125
permissions:
2226
contents: write
@@ -29,13 +33,11 @@ jobs:
2933
steps:
3034
- name: Checkout repo
3135
uses: actions/checkout@v4
32-
#added with option due to runner checking out a detached HEAD state in prepare step
33-
#TODO: need to check if its happening as workflow is triggered from PR or even with workflow dispatch in main branch
3436
with:
35-
token: ${{ secrets.GITHUB_TOKEN }} # or use default GITHUB_TOKEN
36-
persist-credentials: true # allow git push from the job
37-
fetch-depth: 0 # full history so branch refs exist
38-
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} # checkout the branch (not a detached SHA)
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
persist-credentials: true
39+
fetch-depth: 0
40+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
3941

4042
- name: Set up JDK
4143
uses: actions/setup-java@v4
@@ -70,12 +72,29 @@ jobs:
7072
TAG="v${releaseVersion}"
7173
echo "TAG=$TAG" >> $GITHUB_ENV
7274
75+
# Extract branch name
76+
BRANCH_NAME="${{ github.ref_name }}"
77+
echo "Branch name: $BRANCH_NAME"
78+
7379
# Extract numeric components for computing next development version
7480
n=${releaseVersion//[!0-9]/ }
7581
a=(${n//\./ })
76-
nextMinor=$((${a[1]} + 1))
77-
developmentVersion="${a[0]}.${nextMinor}.0-SNAPSHOT"
78-
echo "DEVELOPMENT_VERSION=${developmentVersion}" >> $GITHUB_ENV
82+
83+
# Determine version increment based on branch name
84+
if [[ "$BRANCH_NAME" == release/* ]]; then
85+
# Major version increment for release branches
86+
nextMajor=$((${a[0]} + 1))
87+
developmentVersion="${nextMajor}.0.0-SNAPSHOT"
88+
echo "Branch type: Release - Incrementing major version: ${releaseVersion} → ${developmentVersion}"
89+
elif [[ "$BRANCH_NAME" == hotfix/* ]]; then
90+
# Minor version increment for hotfix branches
91+
currentMajor=${a[0]}
92+
nextMinor=$((${a[1]} + 1))
93+
developmentVersion="${currentMajor}.${nextMinor}.0-SNAPSHOT"
94+
echo "Branch type: Hotfix - Incrementing minor version: ${releaseVersion} → ${developmentVersion}"
95+
fi
96+
97+
echo "DEVELOPMENT_VERSION=${developmentVersion}" >> $GITHUB_ENV
7998
8099
- name: Configure GitHub authentication for Maven Release Plugin
81100
run: |

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.finos.fluxnova</groupId>
66
<artifactId>fluxnova-release-parent</artifactId>
7-
<version>1.1.0-SNAPSHOT</version>
7+
<version>2.0.0-SNAPSHOT</version>
88
<packaging>pom</packaging>
99
<name>fluxnova - Release Parent Pom</name>
1010

0 commit comments

Comments
 (0)