Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .github/workflows/android-bindgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Android Bindgen

on:
pull_request:
paths:
- '.cargo/**'
- '.github/workflows/android-bindgen.yml'
- '**/Cargo.lock'
- '**/Cargo.toml'
- '**/bindings/android/**'
- '**/build*.sh'
- '**/build.rs'
- '**/*.gradle*'
- '**/*.rs'
- '**/*.udl'
- '**/gradle/**'
- '**/gradle.properties'
- '**/gradlew*'
- '**/settings.gradle*'
- '**/uniffi*.toml'
- 'rust-toolchain*'
- 'vendor/**'
push:
branches:
- master
- main
paths:
- '.cargo/**'
- '.github/workflows/android-bindgen.yml'
- '**/Cargo.lock'
- '**/Cargo.toml'
- '**/bindings/android/**'
- '**/build*.sh'
- '**/build.rs'
- '**/*.gradle*'
- '**/*.rs'
- '**/*.udl'
- '**/gradle/**'
- '**/gradle.properties'
- '**/gradlew*'
- '**/settings.gradle*'
- '**/uniffi*.toml'
- 'rust-toolchain*'
- 'vendor/**'
workflow_dispatch:
inputs:
ref:
description: "Branch, tag, or SHA to build"
required: false
default: ""

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
android-bindgen:
name: Android Bindgen
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-targets: false

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-dev pkg-config protobuf-compiler zip unzip

- name: Set up Android SDK
uses: android-actions/setup-android@v3

- name: Set up Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r28c
add-to-path: true

- name: Export Android NDK paths
run: |
echo "ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >> "$GITHUB_ENV"
echo "ANDROID_NDK_ROOT=${{ steps.setup-ndk.outputs.ndk-path }}" >> "$GITHUB_ENV"
echo "ANDROID_NDK_PATH=${{ steps.setup-ndk.outputs.ndk-path }}" >> "$GITHUB_ENV"
echo "NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >> "$GITHUB_ENV"

- name: Generate Android bindings and native libraries
run: ./build_android.sh

- name: Verify Android outputs
shell: bash
run: |
set -euo pipefail
required=(
bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt
bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt
bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so
bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so
bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so
bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so
bindings/android/native-debug-symbols.zip
)

for path in "${required[@]}"; do
if [ ! -s "$path" ]; then
echo "::error::Missing or empty generated Android output: $path"
exit 1
fi
done

aar_count=$(find bindings/android/lib/build/outputs/aar -name '*release.aar' -type f | wc -l | tr -d ' ')
if [ "$aar_count" -eq 0 ]; then
echo "::error::Missing generated Android release AAR"
exit 1
fi

- name: Upload Android generated artifacts
uses: actions/upload-artifact@v4
with:
name: bitkit-core-android-bindgen
path: |
bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/*.kt
bindings/android/lib/src/main/jniLibs/**/libbitkitcore.so
bindings/android/native-debug-symbols.zip
bindings/android/lib/build/outputs/aar/*release.aar
if-no-files-found: error
63 changes: 63 additions & 0 deletions .github/workflows/bindgen-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Bindgen Validation

on:
pull_request:
push:
branches:
- master
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
validate:
name: Scripts, Cargo, and Android manifests
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Validate shell scripts
run: bash -n build.sh build_ios.sh build_android.sh build_python.sh

- name: Validate Cargo manifest
run: cargo metadata --locked --format-version 1 > /dev/null

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Set up Android SDK
uses: android-actions/setup-android@v3

- name: Validate Android Gradle manifests
working-directory: bindings/android
run: ./gradlew projects --no-daemon

swift-manifest:
name: SwiftPM manifest
runs-on: macos-15
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate SwiftPM manifest
run: swift package dump-package > /dev/null
124 changes: 124 additions & 0 deletions .github/workflows/ios-bindgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: iOS Bindgen

on:
pull_request:
paths:
- '.cargo/**'
- '.github/workflows/ios-bindgen.yml'
- '**/Cargo.lock'
- '**/Cargo.toml'
- '**/Package.swift'
- '**/bindings/ios/**'
- '**/build*.sh'
- '**/build.rs'
- '**/*.rs'
- '**/*.udl'
- '**/uniffi*.toml'
- 'rust-toolchain*'
- 'vendor/**'
push:
branches:
- master
- main
paths:
- '.cargo/**'
- '.github/workflows/ios-bindgen.yml'
- '**/Cargo.lock'
- '**/Cargo.toml'
- '**/Package.swift'
- '**/bindings/ios/**'
- '**/build*.sh'
- '**/build.rs'
- '**/*.rs'
- '**/*.udl'
- '**/uniffi*.toml'
- 'rust-toolchain*'
- 'vendor/**'
workflow_dispatch:
inputs:
ref:
description: "Branch, tag, or SHA to build"
required: false
default: ""

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
ios-bindgen:
name: iOS Bindgen
runs-on: macos-15
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-targets: false

