Add release ci for xcframework #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
release: | |
types: [created] | |
env: | |
CARGO_TERM_COLOR: always | |
TOOLCHAIN: nightly | |
CARGO_MAKE_TOOLCHAIN: nightly | |
ANDROID_API: 33 | |
ANDROID_NDK_VERSION: 25.2.9519653 | |
jobs: | |
kotiln_integration_tests: | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
targets: | |
armv7-linux-androideabi | |
aarch64-linux-android | |
i686-linux-android | |
x86_64-linux-android | |
x86_64-unknown-linux-gnu | |
aarch64-apple-darwin | |
x86_64-apple-darwin | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Install gradle | |
uses: gradle/[email protected] | |
# https://github.com/actions/runner-images/blob/5a9870800dc54127d22ee36c303b47314d231c69/images/macos/macos-14-arm64-Readme.md | |
# Python is required to build OpenSSL but there's no python in the m1 | |
# macos runners. | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Run build with Gradle wrapper | |
working-directory: ./crates/core/liveview-native-core-jetpack/ | |
env: | |
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib" | |
run: | |
./gradlew build --scan | |
swift_integration_tests: | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: rust-src | |
targets: | |
aarch64-apple-ios-sim | |
aarch64-apple-ios | |
x86_64-apple-ios | |
aarch64-apple-darwin | |
x86_64-apple-darwin | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-make | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build swift package | |
run: cargo make uniffi-swift-package | |
- name: Test swift package | |
run: cargo make uniffi-swift-test # This also runs the uniffi-swift-package step. | |
integration_tests: | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Get the JNA jar for testing kotlin. | |
run: wget 'https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.14.0/jna-5.14.0.jar' | |
- name: Test | |
run: cargo test | |
env: | |
# This is required for the kotlin uniffi tests | |
CLASSPATH: "/Users/runner/work/liveview-native-core/liveview-native-core/jna-5.14.0.jar:/opt/homebrew/opt/kotlin/libexec/lib/kotlinx-coroutines-core-jvm.jar" | |
apple_simulator_tests: | |
# rust cross-compilation | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
rust-target: ["aarch64-apple-ios-sim" ] | |
apple-sim: [ "iOS" ] | |
os: [ macos-14 ] | |
include: | |
- rust-target: "aarch64-apple-tvos-sim" | |
os: macos-14 | |
apple-sim: "tvOS" | |
- rust-target: "aarch64-apple-watchos-sim" | |
os: macos-14 | |
apple-sim: "watchOS" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: rust-src | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ github.workflow }}-${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- name: Start Simulator | |
uses: futureware-tech/simulator-action@v3 | |
with: | |
os: ${{ matrix.apple-sim }} | |
- name: Build tests | |
run: | | |
cargo -Zbuild-std test --target ${{ matrix.rust-target }} --no-run | |
- name: Run Rust tests on simulator for ${{ matrix.rust-target }} | |
env: | |
DINGHY_LOG: debug | |
timeout-minutes: 20 | |
run: | | |
cargo dinghy all-platforms | |
cargo dinghy all-devices | |
cargo -Zbuild-std test --target ${{ matrix.rust-target }} | |
- name: Set up Elixir | |
run: brew install elixir | |
- name: Install test server dependencies, compile and run in background | |
working-directory: ./tests/support/test_server | |
run: | | |
mix deps.get | |
mix compile | |
mix phx.server & | |
- name: Build tests with liveview-channels | |
run: cargo -Zbuild-std test --target ${{ matrix.rust-target }} --features liveview-channels --no-run | |
- name: Run Rust tests on simulator for ${{ matrix.rust-target }} with liveview-channels | |
env: | |
DINGHY_LOG: debug | |
timeout-minutes: 20 | |
run: | | |
cargo -Zbuild-std test --target ${{ matrix.rust-target }} --features liveview-channels -- --test-threads 1 | |
- name: Build tests with liveview-channels-tls | |
run: cargo -Zbuild-std test --target ${{ matrix.rust-target }} --features liveview-channels-tls --no-run | |
- name: Run Rust tests on simulator for ${{ matrix.rust-target }} with liveview-channels-tls | |
env: | |
DINGHY_LOG: debug | |
timeout-minutes: 20 | |
run: | | |
cargo -Zbuild-std test --target ${{ matrix.rust-target }} --features liveview-channels-tls -- --test-threads 1 | |
android_simulator_tests: | |
# rust cross-compilation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
target: x86_64-linux-android | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
# TODO: Fix this when enabling live-channels feature flag. | |
# - name: Cache deps | |
# id: cache-deps | |
# uses: actions/cache@v4 | |
# env: | |
# cache-name: cache-elixir-deps | |
# with: | |
# path: tests/support/test_server/deps | |
# key: ${{ runner.os }}-mix-${{ env.cache-name }}-deps-${{ hashFiles('**/mix.lock') }} | |
# | |
# - name: Cache compiled build | |
# id: cache-build | |
# uses: actions/cache@v4 | |
# env: | |
# cache-name: cache-compiled-build | |
# with: | |
# path: tests/support/test_server/_build | |
# key: ${{ runner.os }}-mix-${{ env.cache-name }}-build-${{ hashFiles('**/mix.lock') }} | |
# | |
# - uses: erlef/setup-beam@v1 | |
# with: | |
# elixir-version: 1.15 | |
# otp-version: 25 | |
# | |
# - name: Install test server dependencies, compile and run in background | |
# working-directory: ./tests/support/test_server | |
# run: | | |
# mix deps.get | |
# mix compile | |
# mix phx.server & | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Gradle cache | |
uses: gradle/actions/setup-gradle@v3 | |
- name: AVD cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ env.ANDROID_API }} | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ env.ANDROID_API }} | |
ndk: ${{ env.ANDROID_NDK_VERSION }} | |
force-avd-creation: false | |
target: google_apis | |
arch: x86_64 | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
- name: Run tests in android emulator | |
uses: reactivecircus/android-emulator-runner@v2 | |
env: | |
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" | |
with: | |
api-level: ${{ env.ANDROID_API }} | |
ndk: ${{ env.ANDROID_NDK_VERSION }} | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: | | |
cargo dinghy all-platforms | |
cargo dinghy all-devices | |
cargo dinghy -p auto-android-x86_64-api${ANDROID_API} test -- --test-threads 1 | |
build-xcframework: | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
components: rust-src | |
targets: | |
aarch64-apple-ios-sim | |
aarch64-apple-ios | |
x86_64-apple-ios | |
aarch64-apple-darwin | |
x86_64-apple-darwin | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.TOOLCHAIN }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-make | |
- name: Build XCFramework | |
run: | | |
cargo make --profile release uniffi-xcframework | |
ditto -c -k --sequesterRsrc --keepParent target/uniffi/swift/liveview_native_core.xcframework/ target/uniffi/swift/liveview_native_core.xcframework.zip | |
- uses: actions/upload-artifact@v4 | |
with: | |
retention-days: 5 | |
name: liveview_native_core.xcframework | |
path: ./target/uniffi/swift/liveview_native_core.xcframework.zip | |
tag-release: | |
runs-on: macos-14 | |
permissions: | |
contents: write | |
needs: | |
- build-xcframework | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Nightly | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.TOOLCHAIN }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-make | |
- name: Build XCFramework | |
run: | | |
cargo make --profile release uniffi-swift-generate | |
- uses: actions/download-artifact@v4 | |
with: | |
name: liveview_native_core.xcframework.zip | |
path: ./target/uniffi/swift/liveview_native_core.xcframework.zip | |
- name: Update version and checksum of xcframework in Package.swift | |
run: | | |
checksum=$(swift package compute-checksum ./target/uniffi/swift/liveview_native_core.xcframework.zip) | |
version=${{ github.event.release.tag_name }} | |
sed -i "" -E "s/(let releaseTag = \")[^\"]+(\")/\1$version\2/g" Package.swift | |
sed -i "" -E "s/(let releaseChecksum = \")[^\"]+(\")/\1$checksum\2/g" Package.swift | |
sed -i "" -E "s/let useLocalFramework = true/let useLocalFramework = false/g" Package.swift | |
git add Package.swift | |
git add ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/LiveViewNativeCore.swift | |
git diff --staged | |
- name: Commit, tag and push swift package | |
if: github.event_name == 'release' | |
run: | | |
git add Package.swift | |
git add ./crates/core/liveview-native-core-swift/Sources/LiveViewNativeCore/LiveViewNativeCore.swift | |
git tag -fa ${{ github.event.release.tag_name }} -m "Swift Package Release ${{ github.event.release.tag_name }}" | |
git push origin ${{ github.event.release.tag_name }} --force | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: github.event_name == 'release' | |
with: | |
files: ./target/uniffi/swift/liveview_native_core.xcframework.zip | |
draft: true | |
prerelease: true | |
tag_name: ${{ github.event.release.tag_name }} |