Skip to content

Release

Release #95

Workflow file for this run

name: Release
on:
workflow_dispatch:
env:
flutter_channel: 'stable'
LLVM_VERSION: '10.0'
GH_TOKEN: ${{ secrets.GH_TOKEN }}
RUST_TOOLCHAIN: nightly-2023-10-31
NDK_VERSION: 25.2.9519653
jobs:
ci-pass:
name: CI is green
runs-on: ubuntu-latest
needs:
- check_release
- build_release_assets
steps:
- run: exit 0
check_release:
name: Check release
runs-on: ubuntu-latest
steps:
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
path: 'daisy'
- name: Cargo ci build cache
uses: actions/cache@v3
with:
path: |
daisy/ci/target/
key: ${{ runner.os }}-cargo-ci_target
- name: Check release
run: |
cd daisy/ci
cargo run --release --bin check-release
build_release_assets:
name: Build release assets
needs:
- check_release
strategy:
fail-fast: false
matrix:
config:
- target: linux
host: ubuntu-latest
flutter_version: '3.7.3'
- target: windows
host: windows-latest
flutter_version: '3.7.3'
- target: macos
host: macos-11
flutter_version: '3.7.3'
- target: ios
host: macos-11
flutter_version: '3.7.3'
- target: android-arm32
host: ubuntu-latest
flutter_version: '2.10.5'
- target: android-arm64
host: ubuntu-latest
flutter_version: '2.10.5'
- target: android-x86_64
host: ubuntu-latest
flutter_version: '2.10.5'
- target: android-arm32
host: ubuntu-latest
flutter_version: '3.7.3'
- target: android-arm64
host: ubuntu-latest
flutter_version: '3.7.3'
- target: android-x86_64
host: ubuntu-latest
flutter_version: '3.7.3'
runs-on: ${{ matrix.config.host }}
env:
TARGET: ${{ matrix.config.target }}
flutter_version: ${{ matrix.config.flutter_version }}
flutter_channel: ${{ matrix.config.flutter_channel }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: 'daisy'
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
components: rustfmt
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Cargo ci build cache
uses: actions/cache@v3
with:
path: |
daisy/ci/target/
key: ${{ runner.os }}-cargo-ci_target
- id: check_asset
name: Check asset
run: |
cd daisy/ci
cargo run --release --bin check-asset
- name: Check core
if: steps.check_asset.outputs.skip_build != 'true'
uses: actions/checkout@v3
with:
repository: 'niuhuan/daisy-rs-core'
token: ${{ secrets.GH_TOKEN }}
path: 'daisy/native'
- name: Check bridge
if: steps.check_asset.outputs.skip_build != 'true' && !startsWith(matrix.config.flutter_version, '2')
uses: actions/checkout@v3
with:
repository: 'fzyzcjy/flutter_rust_bridge'
path: 'flutter_rust_bridge'
ref: 'v1.54.0'
- name: Check bridge
if: steps.check_asset.outputs.skip_build != 'true' && startsWith(matrix.config.flutter_version, '2')
uses: actions/checkout@v3
with:
repository: 'fzyzcjy/flutter_rust_bridge'
path: 'flutter_rust_bridge'
ref: 'v1.22.0'
- name: Install flutter_rust_bridge
if: steps.check_asset.outputs.skip_build != 'true'
run: |
cd flutter_rust_bridge/frb_codegen
cargo install --path . --force
cd ../..
- name: Cache Flutter dependencies (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'linux' )
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/flutter
key: ${{ runner.os }}-flutter
- name: Setup flutter
if: steps.check_asset.outputs.skip_build != 'true'
uses: subosito/flutter-action@v2
with:
channel: ${{ env.flutter_channel }}
flutter-version: ${{ env.flutter_version }}
architecture: x64
- name: Setup ffigen (flutter2)
if: steps.check_asset.outputs.skip_build != 'true' && startsWith(matrix.config.flutter_version, '2')
run: |
dart pub global activate ffigen 4.1.3
- name: Install LLVM and Clang (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'linux' ) && !startsWith(matrix.config.flutter_version, '2')
run: |
sudo apt update
sudo apt install -y libclang-dev
- name: Install LLVM and Clang (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'linux' ) && startsWith(matrix.config.flutter_version, '2')
run: |
sudo apt update
sudo apt install -y libclang-13-dev
- name: Install libfuse2 (Linux)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'linux'
run: |
sudo apt update
sudo apt install -y libfuse2
- name: Install cargo tools (non-android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'macos' || matrix.config.target == 'windows' || matrix.config.target == 'linux' )
run: |
cargo install cbindgen
- name: Install cargo tools (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
run: |
cargo install cargo-ndk
- name: Setup java (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'zulu'
- name: Setup android tools (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
uses: maxim-lobanov/setup-android-tools@v1
with:
packages: |
platform-tools
platforms;android-33
build-tools;33.0.0
ndk;${{ env.NDK_VERSION }}
- name: Set-Version (All)
if: steps.check_asset.outputs.skip_build != 'true'
run: |
cd daisy/ci
cp version.code.txt ../lib/assets/version.txt
- name: Upgrade deps version (Android)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host != 'macos-11' && startsWith(matrix.config.flutter_version, '2')
run: |
cd daisy
sed -i "s/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml
sed -i "s/flutter_styled_toast: ^2.1.3/flutter_styled_toast: 2.0.0/g" pubspec.yaml
sed -i "s/ffi: 2.0.1/ffi: 1.1.0/g" pubspec.yaml
sed -i "s/ffigen: 6.0.1/ffigen: 4.1.3/g" pubspec.yaml
sed -i "s/modal_bottom_sheet: ^3.0.0-pre/modal_bottom_sheet: ^2.0.1/g" pubspec.yaml
sed -i "s/photo_view: ^0.14.0/photo_view: ^0.13.0/g" pubspec.yaml
- name: Upgrade deps version (iOS)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host == 'macos-11' && startsWith(matrix.config.flutter_version, '2')
run: |
brew install gnu-sed
cd daisy
gsed -i "s/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml
gsed -i "s/flutter_styled_toast: ^2.1.3/flutter_styled_toast: 2.0.0/g" pubspec.yaml
gsed -i "s/ffi: 2.0.1/ffi: 1.1.0/g" pubspec.yaml
gsed -i "s/ffigen: 6.0.1/ffigen: 4.1.3/g" pubspec.yaml
gsed -i "s/modal_bottom_sheet: ^3.0.0-pre/modal_bottom_sheet: ^2.0.1/g" pubspec.yaml
gsed -i "s/photo_view: ^0.14.0/photo_view: ^0.13.0/g" pubspec.yaml
- name: Cargo native build cache
if: steps.check_asset.outputs.skip_build != 'true'
uses: actions/cache@v3
with:
path: |
daisy/native/target/
key: ${{ runner.os }}-cargo-native_target-${{ matrix.config.target }}
- name: Install rust target and build (ios)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'ios')
run: |
rustup target install aarch64-apple-ios
cd daisy
flutter pub get
echo > lib/bridge_generated.dart
echo > ios/Runner/bridge_generated.h
echo > native/src/bridge_generated.rs
echo > native/src/bridge_generated.io.rs
flutter_rust_bridge_codegen \
--rust-input native/src/api.rs \
--dart-output lib/bridge_generated.dart \
--c-output ios/Runner/bridge_generated.h \
--rust-crate-dir native \
--class-name Native
cargo build --manifest-path native/Cargo.toml --features= --lib --release --target=aarch64-apple-ios
cp native/target/aarch64-apple-ios/release/libnative.a ios/Runner/
/usr/libexec/PlistBuddy -c 'Add :application-identifier string niuhuan.daisy' ios/Runner/Info.plist
flutter build ios --no-simulator --no-codesign --release
cd build
rm -rf Payload
mkdir Payload
mv ios/iphoneos/Runner.app Payload/
sh ../scripts/thin-payload.sh Payload
zip -r -9 nosign.ipa Payload
cd ..
- name: Install LLVM and Clang (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) && !startsWith(matrix.config.flutter_version, '2')
run: |
cd daisy
flutter pub get
echo > native/src/bridge_generated.rs
echo > native/src/bridge_generated.io.rs
flutter_rust_bridge_codegen --rust-input native/src/api.rs --dart-output lib/bridge_generated.dart
- name: Install LLVM and Clang (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' ) && startsWith(matrix.config.flutter_version, '2')
run: |
cd daisy
flutter pub get
echo > native/src/bridge_generated.rs
echo > native/src/bridge_generated.io.rs
flutter_rust_bridge_codegen --rust-input native/src/api.rs --dart-output lib/bridge_generated.dart --llvm-path=/usr/lib/llvm-13
- name: Install rust target and build (Android-arm64)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm64')
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}
rustup target install aarch64-linux-android
cd daisy
cd native
cargo ndk -o ../android/app/src/main/jniLibs -t arm64-v8a build --release
cd ..
flutter build apk --target-platform android-arm64
- name: Install rust target and build (Android-arm32)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32')
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}
rustup target install armv7-linux-androideabi
cd daisy
cd native
cargo ndk -o ../android/app/src/main/jniLibs -t armeabi-v7a build --release
cd ..
flutter build apk --target-platform android-arm
- name: Install rust target and build (Android-x86_64)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-x86_64')
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}
rustup target install x86_64-linux-android
cd daisy
cd native
cargo ndk -o ../android/app/src/main/jniLibs -t x86_64 build --release
cd ..
flutter build apk --target-platform android-x64
- name: Install dependencies and build (Linux)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'linux'
run: |
sudo apt-get update
sudo apt install -y ninja-build liblzma-dev libgtk-3-dev libgl1-mesa-dev xorg-dev
curl -JOL https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod a+x appimagetool-x86_64.AppImage
mv appimagetool-x86_64.AppImage appimagetool
cd daisy
flutter pub get
echo > native/src/bridge_generated.rs
echo > native/src/bridge_generated.io.rs
flutter_rust_bridge_codegen --rust-input native/src/api.rs --dart-output lib/bridge_generated.dart
flutter config --enable-linux-desktop
flutter build linux --release
mv build/linux/x64/release/bundle/{daisy,AppRun}
cp linux/appimage/* build/linux/x64/release/bundle/
../appimagetool build/linux/x64/release/bundle/
mv *.AppImage build/linux.AppImage
- name: build (windows)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'windows'
run: |
cd daisy
flutter pub get
echo $null > native/src/bridge_generated.rs
flutter_rust_bridge_codegen --rust-crate-dir native --rust-input native/src/api.rs --dart-output lib/bridge_generated.dart --class-name Native
flutter config --enable-windows-desktop
flutter build windows
cd build/windows/runner/Release
Compress-Archive * ../../../../build/windows.zip
cd ../../../..
- name: Build (macos)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'macos'
run: |
cd daisy
flutter pub get
echo > native/src/bridge_generated.rs
echo > native/src/bridge_generated.io.rs
flutter_rust_bridge_codegen \
--rust-input native/src/api.rs \
--dart-output lib/bridge_generated.dart \
--c-output macos/Runner/bridge_generated.h \
--rust-crate-dir native \
--class-name Native
rustup target install x86_64-apple-darwin
rustup target install aarch64-apple-darwin
cargo build --manifest-path native/Cargo.toml --release --target x86_64-apple-darwin
cargo build --manifest-path native/Cargo.toml --release --target aarch64-apple-darwin
flutter config --enable-macos-desktop
flutter build macos
cd build
mkdir appimage
mv macos/Build/Products/Release/daisy.app appimage/
lipo -create -output appimage/daisy.app/Contents/Frameworks/libnative.dylib ../native/target/x86_64-apple-darwin/release/libnative.dylib ../native/target/aarch64-apple-darwin/release/libnative.dylib
ln -sf /Applications appimage/
hdiutil create -volname daisy -srcfolder appimage -ov -format UDBZ macos.dmg
cd ..
- name: Sign APK (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
env:
KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cd daisy
echo $KEY_FILE_BASE64 > key.jks.base64
base64 -d key.jks.base64 > key.jks
echo $KEY_PASSWORD | $ANDROID_HOME/build-tools/30.0.2/apksigner sign --ks key.jks build/app/outputs/flutter-apk/app-release.apk
- name: Cargo ci build cache
if: steps.check_asset.outputs.skip_build != 'true'
uses: actions/cache@v3
with:
path: |
daisy/ci/target/
key: ${{ runner.os }}-cargo-ci_target
- name: Upload Asset (All)
if: steps.check_asset.outputs.skip_build != 'true'
run: |
cd daisy/ci
cargo run --release --bin upload-asset