- name: Install native build dependencies
run: brew install protobuf

- name: Generate iOS bindings and artifacts
run: ./build_ios.sh

- name: Verify iOS outputs
shell: bash
run: |
set -euo pipefail
required=(
bindings/ios/bitkitcore.swift
bindings/ios/bitkitcoreFFI.h
bindings/ios/module.modulemap
dist/ios/BitkitCore.xcframework
dist/ios/BitkitCore.xcframework.zip
)

for path in "${required[@]}"; do
if [ ! -e "$path" ]; then
echo "::error::Missing generated iOS output: $path"
exit 1
fi
done

test -s dist/ios/BitkitCore.xcframework.zip
swift package compute-checksum dist/ios/BitkitCore.xcframework.zip

- name: Check committed iOS interface files
shell: bash
run: |
set -euo pipefail
generated_sources=(
bindings/ios/bitkitcore.swift
bindings/ios/bitkitcoreFFI.h
bindings/ios/module.modulemap
)

if ! git diff --quiet -- "${generated_sources[@]}"; then
echo "::error::Committed iOS interface files are stale. Run './build_ios.sh', restore Package.swift unless preparing a release, and commit the updated interface files."
git diff --name-only -- "${generated_sources[@]}"
exit 1
fi

- name: Upload iOS generated artifacts
uses: actions/upload-artifact@v4
with:
name: bitkit-core-ios-bindgen
path: |
bindings/ios/bitkitcore.swift
bindings/ios/bitkitcoreFFI.h
bindings/ios/module.modulemap
dist/ios/BitkitCore.xcframework.zip
if-no-files-found: error
16 changes: 11 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
target/
.build/
.swiftpm/
__pycache__/
*.pyc

# Generated Android bindgen outputs
bindings/android/native-debug-symbols.zip
bindings/android/lib/src/main/jniLibs/
# The xcframework's static libraries exceed GitHub's 100 MB file limit. They are
# already shipped, compressed, inside BitkitCore.xcframework.zip, which is what
# Package.swift downloads from the GitHub release, so tracking them here would
# only duplicate that payload.
bindings/ios/BitkitCore.xcframework/**/libbitkitcore.a
bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt
bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt

# Generated iOS release artifacts
dist/
bindings/ios/BitkitCore.xcframework/
bindings/ios/BitkitCore.xcframework.zip
.idea/
.DS_Store
# AI
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@
./build.sh python # Python only
```

Generated mobile binaries are not committed. iOS release artifacts are generated
under `dist/ios/`; `Package.swift` points at the matching GitHub Release asset.
Android Kotlin/JNI outputs are regenerated by `./build_android.sh` before local
publishing or CI validation.

### Release Builds (with version bump)
The `-r/--release` flag bumps versions in `Cargo.toml`, `Package.swift`, and `gradle.properties`, then builds.
Defaults to patch version bump; use `--major`/`-M` or `--minor`/`-m` for other increments.
Expand Down
Loading
Loading