Skip to content

Commit

Permalink
feat: Kotlin CI (#45)
Browse files Browse the repository at this point in the history
* Build binaries without UDL file

* Generate bindings out of promacros

* Clean up

* Add cli feature to uniffi

* Clean up

* chore: test building w/o all features (#43)

* Update crates/yttrium/src/lib.rs

Co-authored-by: Chris Smith <[email protected]>

* Update crates/yttrium/src/account_client.rs

Co-authored-by: Chris Smith <[email protected]>

* Update crates/yttrium/src/config.rs

Co-authored-by: Chris Smith <[email protected]>

* Update crates/yttrium/src/config.rs

Co-authored-by: Chris Smith <[email protected]>

* Update crates/yttrium/src/config.rs

Co-authored-by: Chris Smith <[email protected]>

* fix: CI check

* fix: build

* Formatting

* Add kotlin release workflow

* Add trigger for tests

* Update

* Fix invalid file

* Update action version

* Change action for Android

* Update java versions

* Set up java first

* Install cargo ndk

* Update

* Fix path to binary when generating bindings

* Fix artifacts paths

* Create a separate job for a release

* Change job names

* FIX FILE

* Remove wildcart

* Change asset name

* Remove package name

* Update targets

* Retert targets

* Update dir structure

* Fix creating zip

* Use workflow dispatch

---------

Co-authored-by: Chris Smith <[email protected]>
Co-authored-by: Chris Smith <[email protected]>
  • Loading branch information
3 people authored Oct 28, 2024
1 parent 983d5b9 commit 336792b
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
121 changes: 121 additions & 0 deletions .github/workflows/release-kotlin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
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

jobs:
build-kotlin-artifacts:
runs-on: ubuntu-latest

strategy:
matrix:
target: [aarch64-linux-android, armv7-linux-androideabi]

steps:
- uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
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
with:
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
run: |
cargo ndk -t ${{ matrix.target }} build --release --features=uniffi/cli
- 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 yttrium/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: artifacts
path: yttrium/

release-kotlin-artifacts:
needs: build-kotlin-artifacts
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: yttrium/

- name: Create artifacts zip
run: |
zip -r kotlin-artifacts.zip yttrium/
- 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

- 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: kotlin-artifacts.zip
asset_content_type: application/zip
1 change: 0 additions & 1 deletion crates/kotlin-ffi/uniffi.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[bindings.kotlin]
package_name = "com.reown.kotlin.ffi.yttrium"
android = true
android_cleaner = true

0 comments on commit 336792b

Please sign in to comment.