Skip to content

Commit f647453

Browse files
committed
Build macOS packages for both aarch64 and x86
Signed-off-by: Taylor Smock <[email protected]>
1 parent b8dcfca commit f647453

File tree

1 file changed

+68
-7
lines changed

1 file changed

+68
-7
lines changed

.github/workflows/ant.yml

+68-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Java CI Build
22
env:
3-
junit_platform_version: '1.9.3'
43
JAVAFX_VERSION: '17.0.7'
54
on:
65
push:
@@ -71,7 +70,7 @@ jobs:
7170
matrix:
7271
# test against latest update of each major Java version, as well as specific updates of LTS versions:
7372
java: [8, 11, 17, 21, 22, 23-ea]
74-
os: [ubuntu-latest, macos-latest, windows-latest]
73+
os: [ubuntu-latest, macos-14, windows-latest]
7574
name: Java ${{ matrix.java }} on ${{ matrix.os }}
7675
steps:
7776
- name: Checkout
@@ -93,6 +92,14 @@ jobs:
9392
distribution: 'zulu'
9493
java-version: ${{ matrix.java }}
9594

95+
- name: Setup x64 Java (Mac) ${{ matrix.java }}
96+
if: ${{ runner.os == 'macos' && runner.arch == 'ARM64' && always() }}
97+
uses: actions/setup-java@v4
98+
with:
99+
distribution: 'zulu'
100+
java-version: ${{ matrix.java }}
101+
architecture: x64
102+
96103
- name: Install Ant
97104
uses: JOSM/JOSMPluginAction/actions/setup-ant@v2
98105

@@ -155,12 +162,66 @@ jobs:
155162
APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
156163
APPLE_ID_TEAM: ${{ secrets.APPLE_ID_TEAM }}
157164
run: |
158-
if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip ]; then
159-
curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_osx-x64_bin-jmods.zip
165+
function build_arch() {
166+
if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip ]; then
167+
curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_osx-${1}_bin-jmods.zip
168+
fi
169+
unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip
170+
mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
171+
./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
172+
app/JOSM.zip app/JOSM_${1}.zip
173+
}
174+
175+
function merge() {
176+
if [ "$(command -v lipo)" ]; then
177+
lipo -create -output "${1}" "${2}" "${3}"
178+
elif [ "$(command -v llvm-lipo-15)" ]; then
179+
llvm-lipo-15 -create -output "${1}" "${2}" "${3}"
180+
fi
181+
}
182+
183+
function copy() {
184+
# Trim the root path
185+
FILE="${1#*/}"
186+
if [ ! -e "target/${FILE}" ]; then
187+
# Only make directories if we aren't looking at the root files
188+
if [[ "${FILE}" == *"/"* ]]; then mkdir -p "target/${FILE%/*}"; fi
189+
if file "${1}" | grep -q 'Mach-O' ; then
190+
merge "target/${FILE}" "x64/${FILE}" "aarch64/${FILE}"
191+
if file "${1}" | grep -q 'executable'; then
192+
chmod 755 "target/${FILE}"
193+
fi
194+
else
195+
cp -a "${1}" "target/${FILE}"
196+
fi
197+
fi
198+
}
199+
200+
function directory_iterate() {
201+
while IFS= read -r -d '' file
202+
do
203+
copy "${file}" &
204+
done < <(find "${1}" -type f,l -print0)
205+
wait
206+
}
207+
208+
if [ ${{ runner.arch }} == "ARM64" ]; then
209+
build_arch aarch64
210+
JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_x64" build_arch x64
211+
212+
unzip -d app/x64 app/JOSM_x64.zip
213+
unzip -d app/aarch64 app/JOSM_aarch64.zip
214+
mkdir app/target
215+
cd app
216+
directory_iterate aarch64
217+
directory_iterate x64
218+
cd target
219+
zip JOSM.zip -r JOSM.app
220+
mv JOSM.zip ..
221+
else
222+
build_arch x64
223+
mv app/JOSM_x64.zip app/JOSM.zip
160224
fi
161-
unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip
162-
mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
163-
./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
164225
165226
- name: Setup Windows PATH
166227
if: ${{ runner.os == 'windows' && matrix.java != '8' && matrix.java != '11' && always() }}

0 commit comments

Comments
 (0)