Build and Release Yttrium Dart #1
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: Build and Release Yttrium Dart | |
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.1' }} | |
TARGET_BRANCH: ${{ github.ref_name }} | |
permissions: | |
contents: write | |
jobs: | |
build-android-artifacts: | |
runs-on: macos-latest-xlarge | |
steps: | |
- uses: actions/checkout@v3 | |
# Install Rust toolchain | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rust-src | |
# Install Java 17 | |
- name: Install Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
architecture: x86_64 | |
cache: 'gradle' | |
# Cache Gradle | |
- name: Cache Gradle | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Install cargo-ndk | |
- name: Install cargo-ndk | |
run: | | |
cargo install cargo-ndk | |
# Install Flutter | |
- name: Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24.5' | |
# Get package dependencies and generate files | |
- name: Get package dependencies | |
shell: bash | |
working-directory: crates/yttrium_dart | |
run: | | |
flutter pub get | |
# Generate Dart Bindings | |
- name: Generate Dart Bindings | |
shell: bash | |
working-directory: crates/yttrium_dart | |
run: | | |
flutter_rust_bridge_codegen generate --config-file flutter_rust_bridge.yaml | |
# Build Native libraries | |
- name: Build Rust library | |
shell: bash | |
working-directory: crates/yttrium_dart/rust | |
run: | | |
rustup target add armv7-linux-androideabi aarch64-linux-android | |
cargo ndk -t armeabi-v7a -t arm64-v8a build --release | |
# Prepare artifacts | |
- name: Prepare artifacts | |
shell: bash | |
run: | | |
mkdir -p yttrium/jniLibs/arm64-v8a | |
mkdir -p yttrium/jniLibs/armeabi-v7a | |
cp target/aarch64-linux-android/release/libyttrium_dart.so yttrium/jniLibs/arm64-v8a/libyttrium_dart.so | |
cp target/armv7-linux-androideabi/release/libyttrium_dart.so yttrium/jniLibs/armeabi-v7a/libyttrium_dart.so | |
# Upload artifacts | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts | |
path: yttrium/ | |
create-github-release: | |
needs: build-android-artifacts | |
runs-on: macos-latest-xlarge | |
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 dart-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: YttriumDart ${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- 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: dart-artifacts.zip | |
asset_name: dart-artifacts.zip | |
asset_content_type: application/zip | |
# Launch locally | |
# act -j build-android-artifacts --container-architecture linux/amd64 -P macos-latest-xlarge=-self-hosted --secret-file .github/workflows/.env.secret -W .github/workflows/release-dart.yml |