@@ -2,7 +2,10 @@ name: Build docker images
22
33on :
44 push :
5- tags : ["*"]
5+ branches :
6+ - main
7+ - ' feature/**'
8+ - ' bugfix/**'
69
710jobs :
811 build :
1215 - uses : actions/checkout@v4
1316 with :
1417 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"
1533 - uses : actions/setup-java@v4
1634 with :
1735 java-version : ' 17'
2644 - name : Build and push images
2745 run : bash docker-action.sh
2846 env :
47+ VERSION : ${{ env.VERSION }}
48+ GITHUB_REF : ${{ github.ref }}
2949 PACKAGE_TOKEN : ${{ secrets.PACKAGE_TOKEN }}
3050 MAVEN_USERNAME : ${{ secrets.MAVEN_USERNAME }}
3151 MAVEN_PASSWORD : ${{ secrets.MAVEN_PASSWORD }}
@@ -41,19 +61,39 @@ jobs:
4161
4262 osx :
4363 needs : build
44- runs-on : [macos-latest]
64+ strategy :
65+ matrix :
66+ include :
67+ - runner : macos-13 # Intel x64
68+ arch : x64
69+ arch_name : x86_64
70+ - runner : macos-14 # Apple Silicon arm64
71+ arch : aarch64
72+ arch_name : aarch64
73+ runs-on : ${{ matrix.runner }}
4574
4675 steps :
4776 - uses : actions/checkout@v4
4877 with :
4978 fetch-depth : 2
5079 - name : Set version
51- 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"
5292 - uses : actions/setup-java@v4
5393 with :
5494 java-version : ' 21'
5595 java-package : jdk
56- architecture : x64
96+ architecture : ${{ matrix.arch }}
5797 distribution : oracle
5898 - name : Download fat jar
5999 uses : actions/download-artifact@v4
@@ -62,11 +102,13 @@ jobs:
62102 path : app/build/libs/
63103 - name : Package jar as dmg installer
64104 run : ' jpackage --main-jar data-caterer.jar "@misc/jpackage/jpackage.cfg" "@misc/jpackage/jpackage-mac.cfg"'
105+ - name : Rename DMG with version and architecture
106+ run : mv DataCaterer-*.dmg DataCaterer-${{ env.APP_VERSION }}-macos-${{ matrix.arch_name }}.dmg
65107 - name : Upload dmg
66108 uses : actions/upload-artifact@v4
67109 with :
68- name : data-caterer-mac
69- path : " DataCaterer-1.0.0 .dmg"
110+ name : data-caterer-macos-${{ matrix.arch_name }}
111+ path : " DataCaterer-${{ env.APP_VERSION }}-macos-${{ matrix.arch_name }} .dmg"
70112 overwrite : true
71113
72114 windows :
@@ -78,7 +120,18 @@ jobs:
78120 with :
79121 fetch-depth : 2
80122 - name : Set version
81- 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"
82135 - uses : actions/setup-java@v4
83136 with :
84137 java-version : ' 21'
@@ -92,11 +145,13 @@ jobs:
92145 path : app/build/libs/
93146 - name : Package jar as exe
94147 run : ' jpackage --main-jar data-caterer.jar "@misc/jpackage/jpackage.cfg" "@misc/jpackage/jpackage-windows.cfg"'
148+ - name : Rename EXE with version and architecture
149+ run : mv DataCaterer-*.exe DataCaterer-$env:APP_VERSION-windows-x86_64.exe
95150 - name : Upload installer
96151 uses : actions/upload-artifact@v4
97152 with :
98- name : data-caterer-windows
99- path : " DataCaterer-1.0.0 .exe"
153+ name : data-caterer-windows-x86_64
154+ path : " DataCaterer-${{ env.APP_VERSION }}-windows-x86_64 .exe"
100155 overwrite : true
101156
102157 linux-amd64 :
@@ -108,12 +163,23 @@ jobs:
108163 with :
109164 fetch-depth : 2
110165 - name : Set version
111- 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"
112178 - uses : actions/setup-java@v4
113179 with :
114180 java-version : ' 21'
115181 java-package : jdk
116- architecture : x64
182+ architecture : ${{ matrix.arch }}
117183 distribution : oracle
118184 - name : Download fat jar
119185 uses : actions/download-artifact@v4
@@ -122,13 +188,26 @@ jobs:
122188 path : app/build/libs/
123189 - name : Package jar as debian package (amd64)
124190 run : ' jpackage --main-jar data-caterer.jar "@misc/jpackage/jpackage.cfg" "@misc/jpackage/jpackage-linux.cfg"'
125- - name : List directory
126- run : ls -lart
191+ - name : Rename deb with version
192+ run : |
193+ DEB_FILE=$(ls datacaterer_*_amd64.deb 2>/dev/null | head -n 1)
194+ if [ -n "$DEB_FILE" ]; then
195+ echo "Found deb file: $DEB_FILE"
196+ mv "$DEB_FILE" datacaterer_${{ env.APP_VERSION }}_amd64.deb
197+ echo "Renamed to: datacaterer_${{ env.APP_VERSION }}_amd64.deb"
198+ else
199+ echo "No deb file found"
200+ echo "Current directory:"
201+ pwd
202+ echo "Files in current directory:"
203+ ls -lart
204+ exit 1
205+ fi
127206 - name : Upload deb (amd64)
128207 uses : actions/upload-artifact@v4
129208 with :
130209 name : data-caterer-linux-amd64
131- path : " datacaterer_1.0.0_amd64 .deb"
210+ path : " datacaterer_${{ env.APP_VERSION }}_amd64 .deb"
132211 overwrite : true
133212
134213 linux-arm64 :
@@ -140,45 +219,54 @@ jobs:
140219 with :
141220 fetch-depth : 2
142221 - name : Set version
143- run : echo "APP_VERSION=$(grep version gradle.properties | cut -d= -f2)" >> $GITHUB_ENV
222+ run : |
223+ BASE_VERSION=$(grep version gradle.properties | cut -d= -f2)
224+ COMMIT_HASH=$(git rev-parse --short HEAD)
225+
226+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
227+ APP_VERSION="$BASE_VERSION"
228+ else
229+ APP_VERSION="$BASE_VERSION-$COMMIT_HASH"
230+ fi
144231
145- # Set up QEMU for cross-platform builds
232+ echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
233+ echo "Building version: $APP_VERSION"
146234 - name : Set up QEMU
147235 uses : docker/setup-qemu-action@v3
148236 with :
149237 platforms : arm64
150-
151- # Set up Docker Buildx
152238 - name : Set up Docker Buildx
153239 uses : docker/setup-buildx-action@v3
154-
155240 - name : Download fat jar
156241 uses : actions/download-artifact@v4
157242 with :
158243 name : jars
159244 path : app/build/libs/
160-
161- # Use Docker container with ARM64 JDK for jpackage
162245 - name : Package jar as debian package (arm64)
163246 run : |
164247 docker run --rm --platform linux/arm64 \
165248 -v $(pwd):/workspace \
166249 -w /workspace \
167250 arm64v8/eclipse-temurin:21-jdk \
168251 bash -c "apt-get update && apt-get install -y fakeroot && jpackage --main-jar data-caterer.jar '@misc/jpackage/jpackage.cfg' '@misc/jpackage/jpackage-linux.cfg'"
169-
170- - name : List directory
171- run : ls -lart
172-
173- - name : Rename output to indicate arm64
252+ - name : Rename output to indicate version and architecture (arm64)
174253 run : |
175- if [ -f "datacaterer_1.0.0_amd64.deb" ]; then
176- mv datacaterer_1.0.0_amd64.deb datacaterer_1.0.0_arm64.deb
254+ DEB_FILE=$(ls datacaterer_*_arm64.deb 2>/dev/null | head -n 1)
255+ if [ -n "$DEB_FILE" ]; then
256+ echo "Found deb file: $DEB_FILE"
257+ mv "$DEB_FILE" datacaterer_${{ env.APP_VERSION }}_arm64.deb
258+ echo "Renamed to: datacaterer_${{ env.APP_VERSION }}_arm64.deb"
259+ else
260+ echo "No deb file found"
261+ echo "Current directory:"
262+ pwd
263+ echo "Files in current directory:"
264+ ls -lart
265+ exit 1
177266 fi
178-
179267 - name : Upload deb (arm64)
180268 uses : actions/upload-artifact@v4
181269 with :
182270 name : data-caterer-linux-arm64
183- path : " datacaterer_1.0.0_arm64 .deb"
271+ path : " datacaterer_${{ env.APP_VERSION }}_arm64 .deb"
184272 overwrite : true
0 commit comments