]> git.bitcoin.ninja Git - ldk-java/blob - .github/workflows/build.yml
ab8c4bea4ab307b9c95add8e87d69dedb93b8f1e
[ldk-java] / .github / workflows / build.yml
1 name: Continuous Integration Checks
2
3 on: [push, pull_request]
4
5 jobs:
6   wasm_bindings:
7     runs-on: ubuntu-latest
8     # Ubuntu's version of clang doesn't support....anything that should work.
9     # Ubuntu is an utter trash OS and should generally never be used for anything.
10     # We also require at least rustc 1.51 (ie https://github.com/rust-lang/rust/pull/79998),
11     # so we use debian testing
12     container: debian:bookworm
13     strategy:
14       fail-fast: false
15     steps:
16       - name: Install build utilities and test that clang can build for wasm
17         run: |
18           apt-get update
19           apt-get -y dist-upgrade
20           apt-get -y install cargo libstd-rust-dev-wasm32 lld git g++ clang curl node-typescript npm python3 wasi-libc
21           echo "int main() {}" > genbindings_wasm_test_file.c
22           clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c
23           rm genbindings_wasm_test_file.c
24       - name: Checkout source code
25         uses: actions/checkout@v2
26         with:
27           fetch-depth: 0
28       - name: Install cbindgen
29         run: |
30           git clone https://github.com/eqrion/cbindgen
31           cd cbindgen/
32           git checkout v0.20.0
33           cargo update -p indexmap --precise "1.6.2" --verbose
34           cargo install --locked --path .
35       - name: Checkout Rust-Lightning and LDK-C-Bindings git
36         run: |
37           git config --global safe.directory '*'
38           git config --global user.email "ldk-ci@example.com"
39           git config --global user.name "LDK CI"
40           # Note this is a different endpoint, as we need one non-upstream commit!
41           git clone https://git.bitcoin.ninja/rust-lightning
42           cd rust-lightning
43           git checkout origin/2023-02-0.0.114-java-bindings
44           cd ..
45           git clone https://github.com/lightningdevkit/ldk-c-bindings
46           cd ldk-c-bindings
47           git checkout 0.0.114
48       - name: Rebuild C bindings without STD
49         run: |
50           cd ldk-c-bindings
51           git config --global safe.directory "*"
52           ./genbindings.sh ../rust-lightning false
53       - name: Build and Test TS Debug Bindings for Node
54         run: |
55           # We need FinalizationRegistry and top-level await support, which requires node 14.6/8,
56           # however Debian ships with Node 12
57           # Thus, we install the binary nodejs from nodejs.org and test with that.
58           curl https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz > nodejs.tar.xz
59           tar xvvf nodejs.tar.xz
60           export PATH=$(pwd)/$(echo node-*/bin):$PATH
61           ./genbindings.sh ./ldk-c-bindings/ wasm true false
62       - name: Build and Test TS Release Bindings for Node
63         run: |
64           export PATH=$(pwd)/$(echo node-*/bin):$PATH
65           ./genbindings.sh ./ldk-c-bindings/ wasm false false
66       - name: Install Playwright for Web Tests
67         run: |
68           export HOME=/root/ # Github actions is apparently broken
69           export PATH=$(pwd)/$(echo node-*/bin):$PATH
70           # npx playwright install-deps is broken so we do it manually, see https://github.com/microsoft/playwright/issues/11165
71           apt-get install -y --no-install-recommends fonts-liberation libenchant-2-2 libicu72 libjpeg62-turbo libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libdbus-1-3 libdrm2 libegl1 libgbm1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxshmfence1 xvfb fonts-noto-color-emoji fonts-unifont libfontconfig libfreetype6 xfonts-scalable fonts-ipafont-gothic fonts-wqy-zenhei fonts-tlwg-loma-otf ffmpeg libcairo-gobject2 libdbus-glib-1-2 libfontconfig1 libgdk-pixbuf2.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libxcb-shm0 libxcursor1 libxi6 libxrender1 libxt6 gstreamer1.0-libav gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good libepoxy0 libevdev2 libgl1 libgles2 libgstreamer-gl1.0-0 libgstreamer1.0-0 libharfbuzz-icu0 libharfbuzz0b libhyphen0 libnotify4 libopenjp2-7 libopus0 libpng16-16 libsecret-1-0 libsoup2.4-1 libwayland-client0 libwayland-egl1 libwayland-server0 libwebp7 libwebpdemux2 libwoff1 libxkbcommon0 libxml2 libxslt1.1
72           mkdir -p $HOME/.cache/ms-playwright # `playwright install` is too dumb to create this for us
73           chmod -R 777 $HOME/
74           npm i -D playwright
75           npx playwright install
76       - name: Build and Test TS Debug Bindings for Web
77         run: |
78           export HOME=/root/ # Github actions is apparently broken
79           export PATH=$(pwd)/$(echo node-*/bin):$PATH
80           git config --global safe.directory "*"
81           ./genbindings.sh ./ldk-c-bindings/ wasm true true
82           cd ts
83           rm liblightningjs.wasm && ln -s $(pwd)/../liblightningjs_debug.wasm ./liblightningjs.wasm
84           python3 -m http.server &
85           SERVER_PID=$!
86           node test/browser.mjs
87           kill $SERVER_PID
88       - name: Build and Test TS Release Bindings for Web
89         run: |
90           export HOME=/root/ # Github actions is apparently broken
91           export PATH=$(pwd)/$(echo node-*/bin):$PATH
92           ./genbindings.sh ./ldk-c-bindings/ wasm false true
93           cd ts
94           rm liblightningjs.wasm && ln -s $(pwd)/../liblightningjs_release.wasm ./liblightningjs.wasm
95           python3 -m http.server &
96           SERVER_PID=$!
97           node test/browser.mjs
98           kill $SERVER_PID
99       - name: Check latest TS files are in git
100         run: |
101           git checkout ts/package.json
102           git checkout node-net/package.json
103           git diff --exit-code
104
105   java_bindings:
106     runs-on: ubuntu-latest
107     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
108     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
109     container: debian:bullseye
110     strategy:
111       fail-fast: false
112     steps:
113       - name: Install native Rust toolchain, Valgrind, and build utilitis
114         run: |
115           apt-get update
116           apt-get -y dist-upgrade
117           apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
118       - name: Checkout source code
119         uses: actions/checkout@v2
120         with:
121           fetch-depth: 0
122       - name: Install cbindgen
123         run: |
124           git config --global safe.directory '*'
125           git clone https://github.com/eqrion/cbindgen
126           cd cbindgen/
127           git checkout v0.20.0
128           cargo update -p indexmap --precise "1.6.2" --verbose
129           cargo install --locked --path .
130       - name: Checkout Rust-Lightning and LDK-C-Bindings git
131         run: |
132           git config --global user.email "ldk-ci@example.com"
133           git config --global user.name "LDK CI"
134           # Note this is a different endpoint, as we need one non-upstream commit!
135           git clone https://git.bitcoin.ninja/rust-lightning
136           cd rust-lightning
137           git checkout origin/2023-02-0.0.114-java-bindings
138           cd ..
139           git clone https://github.com/lightningdevkit/ldk-c-bindings
140           cd ldk-c-bindings
141           git checkout 0.0.114
142       - name: Rebuild C bindings, and check the sample app builds + links
143         run: |
144           cd ldk-c-bindings
145           ./genbindings.sh ../rust-lightning true
146       - name: Build Java Debug Bindings
147         run: ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" true false
148       - name: Run Java Tests against Debug Bindings
149         run: |
150           mv liblightningjni_debug_Linux-amd64.so liblightningjni.so
151           export ASAN_OPTIONS=detect_leaks=0
152           LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
153       - name: Build Java Release Bindings
154         run: |
155           ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" false false
156       - name: Check latest headers are in git
157         run: |
158           git checkout pom.xml
159           git diff --exit-code
160
161   java_determinism:
162     runs-on: ubuntu-latest
163     # Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
164     # This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
165     container: debian:bullseye
166     strategy:
167       fail-fast: false
168     steps:
169       - name: Install native Rust toolchain, Valgrind, and build utilitis
170         run: |
171           apt-get update
172           apt-get -y dist-upgrade
173           apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
174       - name: Checkout source code
175         uses: actions/checkout@v2
176         with:
177           fetch-depth: 0
178       - name: Install cbindgen
179         run: |
180           git config --global safe.directory '*'
181           git clone https://github.com/eqrion/cbindgen
182           cd cbindgen/
183           git checkout v0.20.0
184           cargo update -p indexmap --precise "1.6.2" --verbose
185           cargo install --locked --path .
186       - name: Checkout Rust-Lightning and LDK-C-Bindings git
187         run: |
188           git config --global user.email "ldk-ci@example.com"
189           git config --global user.name "LDK CI"
190           # Note this is a different endpoint, as we need one non-upstream commit!
191           git clone https://git.bitcoin.ninja/rust-lightning
192           cd rust-lightning
193           git checkout origin/2023-02-0.0.114-java-bindings
194           cd ..
195           git clone https://github.com/lightningdevkit/ldk-c-bindings
196           cd ldk-c-bindings
197           git checkout 0.0.114
198       - name: Rebuild C bindings, and check the sample app builds + links
199         run: |
200           cd ldk-c-bindings
201           ./genbindings.sh ../rust-lightning true
202       - name: Checkout latest MacOS binaries
203         run: |
204           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
205           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
206           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
207           SNAPSHOT_LINK="$(curl "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
208           curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
209           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
210           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
211           tar xvvf ../../bins-snapshot.tgz
212           mv ldk-java-bins-*/* ./
213           rm -r ldk-java-bins-*
214           cd ../..
215           mkdir -p src/main/resources/
216           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_MacOSX-"* src/main/resources/
217           rm src/main/resources/liblightningjni_MacOSX-*-leaktracking.nativelib
218       - name: Build Java Release Bindings
219         run: |
220           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
221           ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" false false
222       - name: Build deterministic release jar
223         run: ./build-release-jar.sh
224       - name: Check latest library and jars are in bins repo
225         run: |
226           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
227           mkdir ldk-java-bins/new/
228           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_Mac*.nativelib ldk-java-bins/new/
229           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar ldk-java-bins/new/
230           # ldk-java-leaktracking is only for debug purposes and we don't bother with determinism
231           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"ldk-java-leaktracking.jar ldk-java-bins/new/
232           cp src/main/resources/liblightningjni_Linux-amd64.nativelib ldk-java-bins/new/
233           cp ldk-java-sources.jar ldk-java-bins/new/
234           cp ldk-java.jar ldk-java-bins/new/
235           cp ldk-java-classes.jar ldk-java-bins/new/
236           cp ldk-java-javadoc.jar ldk-java-bins/new/
237           cd ldk-java-bins
238           if ! diff -r "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/" new/; then
239             apt-get -y install diffoscope
240             diffoscope new/ldk-java-sources.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-sources.jar" || echo
241             diffoscope new/ldk-java-javadoc.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-javadoc.jar" || echo
242             diffoscope new/ldk-java-classes.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" || echo
243             diffoscope new/ldk-java.jar "${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java.jar" || echo
244             exit 1
245           fi
246       - name: Run Java Tests against built release jar
247         run: |
248           mvn install:install-file -Dfile=ldk-java.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
249           cd javatester
250           mvn package
251           java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
252
253   android:
254     runs-on: ubuntu-latest
255     # Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
256     container: debian:bullseye
257     strategy:
258       fail-fast: false
259     steps:
260       - name: Install rust targets
261         run: |
262           apt-get update
263           apt-get -y dist-upgrade
264           apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk
265           curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
266           chmod +x ./rustup.sh
267           ./rustup.sh -y
268           . $HOME/.cargo/env
269           rustup target add armv7-linux-androideabi
270           rustup target add aarch64-linux-android
271           rustup target add i686-linux-android
272           rustup target add x86_64-linux-android
273       - name: Checkout source code
274         uses: actions/checkout@v2
275         with:
276           fetch-depth: 0
277       - name: Install android NDK compilers
278         run: |
279           git config --global safe.directory '*'
280           curl https://dl.google.com/android/repository/android-ndk-r22b-linux-x86_64.zip > android-ndk-r22b-linux-x86_64.zip
281           if [ "$(sha256sum android-ndk-r22b-linux-x86_64.zip | awk '{ print $1 }')" != "ac3a0421e76f71dd330d0cd55f9d99b9ac864c4c034fc67e0d671d022d4e806b" ]; then
282             echo "Bad hash"
283             exit 1
284           fi
285           unzip android-ndk-r22b-linux-x86_64.zip
286       - name: Install cbindgen
287         run: |
288           . $HOME/.cargo/env
289           cargo install cbindgen
290       - name: Checkout Rust-Lightning and LDK-C-Bindings git
291         run: |
292           git config --global user.email "ldk-ci@example.com"
293           git config --global user.name "LDK CI"
294           # Note this is a different endpoint, as we need one non-upstream commit!
295           git clone https://git.bitcoin.ninja/rust-lightning
296           cd rust-lightning
297           git checkout origin/2023-02-0.0.114-java-bindings
298           cd ..
299           git clone https://github.com/lightningdevkit/ldk-c-bindings
300           cd ldk-c-bindings
301           git checkout 0.0.114
302       - name: Checkout Android AAR binaries and artifacts
303         run: |
304           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
305           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
306           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
307           RELEASE_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main"
308           SNAPSHOT_LINK="$(curl "$RELEASE_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
309           curl -o bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
310
311           ANDROID_PAGE="https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=android-artifacts;hb=refs/heads/main"
312           SNAPSHOT_LINK="$(curl "$ANDROID_PAGE" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
313           curl -o android-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
314
315           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
316           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
317           tar xvvf ../../bins-snapshot.tgz
318           mv ldk-java-bins-*/* ./
319           rm -r ldk-java-bins-*
320
321           mkdir -p ../android-artifacts
322           cd ../android-artifacts
323           tar xvvf ../../android-snapshot.tgz
324           mv ldk-java-bins-*/* ./
325           rm -r ldk-java-bins-*
326       - name: Build Android aar
327         run: |
328           . $HOME/.cargo/env
329           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
330           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/ldk-java-classes.jar" ./
331           export ANDROID_TOOLCHAIN="$(pwd)/android-ndk-r22b/toolchains/llvm/prebuilt/linux-x86_64"
332           export PATH="$PATH:$ANDROID_TOOLCHAIN/bin"
333           ./android-build.sh ./rust-lightning ./ldk-c-bindings/ ./ldk-java-bins/android-artifacts
334       - name: Check latest library and jars are in bins repo
335         run: |
336           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
337           if ! diff LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"LDK-release.aar; then
338             apt-get -y install diffoscope
339             diffoscope LDK-release.aar "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/LDK-release.aar"
340             exit 1
341           fi
342
343   osx:
344     strategy:
345       matrix:
346         include:
347           - platform: macos-10.15
348           - platform: macos-11
349       fail-fast: false
350     runs-on: ${{ matrix.platform }}
351     steps:
352       - name: Install other Rust platforms
353         run: rustup target install aarch64-apple-darwin
354       - name: Checkout source code
355         uses: actions/checkout@v2
356         with:
357           fetch-depth: 0
358       - name: Fetch upstream LLVM/clang snapshot
359         run: |
360           git config --global safe.directory '*'
361           wget -O clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz
362           if [ "$(shasum -a 256 clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz | awk '{ print $1 }')" != "d16b6d536364c5bec6583d12dd7e6cf841b9f508c4430d9ee886726bd9983f1c" ]; then
363             echo "Bad hash"
364             exit 1
365           fi
366       - name: Unpack upstream LLVM+clang and use it by default
367         run: |
368           tar xvvf clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz
369       - name: Install cbindgen
370         run: cargo install cbindgen
371       - name: Checkout Rust-Lightning and LDK-C-Bindings git
372         run: |
373           git config --global user.email "ldk-ci@example.com"
374           git config --global user.name "LDK CI"
375           # Note this is a different endpoint, as we need one non-upstream commit!
376           git clone https://git.bitcoin.ninja/rust-lightning
377           cd rust-lightning
378           git checkout origin/2023-02-0.0.114-java-bindings
379           cd ..
380           git clone https://github.com/lightningdevkit/ldk-c-bindings
381           cd ldk-c-bindings
382           git checkout 0.0.114
383       - name: Rebuild C bindings with upstream clang, and check the sample app builds + links
384         run: |
385           export PATH=`pwd`/clang+llvm-15.0.7-x86_64-apple-darwin21.0/bin:$PATH
386           cd ldk-c-bindings
387           CC=clang ./genbindings.sh ../rust-lightning true
388       - name: Fetch OpenJDK 18
389         run: |
390           if [ "$(uname -m)" = "arm64" ]; then
391             wget -O openjdk-18.0.1.1_macos-aarch64_bin.tar.gz https://download.java.net/java/GA/jdk18.0.1.1/65ae32619e2f40f3a9af3af1851d6e19/2/GPL/openjdk-18.0.1.1_macos-aarch64_bin.tar.gz
392             if [ "$(shasum -a 256 openjdk-18.0.1.1_macos-aarch64_bin.tar.gz | awk '{ print $1 }')" != "29773ad68063bdad7fbaeb762cd873d3f243e86de380d3ac5335cdb929371fb5" ]; then
393               echo "Bad hash"
394               exit 1
395             fi
396             tar xvvf openjdk-18.0.1.1_macos-aarch64_bin.tar.gz
397           else
398             wget -O openjdk-18.0.1.1_macos-x64_bin.tar.gz https://download.java.net/java/GA/jdk18.0.1.1/65ae32619e2f40f3a9af3af1851d6e19/2/GPL/openjdk-18.0.1.1_macos-x64_bin.tar.gz
399             if [ "$(shasum -a 256 openjdk-18.0.1.1_macos-x64_bin.tar.gz | awk '{ print $1 }')" != "f02d17ec5a387555f8489abc352d973b6c10364409b597046025938e2266d72a" ]; then
400               echo "Bad hash"
401               exit 1
402             fi
403             tar xvvf openjdk-18.0.1.1_macos-x64_bin.tar.gz
404           fi
405       - name: Checkout latest Linux binaries
406         run: |
407           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
408           echo "Fetching deterministic binaries for LDK-GC ${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
409           # Gitweb only allows snapshots of folders by providing the object hash, which we have to extract:
410           SNAPSHOT_LINK="$(wget -O /dev/stdout "https://git.bitcoin.ninja/index.cgi?p=ldk-java-bins;a=tree;f=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE};hb=refs/heads/main" | grep snapshot | grep -o 'href="[a-zA-Z0-9/?\.=;\-]*"' | sed 's/href="//' | tr -d '"' | grep snapshot)"
411           wget -O bins-snapshot.tgz "https://git.bitcoin.ninja${SNAPSHOT_LINK}"
412           mkdir -p ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
413           cd ldk-java-bins/"${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}"
414           tar xvvf ../../bins-snapshot.tgz
415           mv ldk-java-bins-*/* ./
416           cd ../..
417           mkdir -p src/main/resources/
418           cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/liblightningjni_Linux-"* src/main/resources/
419       - name: Build Java Release Bindings
420         run: |
421           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
422           export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
423           export PATH=$JAVA_HOME/bin:$PATH
424           export PATH=`pwd`/clang+llvm-15.0.7-x86_64-apple-darwin21.0/bin:$PATH
425           ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
426
427           if [ "${{ matrix.platform }}" = "macos-11" ]; then
428             export CC="clang --target=aarch64-apple-darwin"
429             export LDK_TARGET=aarch64-apple-darwin
430             export LDK_TARGET_CPU=apple-a14
431             ./genbindings.sh ./ldk-c-bindings/ "-I$JAVA_HOME/include/ -I$JAVA_HOME/include/darwin -isysroot$(xcrun --show-sdk-path)" false false
432             cat src/main/resources/liblightningjni_MacOSX-aarch64.nativelib > /dev/null
433
434           fi
435
436       - name: Fetch Maven 3.8.4
437         run: |
438           # We don't bother using the upstream mirrors as they remove prior
439           # releases aggressively, causing spurious CI failures when we don't
440           # care about the version used.
441           wget -O apache-maven-3.8.4-bin.tar.gz https://bitcoin.ninja/apache-maven-3.8.4-bin.tar.gz
442           if [ "$(shasum -a 256 apache-maven-3.8.4-bin.tar.gz | awk '{ print $1 }')" != "2cdc9c519427bb20fdc25bef5a9063b790e4abd930e7b14b4e9f4863d6f9f13c" ]; then
443             echo "Bad hash"
444             exit 1
445           fi
446           tar xvvf apache-maven-3.8.4-bin.tar.gz
447           export PATH=apache-maven-3.8.4/bin:$PATH
448       - name: Run Java Tests against built jar
449         run: |
450           export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
451           export PATH=$JAVA_HOME/bin:$PATH
452           mvn -DskipTests=true package
453           export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
454           JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
455           mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
456           cd javatester
457           mvn -q -B package
458           java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
459       - name: Check latest release libs are in git
460         run: |
461           if [ "${{ matrix.platform }}" = "macos-11" ]; then
462             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
463             # Sadly, OSX binaries are not currently deterministic, more debugging is needed.
464             diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-x86_64.nativelib src/main/resources/liblightningjni_MacOSX-x86_64.nativelib || echo
465             diff "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-aarch64.nativelib src/main/resources/liblightningjni_MacOSX-aarch64.nativelib || echo
466           fi
467       - name: Upload CI x86_64 build for analysis
468         if: matrix.platform == 'macos-11'
469         uses: actions/upload-artifact@v3.0.0
470         with:
471           name: liblightningjni_MacOSX-x86_64.nativelib.ci-build
472           path: src/main/resources/liblightningjni_MacOSX-x86_64.nativelib
473       - name: Upload CI aarch64 build for analysis
474         if: matrix.platform == 'macos-11'
475         uses: actions/upload-artifact@v3.0.0
476         with:
477           name: liblightningjni_MacOSX-aarch64.nativelib.ci-build
478           path: src/main/resources/liblightningjni_MacOSX-aarch64.nativelib
479       - name: Run Java Tests against release bins
480         run: |
481           if [ "${{ matrix.platform }}" != "macos-11" ]; then
482             export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
483             export JAVA_HOME=`pwd`/jdk-18.0.1.1.jdk/Contents/Home
484             export PATH=$JAVA_HOME/bin:$PATH
485             cp "ldk-java-bins/${LDK_GARBAGECOLLECTED_GIT_OVERRIDE}/"liblightningjni_MacOSX-{x86_64,aarch64}.nativelib src/main/resources/
486             mvn clean
487             mvn -q -B -DskipTests=true package
488             JAR_VERSION=${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}
489             mvn install:install-file -Dfile=target/ldk-java-${JAR_VERSION}.jar -DgroupId=org.lightningdevkit -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
490             cd javatester
491             mvn -q -B package
492             java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
493           fi