Skip to content

Commit

Permalink
Fix rustls transport error / use nix releases (#1153)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent 3a0129c commit 7e51928
Show file tree
Hide file tree
Showing 23 changed files with 511 additions and 61 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/release-kotlin-bindings-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release Kotlin Bindings
on:
workflow_dispatch:
jobs:
build-linux:
runs-on: warp-ubuntu-latest-x64-16x
strategy:
fail-fast: false
matrix:
target:
- x86_64-linux-android
- i686-linux-android
- armv7-linux-androideabi
- aarch64-linux-android
include:
- target: x86_64-linux-android
output_target: x86_64
- target: i686-linux-android
output_target: x86
- target: armv7-linux-androideabi
output_target: armeabi-v7a
- target: aarch64-linux-android
output_target: arm64-v8a
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
bindings_ffi
- name: Install Nix
uses: cachix/install-nix-action@v17
with:
# Mostly to avoid GitHub rate limiting
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Build jniLibs
run: |
nix develop --command \
cargo ndk -o bindings_ffi/jniLibs --manifest-path ./bindings_ffi/Cargo.toml \
-t ${{ matrix.target }} -- build --release
- name: Prepare JNI libs
run: |
cp bindings_ffi/jniLibs/${{ matrix.output_target }}/libxmtpv3.so bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.output_target }}
path: bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so
retention-days: 1
package-kotlin:
needs: [build-linux]
runs-on: warp-ubuntu-latest-x64-16x
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: bindings_ffi/jniLibs
- name: Build archive
working-directory: bindings_ffi
run: |
zip -r LibXMTPKotlinFFI.zip jniLibs
- name: Get short SHA
id: slug
run: echo "sha7=$(echo "${GITHUB_SHA}" | cut -c1-7)" >> "$GITHUB_OUTPUT"
- name: Create release and upload asset
uses: softprops/action-gh-release@v1
with:
files: ./bindings_ffi/LibXMTPKotlinFFI.zip
tag_name: kotlin-bindings-${{ steps.slug.outputs.sha7 }}
name: Kotlin-Bindings-${{ steps.slug.outputs.sha7 }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97 changes: 97 additions & 0 deletions .github/workflows/release-swift-bindings-nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Release Swift Bindings
on:
workflow_dispatch:
jobs:
build-macos:
runs-on: warp-macos-13-arm64-6x
strategy:
fail-fast: false
matrix:
target:
- aarch64-apple-ios
- x86_64-apple-ios
- aarch64-apple-ios-sim
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v17
with:
# Mostly to avoid GitHub rate limiting
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
- name: Build target
run: |
nix develop --command \
cargo build --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/libxmtpv3.a
retention-days: 1
swift:
runs-on: warp-macos-13-arm64-6x
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
- name: Generate bindings
working-directory: bindings_ffi
run: |
nix develop ./../ --command make swift
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: swift
path: bindings_ffi/build/swift/
retention-days: 1
package-swift:
needs: [build-macos, swift]
runs-on: warp-macos-13-arm64-6x
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: bindings_ffi/build
- name: Build archive
working-directory: bindings_ffi
run: |
mkdir -p Sources/LibXMTP
mv build/swift/xmtpv3.swift Sources/LibXMTP/
make framework
cp ../LICENSE ./LICENSE
zip -r LibXMTPSwiftFFI.zip Sources LibXMTPSwiftFFI.xcframework LICENSE
- name: Calculate checksum
id: checksum
working-directory: bindings_ffi
run: |
echo "checksum=$(shasum -a 256 "LibXMTPSwiftFFI.zip" | awk '{ print $1 }')" >> "$GITHUB_OUTPUT"
- name: Get short SHA
id: slug
run: echo "sha7=$(echo "$GITHUB_SHA" | cut -c1-7)" >> "$GITHUB_OUTPUT"
- name: Create release and upload asset
uses: softprops/action-gh-release@v1
with:
files: ./bindings_ffi/LibXMTPSwiftFFI.zip
tag_name: swift-bindings-${{ steps.slug.outputs.sha7 }}
name: Swift-Bindings-${{ steps.slug.outputs.sha7 }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 2 additions & 5 deletions .github/workflows/release-swift-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ jobs:
workspaces: |
.
bindings_ffi
# Install latest cross to mitigate unwind linking issue on android builds.
# See https://github.com/cross-rs/cross/issues/1222
- name: Install cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Install Cross
uses: taiki-e/install-action@cross
- name: Build target
env:
CROSS_NO_WARNINGS: "0"
Expand Down
39 changes: 20 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.0.1"
version = "0.1.0"

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

Loading

0 comments on commit 7e51928

Please sign in to comment.