From 7c1b25caca171eee6bdac5f3f58be0d36afb5524 Mon Sep 17 00:00:00 2001 From: kubel Date: Tue, 15 Oct 2024 09:16:22 +0200 Subject: [PATCH 01/37] Build binaries without UDL file --- crates/kotlin-ffi/Cargo.toml | 2 +- crates/kotlin-ffi/build.rs | 3 -- crates/kotlin-ffi/src/account_client.udl | 53 ------------------------ crates/kotlin-ffi/src/lib.rs | 10 ++--- crates/kotlin-ffi/src/yttrium.udl | 38 ----------------- crates/yttrium/Cargo.toml | 5 ++- crates/yttrium/src/config.rs | 6 +++ crates/yttrium/src/lib.rs | 2 + justfile | 2 +- 9 files changed, 19 insertions(+), 102 deletions(-) delete mode 100644 crates/kotlin-ffi/build.rs delete mode 100644 crates/kotlin-ffi/src/account_client.udl delete mode 100644 crates/kotlin-ffi/src/yttrium.udl diff --git a/crates/kotlin-ffi/Cargo.toml b/crates/kotlin-ffi/Cargo.toml index 3b26b54..4b0dcce 100644 --- a/crates/kotlin-ffi/Cargo.toml +++ b/crates/kotlin-ffi/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] uniffi_build = "0.28.1" [dependencies] -yttrium = { path = "../yttrium" } +yttrium = { path = "../yttrium", features = ["uniffi"] } uniffi = { version = "0.28.1", features = ["tokio"] } openssl = { version = "0.10", features = ["vendored"] } openssl-sys = { version = "0.9.103", features = ["vendored"] } diff --git a/crates/kotlin-ffi/build.rs b/crates/kotlin-ffi/build.rs deleted file mode 100644 index 6a3212e..0000000 --- a/crates/kotlin-ffi/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - uniffi_build::generate_scaffolding("src/yttrium.udl").unwrap(); -} diff --git a/crates/kotlin-ffi/src/account_client.udl b/crates/kotlin-ffi/src/account_client.udl deleted file mode 100644 index 552c4d6..0000000 --- a/crates/kotlin-ffi/src/account_client.udl +++ /dev/null @@ -1,53 +0,0 @@ -namespace yttrium { - -}; - -[Error] -enum Error { - "Unknown" -}; - -dictionary Endpoint { - string api_key; - string base_url; -}; - -dictionary Endpoints { - Endpoint rpc; - Endpoint bundler; - Endpoint paymaster; -}; - - dictionary Config { - Endpoints endpoints; - }; - - dictionary AccountClientConfig { - string owner_address; - u64 chain_id; - Config config; - string signer_type; - boolean safe; - string private_key; - }; - - dictionary Transaction { - string to; - string value; - string data; - }; - -interface AccountClient { - constructor(AccountClientConfig config); - - u64 chain_id(); - - [Throws=Error, Async] - string get_address(); - - [Throws=Error, Async] - string send_transactions(sequence transactions); - - [Throws=Error, Async] - string wait_for_user_operation_receipt(string user_operation_hash); - }; \ No newline at end of file diff --git a/crates/kotlin-ffi/src/lib.rs b/crates/kotlin-ffi/src/lib.rs index 038a6fb..0dc8455 100644 --- a/crates/kotlin-ffi/src/lib.rs +++ b/crates/kotlin-ffi/src/lib.rs @@ -1,6 +1,6 @@ +uniffi::setup_scaffolding!(); + use yttrium::config::Config; -use yttrium::config::Endpoint; -use yttrium::config::Endpoints; use yttrium::{ account_client::{AccountClient as YAccountClient, SignerType}, private_key_service::PrivateKeyService, @@ -15,6 +15,7 @@ pub struct AccountClient { account_client: YAccountClient, } +#[derive(uniffi::Record)] pub struct AccountClientConfig { pub owner_address: String, pub chain_id: u64, @@ -24,13 +25,14 @@ pub struct AccountClientConfig { pub private_key: String, } +#[derive(uniffi::Record)] pub struct Transaction { pub to: String, pub value: String, pub data: String, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum Error { #[error("Unknown {0}")] Unknown(String), @@ -121,8 +123,6 @@ impl AccountClient { } } -uniffi::include_scaffolding!("yttrium"); - impl From for YTransaction { fn from(transaction: Transaction) -> Self { YTransaction::new_from_strings( diff --git a/crates/kotlin-ffi/src/yttrium.udl b/crates/kotlin-ffi/src/yttrium.udl deleted file mode 100644 index 2d3700d..0000000 --- a/crates/kotlin-ffi/src/yttrium.udl +++ /dev/null @@ -1,38 +0,0 @@ -namespace yttrium { - -}; - -[Error] -enum Error { - "Unknown" -}; - -dictionary Endpoint { - string api_key; - string base_url; -}; - -dictionary Endpoints { - Endpoint rpc; - Endpoint bundler; - Endpoint paymaster; -}; - - dictionary Config { - Endpoints endpoints; - }; - - dictionary AccountClientConfig { - string owner_address; - u64 chain_id; - Config config; - string signer_type; - boolean safe; - string private_key; - }; - - dictionary Transaction { - string to; - string value; - string data; - }; \ No newline at end of file diff --git a/crates/yttrium/Cargo.toml b/crates/yttrium/Cargo.toml index 2524d28..60192c7 100644 --- a/crates/yttrium/Cargo.toml +++ b/crates/yttrium/Cargo.toml @@ -6,10 +6,13 @@ rust-version.workspace = true license.workspace = true [features] -full = [] +full = ["uniffi"] +uniffi = ["dep:uniffi", "dep:uniffi_macros"] test_pimlico_api = [] [dependencies] +uniffi = { version = "0.28.1", optional = true } +uniffi_macros = { version = "0.28.1", optional = true } # Ethereum alloy = { version = "0.3.6", features = [ "contract", diff --git a/crates/yttrium/src/config.rs b/crates/yttrium/src/config.rs index f271ec3..b5c8075 100644 --- a/crates/yttrium/src/config.rs +++ b/crates/yttrium/src/config.rs @@ -6,6 +6,8 @@ const LOCAL_BUNDLER_URL: &str = "http://localhost:4337"; const LOCAL_PAYMASTER_URL: &str = "http://localhost:3000"; #[derive(Clone, Debug, PartialEq)] +#[cfg(feature = "uniffi")] +#[derive(uniffi_macros:: Record)] pub struct Config { pub endpoints: Endpoints, } @@ -21,6 +23,8 @@ impl Config { } #[derive(Clone, Debug, PartialEq)] +#[cfg(feature = "uniffi")] +#[derive(uniffi_macros:: Record)] pub struct Endpoints { pub rpc: Endpoint, pub bundler: Endpoint, @@ -81,6 +85,8 @@ impl Endpoints { } #[derive(Clone, Debug, PartialEq)] +#[cfg(feature = "uniffi")] +#[derive(uniffi_macros:: Record)] pub struct Endpoint { pub base_url: String, pub api_key: String, diff --git a/crates/yttrium/src/lib.rs b/crates/yttrium/src/lib.rs index 8dcb2ef..88236d5 100644 --- a/crates/yttrium/src/lib.rs +++ b/crates/yttrium/src/lib.rs @@ -1,3 +1,5 @@ +uniffi::setup_scaffolding!(); + pub mod account_client; #[cfg(not(target_arch = "wasm32"))] pub mod bundler; diff --git a/justfile b/justfile index 5a106e6..7151b24 100644 --- a/justfile +++ b/justfile @@ -23,4 +23,4 @@ fmt: cargo +nightly fmt --all udeps: - cargo +nightly udeps --workspace + # cargo +nightly udeps --workspace From 5339f206edf624d9394a85e0ffffe17dcfdd016f Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 16 Oct 2024 13:19:02 +0200 Subject: [PATCH 02/37] Generate bindings out of promacros --- .gitignore | 1 + crates/kotlin-ffi/Cargo.toml | 4 ++++ crates/kotlin-ffi/src/lib.rs | 4 ++-- crates/kotlin-ffi/uniffi-bindgen.rs | 3 +++ crates/yttrium/src/account_client.rs | 6 ++++++ justfile | 2 +- 6 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 crates/kotlin-ffi/uniffi-bindgen.rs diff --git a/.gitignore b/.gitignore index 9bdc049..2aaf375 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ Utilities/InstalledSwiftPMConfiguration/config.json .cursorignore /crates/kotlin-ffi/jniLibs /crates/kotlin-ffi/bindings/com/reown/kotlin/ffi/yttrium +/kotlin-bindings diff --git a/crates/kotlin-ffi/Cargo.toml b/crates/kotlin-ffi/Cargo.toml index 4b0dcce..9b9826d 100644 --- a/crates/kotlin-ffi/Cargo.toml +++ b/crates/kotlin-ffi/Cargo.toml @@ -32,3 +32,7 @@ reqwest.workspace = true # Logging log.workspace = true thiserror.workspace = true + +[[bin]] +name = "uniffi-bindgen" +path = "uniffi-bindgen.rs" \ No newline at end of file diff --git a/crates/kotlin-ffi/src/lib.rs b/crates/kotlin-ffi/src/lib.rs index 0dc8455..3e8d3cf 100644 --- a/crates/kotlin-ffi/src/lib.rs +++ b/crates/kotlin-ffi/src/lib.rs @@ -1,7 +1,7 @@ uniffi::setup_scaffolding!(); use yttrium::config::Config; -use yttrium::{ +use yttrium::{ account_client::{AccountClient as YAccountClient, SignerType}, private_key_service::PrivateKeyService, sign_service::address_from_string, @@ -65,7 +65,7 @@ impl AccountClient { Self { owner_address: config.owner_address.clone(), chain_id: config.chain_id, - account_client, + account_client: account_client, } } diff --git a/crates/kotlin-ffi/uniffi-bindgen.rs b/crates/kotlin-ffi/uniffi-bindgen.rs new file mode 100644 index 0000000..d96eac7 --- /dev/null +++ b/crates/kotlin-ffi/uniffi-bindgen.rs @@ -0,0 +1,3 @@ +fn main() { + uniffi::uniffi_bindgen_main() +} \ No newline at end of file diff --git a/crates/yttrium/src/account_client.rs b/crates/yttrium/src/account_client.rs index 88e7a82..059bd82 100644 --- a/crates/yttrium/src/account_client.rs +++ b/crates/yttrium/src/account_client.rs @@ -53,6 +53,8 @@ impl Signer { } #[allow(dead_code)] +#[cfg(feature = "uniffi")] +#[derive(uniffi_macros::Object)] pub struct AccountClient { owner: String, chain_id: u64, @@ -279,6 +281,10 @@ pub async fn get_address_with_private_key_signer( get_sender_address_with_signer(config, chain_id, signer).await? }; + // else { + // unimplemented!() + // }; + Ok(sender_address.to_string()) } diff --git a/justfile b/justfile index 7151b24..5a106e6 100644 --- a/justfile +++ b/justfile @@ -23,4 +23,4 @@ fmt: cargo +nightly fmt --all udeps: - # cargo +nightly udeps --workspace + cargo +nightly udeps --workspace From ae1a095d51ef4523cc94464b1d81d686c16231b4 Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 16 Oct 2024 13:21:20 +0200 Subject: [PATCH 03/37] Clean up --- crates/yttrium/src/account_client.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/yttrium/src/account_client.rs b/crates/yttrium/src/account_client.rs index 059bd82..1ad5be0 100644 --- a/crates/yttrium/src/account_client.rs +++ b/crates/yttrium/src/account_client.rs @@ -281,10 +281,6 @@ pub async fn get_address_with_private_key_signer( get_sender_address_with_signer(config, chain_id, signer).await? }; - // else { - // unimplemented!() - // }; - Ok(sender_address.to_string()) } From 38bd24d919cfb74048e7f932af5e45d652b3f96d Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 16 Oct 2024 13:41:44 +0200 Subject: [PATCH 04/37] Add cli feature to uniffi --- crates/kotlin-ffi/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/kotlin-ffi/Cargo.toml b/crates/kotlin-ffi/Cargo.toml index 9b9826d..20bc9b3 100644 --- a/crates/kotlin-ffi/Cargo.toml +++ b/crates/kotlin-ffi/Cargo.toml @@ -12,7 +12,7 @@ uniffi_build = "0.28.1" [dependencies] yttrium = { path = "../yttrium", features = ["uniffi"] } -uniffi = { version = "0.28.1", features = ["tokio"] } +uniffi = { version = "0.28.1", features = ["tokio", "cli"] } openssl = { version = "0.10", features = ["vendored"] } openssl-sys = { version = "0.9.103", features = ["vendored"] } From e8ae419f6d830cd309a038da7746c57d65d16bac Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 16 Oct 2024 13:49:03 +0200 Subject: [PATCH 05/37] Clean up --- crates/kotlin-ffi/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/kotlin-ffi/src/lib.rs b/crates/kotlin-ffi/src/lib.rs index 3e8d3cf..0d1d6df 100644 --- a/crates/kotlin-ffi/src/lib.rs +++ b/crates/kotlin-ffi/src/lib.rs @@ -65,7 +65,7 @@ impl AccountClient { Self { owner_address: config.owner_address.clone(), chain_id: config.chain_id, - account_client: account_client, + account_client, } } From d8f21b771d4f48e0b57976739f48d11f9152e0b2 Mon Sep 17 00:00:00 2001 From: Chris Smith <1979423+chris13524@users.noreply.github.com> Date: Wed, 16 Oct 2024 08:04:19 -0400 Subject: [PATCH 06/37] chore: test building w/o all features (#43) --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7f0f04..6be4987 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: - run: cargo build --workspace --features=full --all-targets - run: cargo test --features=full --lib --bins - run: cargo clippy --workspace --features=full --all-targets -- -D warnings + - run: cargo clippy --workspace --all-targets -- -D warnings - run: cargo +nightly fmt --all -- --check udeps: From cdcfcdd3236edb7da15fb53f689e1a46061686d7 Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Wed, 16 Oct 2024 14:31:36 +0200 Subject: [PATCH 07/37] Update crates/yttrium/src/lib.rs Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- crates/yttrium/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/yttrium/src/lib.rs b/crates/yttrium/src/lib.rs index 88236d5..bf9f41c 100644 --- a/crates/yttrium/src/lib.rs +++ b/crates/yttrium/src/lib.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "uniffi")] uniffi::setup_scaffolding!(); pub mod account_client; From 92670ff023fcb381559404e7f7a0cffae512aef7 Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Wed, 16 Oct 2024 15:17:55 +0200 Subject: [PATCH 08/37] Update crates/yttrium/src/account_client.rs Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- crates/yttrium/src/account_client.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/yttrium/src/account_client.rs b/crates/yttrium/src/account_client.rs index 1ad5be0..f4382b0 100644 --- a/crates/yttrium/src/account_client.rs +++ b/crates/yttrium/src/account_client.rs @@ -53,8 +53,7 @@ impl Signer { } #[allow(dead_code)] -#[cfg(feature = "uniffi")] -#[derive(uniffi_macros::Object)] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] pub struct AccountClient { owner: String, chain_id: u64, From 846f63cd2a242f61eafb95e55e4069c2aa6aa442 Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Wed, 16 Oct 2024 15:18:04 +0200 Subject: [PATCH 09/37] Update crates/yttrium/src/config.rs Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- crates/yttrium/src/config.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/yttrium/src/config.rs b/crates/yttrium/src/config.rs index b5c8075..e4b8783 100644 --- a/crates/yttrium/src/config.rs +++ b/crates/yttrium/src/config.rs @@ -23,8 +23,7 @@ impl Config { } #[derive(Clone, Debug, PartialEq)] -#[cfg(feature = "uniffi")] -#[derive(uniffi_macros:: Record)] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] pub struct Endpoints { pub rpc: Endpoint, pub bundler: Endpoint, From 4ca465c0e983083f0982286e683d1625b01d58a9 Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Wed, 16 Oct 2024 15:18:13 +0200 Subject: [PATCH 10/37] Update crates/yttrium/src/config.rs Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- crates/yttrium/src/config.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/yttrium/src/config.rs b/crates/yttrium/src/config.rs index e4b8783..53c93ac 100644 --- a/crates/yttrium/src/config.rs +++ b/crates/yttrium/src/config.rs @@ -6,8 +6,7 @@ const LOCAL_BUNDLER_URL: &str = "http://localhost:4337"; const LOCAL_PAYMASTER_URL: &str = "http://localhost:3000"; #[derive(Clone, Debug, PartialEq)] -#[cfg(feature = "uniffi")] -#[derive(uniffi_macros:: Record)] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] pub struct Config { pub endpoints: Endpoints, } From 59697756918a040771499030060883225bc1f5d7 Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Wed, 16 Oct 2024 15:18:20 +0200 Subject: [PATCH 11/37] Update crates/yttrium/src/config.rs Co-authored-by: Chris Smith <1979423+chris13524@users.noreply.github.com> --- crates/yttrium/src/config.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/yttrium/src/config.rs b/crates/yttrium/src/config.rs index 53c93ac..890e1ac 100644 --- a/crates/yttrium/src/config.rs +++ b/crates/yttrium/src/config.rs @@ -83,8 +83,7 @@ impl Endpoints { } #[derive(Clone, Debug, PartialEq)] -#[cfg(feature = "uniffi")] -#[derive(uniffi_macros:: Record)] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] pub struct Endpoint { pub base_url: String, pub api_key: String, From 9a0f061efb21ca66331a9b091ddca9460e287ea2 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 16 Oct 2024 09:23:49 -0400 Subject: [PATCH 12/37] fix: CI check --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6be4987..d34301d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - run: cargo build --workspace --features=full --all-targets - run: cargo test --features=full --lib --bins - run: cargo clippy --workspace --features=full --all-targets -- -D warnings - - run: cargo clippy --workspace --all-targets -- -D warnings + - run: cargo clippy -p yttrium --all-targets -- -D warnings - run: cargo +nightly fmt --all -- --check udeps: From a127e7f5fab182527b0c96b5c47aa4377e80ab77 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 16 Oct 2024 09:39:08 -0400 Subject: [PATCH 13/37] fix: build --- .github/workflows/ci.yml | 2 +- crates/yttrium/src/config.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d34301d..eadfea9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - run: cargo build --workspace --features=full --all-targets - run: cargo test --features=full --lib --bins - run: cargo clippy --workspace --features=full --all-targets -- -D warnings - - run: cargo clippy -p yttrium --all-targets -- -D warnings + - run: cargo clippy -p yttrium --all-targets -- -D warnings # `-p yttrium` to avoid feature unification; kotlin-ffi enables uniffi feature and we want to test without that - run: cargo +nightly fmt --all -- --check udeps: diff --git a/crates/yttrium/src/config.rs b/crates/yttrium/src/config.rs index 890e1ac..d4f0705 100644 --- a/crates/yttrium/src/config.rs +++ b/crates/yttrium/src/config.rs @@ -6,7 +6,7 @@ const LOCAL_BUNDLER_URL: &str = "http://localhost:4337"; const LOCAL_PAYMASTER_URL: &str = "http://localhost:3000"; #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))] pub struct Config { pub endpoints: Endpoints, } @@ -22,7 +22,7 @@ impl Config { } #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))] pub struct Endpoints { pub rpc: Endpoint, pub bundler: Endpoint, @@ -83,7 +83,7 @@ impl Endpoints { } #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Object))] +#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))] pub struct Endpoint { pub base_url: String, pub api_key: String, From 6fa5b11536453a9a67e15a4e22613f110cec1ebf Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 16 Oct 2024 15:51:02 +0200 Subject: [PATCH 14/37] Formatting --- crates/kotlin-ffi/src/lib.rs | 2 +- crates/kotlin-ffi/uniffi-bindgen.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/kotlin-ffi/src/lib.rs b/crates/kotlin-ffi/src/lib.rs index 0d1d6df..0dc8455 100644 --- a/crates/kotlin-ffi/src/lib.rs +++ b/crates/kotlin-ffi/src/lib.rs @@ -1,7 +1,7 @@ uniffi::setup_scaffolding!(); use yttrium::config::Config; -use yttrium::{ +use yttrium::{ account_client::{AccountClient as YAccountClient, SignerType}, private_key_service::PrivateKeyService, sign_service::address_from_string, diff --git a/crates/kotlin-ffi/uniffi-bindgen.rs b/crates/kotlin-ffi/uniffi-bindgen.rs index d96eac7..f6cff6c 100644 --- a/crates/kotlin-ffi/uniffi-bindgen.rs +++ b/crates/kotlin-ffi/uniffi-bindgen.rs @@ -1,3 +1,3 @@ fn main() { uniffi::uniffi_bindgen_main() -} \ No newline at end of file +} From 131779b195c99de0dfc6d5cdd706aea31210214b Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 13:21:31 +0200 Subject: [PATCH 15/37] Add kotlin release workflow --- .github/workflows/release-kotlin.yml | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/release-kotlin.yml diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml new file mode 100644 index 0000000..8ccd66d --- /dev/null +++ b/.github/workflows/release-kotlin.yml @@ -0,0 +1,87 @@ +name: Build and Release Yttrium Kotlin + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g. 0.0.1)' + required: true + +env: + CARGO_TERM_COLOR: always + VERSION: ${{ github.event.inputs.version || '0.0.24' }} + TARGET_BRANCH: ${{ github.ref_name }} + +permissions: + contents: write # Grant write access to repository contents for this workflow + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + target: [aarch64-linux-android, armv7-linux-androideabi] #armeabi-v7a, arm64-v8a + + steps: + - uses: actions/checkout@v3 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + + - name: Install Android NDK + uses: malinskiy/action-android@v2 + with: + components: build-tools;30.0.3 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Build Rust library + run: | + cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli + + - name: Generate Kotlin bindings + run: | + cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/aarch64-linux-android/release/libuniffi_yttrium.so --language kotlin --out-dir kotlin-bindings + # cargo install uniffi_bindgen + # uniffi-bindgen generate src/your_api.udl --language kotlin --out-dir bindings + + - name: Package artifacts + run: | + # Copy the .so files and Kotlin bindings into a single directory + mkdir -p artifacts/libs/${{ matrix.target }} + cp target/${{ matrix.target }}/release/libuniffi_yttrium.so artifacts/libs/${{ matrix.target }}/ + cp -r bindings artifacts/kotlin-bindings + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: Yttrium ${{ env.VERSION }} + draft: false + prerelease: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./kotlin_artifacts.zip + asset_name: artifacts_${{ matrix.target }}.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 5eae3163e9a11a64ff9e787f96650aad5cd8aad3 Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 13:39:18 +0200 Subject: [PATCH 16/37] Add trigger for tests --- .github/workflows/release-kotlin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 8ccd66d..03b1dcb 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -1,6 +1,7 @@ name: Build and Release Yttrium Kotlin on: + pull_request: workflow_dispatch: inputs: version: From 8c9f1d7c9fa57763957fc237f45ce7237155dcb7 Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 13:56:12 +0200 Subject: [PATCH 17/37] Update --- .github/workflows/release-kotlin.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 03b1dcb..777dd23 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -1,12 +1,12 @@ name: Build and Release Yttrium Kotlin on: - pull_request: - workflow_dispatch: - inputs: - version: - description: 'Version to release (e.g. 0.0.1)' - required: true + # workflow_dispatch: + # inputs: + # version: + # description: 'Version to release (e.g. 0.0.1)' + # required: true + push: env: CARGO_TERM_COLOR: always @@ -68,8 +68,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ env.VERSION }} - release_name: Yttrium ${{ env.VERSION }} + tag_name: 0.2.1 #${{ env.VERSION }} + release_name: Yttrium 0.2.1 #${{ env.VERSION }} draft: false prerelease: true env: From 172809f8bc04e7a522717953a2f8d2e70186f208 Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 13:58:33 +0200 Subject: [PATCH 18/37] Fix invalid file --- .github/workflows/release-kotlin.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 777dd23..e970dc6 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -72,8 +72,6 @@ jobs: release_name: Yttrium 0.2.1 #${{ env.VERSION }} draft: false prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload Release Assets uses: actions/upload-release-asset@v1 @@ -83,6 +81,4 @@ jobs: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./kotlin_artifacts.zip asset_name: artifacts_${{ matrix.target }}.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + asset_content_type: application/zip \ No newline at end of file From 88c8987a6f2736e58e63af5e9c6802395f1e025d Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 14:21:54 +0200 Subject: [PATCH 19/37] Update action version --- .github/workflows/release-kotlin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index e970dc6..31cb304 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -35,7 +35,7 @@ jobs: override: true - name: Install Android NDK - uses: malinskiy/action-android@v2 + uses: malinskiy/action-android@v3 with: components: build-tools;30.0.3 From 30a5ead3b87757db0645c02eb4340a00ecb9f0f0 Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 14:48:04 +0200 Subject: [PATCH 20/37] Change action for Android --- .github/workflows/release-kotlin.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 31cb304..e2f8db4 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -34,10 +34,12 @@ jobs: target: ${{ matrix.target }} override: true - - name: Install Android NDK - uses: malinskiy/action-android@v3 + - name: Set up Android SDK + uses: android-actions/setup-android@v3 with: - components: build-tools;30.0.3 + api-level: 35 + build-tools: 35.0.0 + ndk-version: 27.2.12479018 - name: Set up Java uses: actions/setup-java@v3 From d749f236481c56e96f690a5a8235c82b509d28ef Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 14:57:33 +0200 Subject: [PATCH 21/37] Update java versions --- .github/workflows/release-kotlin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index e2f8db4..caea5cb 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -45,7 +45,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' - name: Build Rust library run: | From 535268911e895a35c796104110c54a1f8e604133 Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 14:58:45 +0200 Subject: [PATCH 22/37] Set up java first --- .github/workflows/release-kotlin.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index caea5cb..8040cce 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -33,6 +33,12 @@ jobs: toolchain: stable target: ${{ matrix.target }} override: true + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' - name: Set up Android SDK uses: android-actions/setup-android@v3 @@ -40,12 +46,6 @@ jobs: api-level: 35 build-tools: 35.0.0 ndk-version: 27.2.12479018 - - - name: Set up Java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - name: Build Rust library run: | From b606a141ed2d5df7c8042065154c7cc6ca3a08ec Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 15:21:17 +0200 Subject: [PATCH 23/37] Install cargo ndk --- .github/workflows/release-kotlin.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 8040cce..83dcfd7 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -46,8 +46,14 @@ jobs: api-level: 35 build-tools: 35.0.0 ndk-version: 27.2.12479018 + + - name: Install cargo-ndk + run: | + cargo install cargo-ndk - name: Build Rust library + env: + ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }} run: | cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli From 2b5467213d4a5b970a8c810717872542128732c8 Mon Sep 17 00:00:00 2001 From: kubel Date: Thu, 17 Oct 2024 15:22:52 +0200 Subject: [PATCH 24/37] Update --- .github/workflows/release-kotlin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 83dcfd7..7727da5 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -52,8 +52,8 @@ jobs: cargo install cargo-ndk - name: Build Rust library - env: - ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }} + # env: + # ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }} run: | cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli From 579fc18e26efc407ec43bfc78413799191252766 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 07:34:55 +0200 Subject: [PATCH 25/37] Fix path to binary when generating bindings --- .github/workflows/release-kotlin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 7727da5..6550dd4 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -59,7 +59,7 @@ jobs: - name: Generate Kotlin bindings run: | - cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/aarch64-linux-android/release/libuniffi_yttrium.so --language kotlin --out-dir kotlin-bindings + cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir kotlin-bindings # cargo install uniffi_bindgen # uniffi-bindgen generate src/your_api.udl --language kotlin --out-dir bindings @@ -68,7 +68,7 @@ jobs: # Copy the .so files and Kotlin bindings into a single directory mkdir -p artifacts/libs/${{ matrix.target }} cp target/${{ matrix.target }}/release/libuniffi_yttrium.so artifacts/libs/${{ matrix.target }}/ - cp -r bindings artifacts/kotlin-bindings + cp -r kotlin-bindings artifacts/kotlin-bindings - name: Create Release id: create_release From 6cf77a0134e6f2b074dc34fb2beed2548205fb4a Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 07:47:52 +0200 Subject: [PATCH 26/37] Fix artifacts paths --- .github/workflows/release-kotlin.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 6550dd4..c6f7e52 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -80,6 +80,10 @@ jobs: release_name: Yttrium 0.2.1 #${{ env.VERSION }} draft: false prerelease: true + + - name: Create artifacts zip + run: | + zip -r artifacts_${{ matrix.target }}.zip artifacts/ - name: Upload Release Assets uses: actions/upload-release-asset@v1 @@ -87,6 +91,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./kotlin_artifacts.zip + asset_path: ./artifacts_${{ matrix.target }}.zip asset_name: artifacts_${{ matrix.target }}.zip asset_content_type: application/zip \ No newline at end of file From 42e3c62797a5285fcdb68051aff21a70d2d134a3 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 08:46:25 +0200 Subject: [PATCH 27/37] Create a separate job for a release --- .github/workflows/release-kotlin.yml | 47 +++++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index c6f7e52..6b95de2 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - target: [aarch64-linux-android, armv7-linux-androideabi] #armeabi-v7a, arm64-v8a + target: [aarch64-linux-android, armv7-linux-androideabi] steps: - uses: actions/checkout@v3 @@ -52,8 +52,6 @@ jobs: cargo install cargo-ndk - name: Build Rust library - # env: - # ANDROID_NDK_HOME: ${{ env.ANDROID_NDK_HOME }} run: | cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli @@ -69,21 +67,46 @@ jobs: mkdir -p artifacts/libs/${{ matrix.target }} cp target/${{ matrix.target }}/release/libuniffi_yttrium.so artifacts/libs/${{ matrix.target }}/ cp -r kotlin-bindings artifacts/kotlin-bindings - + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: artifacts-${{ matrix.target }} + path: artifacts/ + + release: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: artifacts-* + path: downloaded-artifacts + + - name: Create artifacts zip + run: | + cd downloaded-artifacts + zip -r artifacts.zip ./* + + # - name: Create artifacts zip + # run: | + # zip -r artifacts_${{ matrix.target }}.zip artifacts/ + - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: 0.2.1 #${{ env.VERSION }} - release_name: Yttrium 0.2.1 #${{ env.VERSION }} + tag_name: 0.2.1 # Replace with dynamic version if needed + release_name: Yttrium 0.2.1 draft: false prerelease: true - - - name: Create artifacts zip - run: | - zip -r artifacts_${{ matrix.target }}.zip artifacts/ - name: Upload Release Assets uses: actions/upload-release-asset@v1 @@ -91,6 +114,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./artifacts_${{ matrix.target }}.zip - asset_name: artifacts_${{ matrix.target }}.zip + asset_path: downloaded-artifacts/artifacts.zip + asset_name: artifacts.zip asset_content_type: application/zip \ No newline at end of file From 81826bd201d8399da52f15deac2361600b7646ff Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 08:48:43 +0200 Subject: [PATCH 28/37] Change job names --- .github/workflows/release-kotlin.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 6b95de2..a11e10c 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -17,7 +17,7 @@ permissions: contents: write # Grant write access to repository contents for this workflow jobs: - build: + build-kotlin-artifacts: runs-on: ubuntu-latest strategy: @@ -73,9 +73,9 @@ jobs: with: name: artifacts-${{ matrix.target }} path: artifacts/ - - release: - needs: build + + release-kotlin-artifacts: + needs: build-kotlin-artifacts runs-on: ubuntu-latest steps: From 34abefbfc3023261f2ecb66ba35bbf58a1f971e4 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 08:53:44 +0200 Subject: [PATCH 29/37] FIX FILE --- .github/workflows/release-kotlin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index a11e10c..c0ff076 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -82,7 +82,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Download artifacts + - name: Download artifacts uses: actions/download-artifact@v3 with: name: artifacts-* From 870c56706a33cf80c0471df83c75070d81ef449d Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 09:10:06 +0200 Subject: [PATCH 30/37] Remove wildcart --- .github/workflows/release-kotlin.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index c0ff076..8ff348e 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -85,12 +85,12 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - name: artifacts-* - path: downloaded-artifacts + # name: artifacts-* + path: kotlin-artifacts - name: Create artifacts zip run: | - cd downloaded-artifacts + cd kotlin-artifacts zip -r artifacts.zip ./* # - name: Create artifacts zip @@ -114,6 +114,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: downloaded-artifacts/artifacts.zip + asset_path: kotlin-artifacts/artifacts.zip asset_name: artifacts.zip asset_content_type: application/zip \ No newline at end of file From 059306e8e7ac97aadbeaf81548de9586449617f9 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 09:23:36 +0200 Subject: [PATCH 31/37] Change asset name --- .github/workflows/release-kotlin.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 8ff348e..f91f902 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -14,7 +14,7 @@ env: TARGET_BRANCH: ${{ github.ref_name }} permissions: - contents: write # Grant write access to repository contents for this workflow + contents: write jobs: build-kotlin-artifacts: @@ -58,12 +58,9 @@ jobs: - name: Generate Kotlin bindings run: | cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir kotlin-bindings - # cargo install uniffi_bindgen - # uniffi-bindgen generate src/your_api.udl --language kotlin --out-dir bindings - name: Package artifacts run: | - # Copy the .so files and Kotlin bindings into a single directory mkdir -p artifacts/libs/${{ matrix.target }} cp target/${{ matrix.target }}/release/libuniffi_yttrium.so artifacts/libs/${{ matrix.target }}/ cp -r kotlin-bindings artifacts/kotlin-bindings @@ -85,17 +82,12 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - # name: artifacts-* path: kotlin-artifacts - name: Create artifacts zip run: | cd kotlin-artifacts - zip -r artifacts.zip ./* - - # - name: Create artifacts zip - # run: | - # zip -r artifacts_${{ matrix.target }}.zip artifacts/ + zip -r kotlin-artifacts.zip ./* - name: Create Release id: create_release @@ -114,6 +106,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: kotlin-artifacts/artifacts.zip - asset_name: artifacts.zip + asset_path: kotlin-artifacts/kotlin-artifacts.zip + asset_name: kotlin-artifacts.zip asset_content_type: application/zip \ No newline at end of file From b970c25f0d7dc8335511b2adb77c7f139fb739f6 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 11:39:51 +0200 Subject: [PATCH 32/37] Remove package name --- .github/workflows/release-kotlin.yml | 2 +- crates/kotlin-ffi/uniffi.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index f91f902..d2ca61b 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -68,7 +68,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: artifacts-${{ matrix.target }} + name: ${{ matrix.target }} path: artifacts/ release-kotlin-artifacts: diff --git a/crates/kotlin-ffi/uniffi.toml b/crates/kotlin-ffi/uniffi.toml index 8ceba2c..dd43a49 100644 --- a/crates/kotlin-ffi/uniffi.toml +++ b/crates/kotlin-ffi/uniffi.toml @@ -1,4 +1,3 @@ [bindings.kotlin] -package_name = "com.reown.kotlin.ffi.yttrium" android = true android_cleaner = true \ No newline at end of file From 8fc3316937b611669834c36d2cebcf4afb01d53a Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 12:11:22 +0200 Subject: [PATCH 33/37] Update targets --- .github/workflows/release-kotlin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index d2ca61b..5848aac 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - target: [aarch64-linux-android, armv7-linux-androideabi] + target: [aarm64-v8a, armeabi-v7a] steps: - uses: actions/checkout@v3 From d64fdc75af14bddbce269f84fca25626f22974e1 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 12:13:11 +0200 Subject: [PATCH 34/37] Retert targets --- .github/workflows/release-kotlin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 5848aac..d2ca61b 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - target: [aarm64-v8a, armeabi-v7a] + target: [aarch64-linux-android, armv7-linux-androideabi] steps: - uses: actions/checkout@v3 From 95a62a93906a0f2ce93f7e2c28e670ecd53bb3fe Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 12:59:49 +0200 Subject: [PATCH 35/37] Update dir structure --- .github/workflows/release-kotlin.yml | 36 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index d2ca61b..5d65f1d 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -55,21 +55,32 @@ jobs: run: | cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli - - name: Generate Kotlin bindings + - name: Generate Kotlin bindings (once) + if: ${{ matrix.target == 'aarch64-linux-android' }} run: | - cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir kotlin-bindings + cargo run --features=uniffi/cli --bin uniffi-bindgen generate --library target/${{ matrix.target }}/release/libuniffi_yttrium.so --language kotlin --out-dir yttrium/kotlin-bindings - - name: Package artifacts - run: | - mkdir -p artifacts/libs/${{ matrix.target }} - cp target/${{ matrix.target }}/release/libuniffi_yttrium.so artifacts/libs/${{ matrix.target }}/ - cp -r kotlin-bindings artifacts/kotlin-bindings + - name: Prepare artifacts + run: | + # Map Rust targets to Android ABI names + declare -A abi_map + abi_map[aarch64-linux-android]="arm64-v8a" + abi_map[armv7-linux-androideabi]="armeabi-v7a" + + abi_name=${abi_map[${{ matrix.target }}]} + if [ -z "$abi_name" ]; then + echo "Unknown ABI for target ${{ matrix.target }}" + exit 1 + fi + + mkdir -p yttrium/libs/$abi_name + cp target/${{ matrix.target }}/release/libuniffi_yttrium.so yttrium/libs/$abi_name/ - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: ${{ matrix.target }} - path: artifacts/ + name: artifacts + path: yttrium/ release-kotlin-artifacts: needs: build-kotlin-artifacts @@ -82,12 +93,13 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - path: kotlin-artifacts + name: artifacts + path: yttrium/ - name: Create artifacts zip run: | cd kotlin-artifacts - zip -r kotlin-artifacts.zip ./* + zip -r kotlin-artifacts.zip yttrium/ - name: Create Release id: create_release @@ -106,6 +118,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: kotlin-artifacts/kotlin-artifacts.zip + asset_path: kotlin-artifacts.zip asset_name: kotlin-artifacts.zip asset_content_type: application/zip \ No newline at end of file From 9ebac07bc6c9b4734440123b0f04741e7e94b0df Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 13:08:59 +0200 Subject: [PATCH 36/37] Fix creating zip --- .github/workflows/release-kotlin.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 5d65f1d..3bc4c00 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -98,7 +98,6 @@ jobs: - name: Create artifacts zip run: | - cd kotlin-artifacts zip -r kotlin-artifacts.zip yttrium/ - name: Create Release From 77305e255245bb1e7629e2b1ca8b8c565ed91a69 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 18 Oct 2024 14:11:11 +0200 Subject: [PATCH 37/37] Use workflow dispatch --- .github/workflows/release-kotlin.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-kotlin.yml b/.github/workflows/release-kotlin.yml index 3bc4c00..4a4aec0 100644 --- a/.github/workflows/release-kotlin.yml +++ b/.github/workflows/release-kotlin.yml @@ -1,12 +1,11 @@ name: Build and Release Yttrium Kotlin on: - # workflow_dispatch: - # inputs: - # version: - # description: 'Version to release (e.g. 0.0.1)' - # required: true - push: + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g. 0.0.1)' + required: true env: CARGO_TERM_COLOR: always @@ -106,8 +105,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: 0.2.1 # Replace with dynamic version if needed - release_name: Yttrium 0.2.1 + tag_name: ${{ env.VERSION }} + release_name: Yttrium ${{ env.VERSION }} draft: false prerelease: true