44 push :
55 branches :
66 - main
7+ - ' feature/**'
8+ - ' bugfix/**'
79
810jobs :
911 build :
1315 - uses : actions/checkout@v4
1416 with :
1517 fetch-depth : 2
18+ - name : Set version based on branch
19+ id : version
20+ run : |
21+ BASE_VERSION=$(grep version gradle.properties | cut -d= -f2)
22+ COMMIT_HASH=$(git rev-parse --short HEAD)
23+
24+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
25+ VERSION="$BASE_VERSION"
26+ else
27+ VERSION="$BASE_VERSION-$COMMIT_HASH"
28+ fi
29+
30+ echo "VERSION=$VERSION" >> $GITHUB_ENV
31+ echo "version=$VERSION" >> $GITHUB_OUTPUT
32+ echo "Building version: $VERSION"
1633 - uses : actions/setup-java@v4
1734 with :
1835 java-version : ' 17'
2744 - name : Build and push images
2845 run : bash docker-action.sh
2946 env :
47+ VERSION : ${{ env.VERSION }}
48+ GITHUB_REF : ${{ github.ref }}
3049 PACKAGE_TOKEN : ${{ secrets.PACKAGE_TOKEN }}
3150 MAVEN_USERNAME : ${{ secrets.MAVEN_USERNAME }}
3251 MAVEN_PASSWORD : ${{ secrets.MAVEN_PASSWORD }}
5877 with :
5978 fetch-depth : 2
6079 - name : Set version
61- run : echo "APP_VERSION=$(grep version gradle.properties | cut -d= -f2)" >> $GITHUB_ENV
80+ run : |
81+ BASE_VERSION=$(grep version gradle.properties | cut -d= -f2)
82+ COMMIT_HASH=$(git rev-parse --short HEAD)
83+
84+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
85+ APP_VERSION="$BASE_VERSION"
86+ else
87+ APP_VERSION="$BASE_VERSION-$COMMIT_HASH"
88+ fi
89+
90+ echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
91+ echo "Building version: $APP_VERSION"
6292 - uses : actions/setup-java@v4
6393 with :
6494 java-version : ' 21'
@@ -90,7 +120,18 @@ jobs:
90120 with :
91121 fetch-depth : 2
92122 - name : Set version
93- run : echo "APP_VERSION=$(grep version gradle.properties | cut -d= -f2)" >> $env:GITHUB_ENV
123+ run : |
124+ $BASE_VERSION = (Get-Content gradle.properties | Select-String '^version=' | ForEach-Object { $_ -replace 'version=','' }).Trim()
125+ $COMMIT_HASH = git rev-parse --short HEAD
126+
127+ if ("${{ github.ref }}" -eq "refs/heads/main") {
128+ $APP_VERSION = $BASE_VERSION
129+ } else {
130+ $APP_VERSION = "$BASE_VERSION-$COMMIT_HASH"
131+ }
132+
133+ echo "APP_VERSION=$APP_VERSION" >> $env:GITHUB_ENV
134+ Write-Output "Building version: $APP_VERSION"
94135 - uses : actions/setup-java@v4
95136 with :
96137 java-version : ' 21'
@@ -115,23 +156,25 @@ jobs:
115156
116157 linux-amd64 :
117158 needs : build
118- strategy :
119- matrix :
120- include :
121- - runner : ubuntu-latest
122- arch : x64
123- arch_name : amd64
124- - runner : ubuntu-latest
125- arch : aarch64
126- arch_name : arm64
127- runs-on : ${{ matrix.runner }}
159+ runs-on : [ubuntu-latest]
128160
129161 steps :
130162 - uses : actions/checkout@v4
131163 with :
132164 fetch-depth : 2
133165 - name : Set version
134- run : echo "APP_VERSION=$(grep version gradle.properties | cut -d= -f2)" >> $GITHUB_ENV
166+ run : |
167+ BASE_VERSION=$(grep version gradle.properties | cut -d= -f2)
168+ COMMIT_HASH=$(git rev-parse --short HEAD)
169+
170+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
171+ APP_VERSION="$BASE_VERSION"
172+ else
173+ APP_VERSION="$BASE_VERSION-$COMMIT_HASH"
174+ fi
175+
176+ echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
177+ echo "Building version: $APP_VERSION"
135178 - uses : actions/setup-java@v4
136179 with :
137180 java-version : ' 21'
@@ -173,7 +216,18 @@ jobs:
173216 with :
174217 fetch-depth : 2
175218 - name : Set version
176- run : echo "APP_VERSION=$(grep version gradle.properties | cut -d= -f2)" >> $GITHUB_ENV
219+ run : |
220+ BASE_VERSION=$(grep version gradle.properties | cut -d= -f2)
221+ COMMIT_HASH=$(git rev-parse --short HEAD)
222+
223+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
224+ APP_VERSION="$BASE_VERSION"
225+ else
226+ APP_VERSION="$BASE_VERSION-$COMMIT_HASH"
227+ fi
228+
229+ echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
230+ echo "Building version: $APP_VERSION"
177231 - name : Set up QEMU
178232 uses : docker/setup-qemu-action@v3
179233 with :
0 commit comments