Skip to content

Commit 2a4a133

Browse files
committed
feat: Add CI build
1 parent 4cdb9be commit 2a4a133

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

.github/workflows/jnigen.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Build Workflow
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-linux:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- name: Install cross-compilation toolchains
10+
run: |
11+
sudo apt update
12+
sudo apt install -y --force-yes gcc g++
13+
sudo apt install -y --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
14+
sudo apt install -y --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
15+
sudo apt install -y --force-yes gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross
16+
sudo apt install -y --force-yes mingw-w64 lib32z1
17+
18+
- name: Download Android NDK
19+
run: |
20+
mkdir -p $HOME/android-ndk
21+
cd $HOME/android-ndk
22+
wget https://dl.google.com/android/repository/android-ndk-r25c-linux.zip -O android-ndk.zip
23+
echo "769ee342ea75f80619d985c2da990c48b3d8eaf45f48783a2d48870d04b46108 android-ndk.zip" | sha256sum --check
24+
unzip android-ndk.zip
25+
echo "NDK_HOME=$HOME/android-ndk/android-ndk-r25c" >> $GITHUB_ENV
26+
27+
- uses: actions/checkout@v2
28+
with:
29+
fetch-depth: 0
30+
submodules: 'recursive'
31+
32+
- name: Set up JDK 17
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: 'zulu'
36+
java-version: '17'
37+
38+
- name: Build box2d
39+
run: ./gradlew build_linux build_android build_windows
40+
41+
- name: Initialize jnigen
42+
run: ./gradlew jnigen
43+
44+
- name: Build natives
45+
run: ./gradlew jnigenBuildAllAndroid jnigenBuildAllLinux jnigenBuildAllWindows
46+
47+
48+
- name: Pack artifacts
49+
run: |
50+
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" | grep "libs" > native-files-list
51+
zip natives-linux -@ < native-files-list
52+
53+
- name: Upload artifacts
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: natives-linux.zip
57+
path: natives-linux.zip
58+
build-mac:
59+
runs-on: macos-14
60+
steps:
61+
- name: Setup Xcode SDK
62+
run: |
63+
# See https://github.com/actions/virtual-environments/issues/2557
64+
sudo mv /Library/Developer/CommandLineTools/SDKs/* /tmp
65+
sudo mv /Applications/Xcode.app /Applications/Xcode.app.bak
66+
sudo mv /Applications/Xcode_15.4.0.app /Applications/Xcode.app
67+
sudo xcode-select -switch /Applications/Xcode.app
68+
/usr/bin/xcodebuild -version
69+
70+
- uses: actions/checkout@v2
71+
with:
72+
fetch-depth: 0
73+
submodules: 'recursive'
74+
75+
- name: Set up JDK 17
76+
uses: actions/setup-java@v3
77+
with:
78+
distribution: 'zulu'
79+
java-version: '17'
80+
81+
- name: Build box2d
82+
run: ./gradlew build_macos build_ios
83+
84+
- name: Initialize jnigen
85+
run: ./gradlew jnigen
86+
87+
- name: Build natives
88+
run: ./gradlew jnigenBuildAllIOS jnigenBuildAllMacOsX
89+
90+
- name: Pack artifacts
91+
run: |
92+
find . -name "*.a" -o -name "*.dll" -o -name "*.dylib" -o -name "*.so" -o -name "*.xcframework" | grep "libs" > native-files-list
93+
zip natives-mac -@ < native-files-list
94+
95+
- name: Upload artifacts
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: natives-mac.zip
99+
path: natives-mac.zip
100+
101+
102+
package:
103+
runs-on: ubuntu-latest
104+
needs: [build-linux, build-mac]
105+
steps:
106+
- uses: actions/checkout@v2
107+
with:
108+
fetch-depth: 0
109+
submodules: 'recursive'
110+
111+
- name: Set up JDK 17
112+
uses: actions/setup-java@v3
113+
with:
114+
distribution: 'zulu'
115+
java-version: '17'
116+
117+
- name: Download Artifacts from linux
118+
if: success() && needs.build-linux.result == 'success'
119+
uses: actions/download-artifact@v3
120+
with:
121+
name: natives-linux.zip
122+
123+
- name: Unzip artifacts
124+
run: unzip -o natives-linux.zip
125+
- name: Download Artifacts from mac
126+
if: success() && needs.build-mac.result == 'success'
127+
uses: actions/download-artifact@v3
128+
with:
129+
name: natives-mac.zip
130+
131+
- name: Unzip artifacts
132+
run: unzip -o natives-mac.zip
133+
134+
135+
- name: Package All
136+
run: ./gradlew jnigenPackageAll

0 commit comments

Comments
 (0)