Skip to content

Commit 7e51928

Browse files
insipxnplasterercoderabbitai[bot]
authored
Fix rustls transport error / use nix releases (#1153)
* ensure openssl version * fix the gen correctly generating * use xmtp/rust patch * remove some clones * use install action for cross * nix flake * add nix flake, kotlin/swift scripts+workflows * switch around swift -nix and non-nix * fix lints * remove extra lockfile * use nix flake for nix-swift release too * use magic nix cache in make swift * improve dev/release-swift * Update dev/release-kotlin Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * apply feedback * simplify buildInputs * cross unwind still not fixed * apply feedback to workflows * update workflows to use softprops --------- Co-authored-by: Naomi Plasterer <naomi@xmtp.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3a0129c commit 7e51928

23 files changed

+511
-61
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release Kotlin Bindings
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
build-linux:
6+
runs-on: warp-ubuntu-latest-x64-16x
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
target:
11+
- x86_64-linux-android
12+
- i686-linux-android
13+
- armv7-linux-androideabi
14+
- aarch64-linux-android
15+
include:
16+
- target: x86_64-linux-android
17+
output_target: x86_64
18+
- target: i686-linux-android
19+
output_target: x86
20+
- target: armv7-linux-androideabi
21+
output_target: armeabi-v7a
22+
- target: aarch64-linux-android
23+
output_target: arm64-v8a
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Cache
28+
uses: Swatinem/rust-cache@v2
29+
with:
30+
workspaces: |
31+
.
32+
bindings_ffi
33+
- name: Install Nix
34+
uses: cachix/install-nix-action@v17
35+
with:
36+
# Mostly to avoid GitHub rate limiting
37+
extra_nix_config: |
38+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
39+
- uses: DeterminateSystems/magic-nix-cache-action@v2
40+
- name: Build jniLibs
41+
run: |
42+
nix develop --command \
43+
cargo ndk -o bindings_ffi/jniLibs --manifest-path ./bindings_ffi/Cargo.toml \
44+
-t ${{ matrix.target }} -- build --release
45+
- name: Prepare JNI libs
46+
run: |
47+
cp bindings_ffi/jniLibs/${{ matrix.output_target }}/libxmtpv3.so bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so
48+
- name: Upload binary
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: ${{ matrix.output_target }}
52+
path: bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so
53+
retention-days: 1
54+
package-kotlin:
55+
needs: [build-linux]
56+
runs-on: warp-ubuntu-latest-x64-16x
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
- name: Download artifacts
61+
uses: actions/download-artifact@v4
62+
with:
63+
path: bindings_ffi/jniLibs
64+
- name: Build archive
65+
working-directory: bindings_ffi
66+
run: |
67+
zip -r LibXMTPKotlinFFI.zip jniLibs
68+
- name: Get short SHA
69+
id: slug
70+
run: echo "sha7=$(echo "${GITHUB_SHA}" | cut -c1-7)" >> "$GITHUB_OUTPUT"
71+
- name: Create release and upload asset
72+
uses: softprops/action-gh-release@v1
73+
with:
74+
files: ./bindings_ffi/LibXMTPKotlinFFI.zip
75+
tag_name: kotlin-bindings-${{ steps.slug.outputs.sha7 }}
76+
name: Kotlin-Bindings-${{ steps.slug.outputs.sha7 }}
77+
draft: false
78+
prerelease: true
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release Swift Bindings
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
build-macos:
6+
runs-on: warp-macos-13-arm64-6x
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
target:
11+
- aarch64-apple-ios
12+
- x86_64-apple-ios
13+
- aarch64-apple-ios-sim
14+
- x86_64-apple-darwin
15+
- aarch64-apple-darwin
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
- name: Install Nix
20+
uses: cachix/install-nix-action@v17
21+
with:
22+
# Mostly to avoid GitHub rate limiting
23+
extra_nix_config: |
24+
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
25+
- uses: DeterminateSystems/magic-nix-cache-action@v2
26+
- name: Cache
27+
uses: Swatinem/rust-cache@v2
28+
with:
29+
workspaces: |
30+
.
31+
- name: Build target
32+
run: |
33+
nix develop --command \
34+
cargo build --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml
35+
- name: Upload binary
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: ${{ matrix.target }}
39+
path: target/${{ matrix.target }}/release/libxmtpv3.a
40+
retention-days: 1
41+
swift:
42+
runs-on: warp-macos-13-arm64-6x
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
- uses: DeterminateSystems/magic-nix-cache-action@v2
47+
- name: Cache
48+
uses: Swatinem/rust-cache@v2
49+
with:
50+
workspaces: |
51+
.
52+
- name: Generate bindings
53+
working-directory: bindings_ffi
54+
run: |
55+
nix develop ./../ --command make swift
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: swift
60+
path: bindings_ffi/build/swift/
61+
retention-days: 1
62+
package-swift:
63+
needs: [build-macos, swift]
64+
runs-on: warp-macos-13-arm64-6x
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
- name: Download artifacts
69+
uses: actions/download-artifact@v4
70+
with:
71+
path: bindings_ffi/build
72+
- name: Build archive
73+
working-directory: bindings_ffi
74+
run: |
75+
mkdir -p Sources/LibXMTP
76+
mv build/swift/xmtpv3.swift Sources/LibXMTP/
77+
make framework
78+
cp ../LICENSE ./LICENSE
79+
zip -r LibXMTPSwiftFFI.zip Sources LibXMTPSwiftFFI.xcframework LICENSE
80+
- name: Calculate checksum
81+
id: checksum
82+
working-directory: bindings_ffi
83+
run: |
84+
echo "checksum=$(shasum -a 256 "LibXMTPSwiftFFI.zip" | awk '{ print $1 }')" >> "$GITHUB_OUTPUT"
85+
- name: Get short SHA
86+
id: slug
87+
run: echo "sha7=$(echo "$GITHUB_SHA" | cut -c1-7)" >> "$GITHUB_OUTPUT"
88+
- name: Create release and upload asset
89+
uses: softprops/action-gh-release@v1
90+
with:
91+
files: ./bindings_ffi/LibXMTPSwiftFFI.zip
92+
tag_name: swift-bindings-${{ steps.slug.outputs.sha7 }}
93+
name: Swift-Bindings-${{ steps.slug.outputs.sha7 }}
94+
draft: false
95+
prerelease: true
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-swift-bindings.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ jobs:
2626
workspaces: |
2727
.
2828
bindings_ffi
29-
# Install latest cross to mitigate unwind linking issue on android builds.
30-
# See https://github.com/cross-rs/cross/issues/1222
31-
- name: Install cross
32-
run: |
33-
cargo install cross --git https://github.com/cross-rs/cross
29+
- name: Install Cross
30+
uses: taiki-e/install-action@cross
3431
- name: Build target
3532
env:
3633
CROSS_NO_WARNINGS: "0"

Cargo.lock

+20-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ members = [
2222
resolver = "2"
2323

2424
[workspace.package]
25-
version = "0.0.1"
25+
version = "0.1.0"
2626

2727
[workspace.dependencies]
2828
anyhow = "1.0"
@@ -57,7 +57,11 @@ sha2 = "0.10.8"
5757
thiserror = "1.0"
5858
tls_codec = "0.4.1"
5959
tokio = { version = "1.35.1", default-features = false }
60-
tonic = "^0.12"
60+
# Changing this version and rustls may potentially break the android build. Use Caution.
61+
# Test with Android and Swift first.
62+
# Its probably preferable to one day use https://github.com/rustls/rustls-native-certs
63+
tonic = { version = "^0.12.2", features = ["tls", "tls-native-roots", "tls-webpki-roots"] }
64+
rustls = { version = "=0.23.7", features = ["ring"] }
6165
tracing = { version = "0.1", features = ["log", "release_max_level_debug"] }
6266
tracing-subscriber = { version = "0.3", default-features = false }
6367
diesel = { version = "2.2", default-features = false }
@@ -70,10 +74,8 @@ wasm-bindgen-test = "0.3.45"
7074
gloo-timers = "0.3"
7175
web-sys = "0.3"
7276
js-sys = "0.3"
73-
# NOTE: A regression in openssl-sys exists where libatomic is dynamically linked
74-
# for i686-linux-android targets. https://github.com/sfackler/rust-openssl/issues/2163
75-
openssl-sys = "0.9.104"
76-
openssl = "0.10.68"
77+
openssl-sys = "0.9"
78+
openssl = { version = "0.10", features = ["vendored"] }
7779
libsqlite3-sys = { version = "0.29", features = ["bundled-sqlcipher-vendored-openssl" ] }
7880
dyn-clone = "1"
7981
trait-variant = "0.1.2"
@@ -128,3 +130,4 @@ diesel-wasm-sqlite = { git = "https://github.com/xmtp/diesel-wasm-sqlite", branc
128130
diesel = { git = "https://github.com/diesel-rs/diesel", branch = "master" }
129131
diesel_derives = { git = "https://github.com/diesel-rs/diesel", branch = "master" }
130132
diesel_migrations = { git = "https://github.com/diesel-rs/diesel", branch = "master" }
133+

0 commit comments

Comments
 (0)