Release #180
This file contains hidden or 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: Release | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RUST_TOOLCHAIN: nightly-2025-02-26 | |
| NDK_VERSION: 27.2.12479018 | |
| FLUTTER_CHANNEL: stable | |
| FLUTTER_VERSION: '3.29.3' | |
| JDK_VERSION: 17 | |
| 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 | |
| outputs: | |
| matrix: ${{ steps.check-release.outputs.matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Check and create release | |
| id: check-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| export VERSION=$(cat ci/version.code.txt | xargs echo) | |
| echo "VERSION : $VERSION" | |
| declare -A asset_dict | |
| asset_dict["ios"]="${{ github.event.repository.name }}-$VERSION-nosign.ipa" | |
| asset_dict["android-arm64"]="${{ github.event.repository.name }}-arm64-$VERSION.apk" | |
| asset_dict["android-arm32"]="${{ github.event.repository.name }}-arm32-$VERSION.apk" | |
| asset_dict["android-core"]="${{ github.event.repository.name }}-android-core-$VERSION.zip" | |
| asset_dict["windows"]="${{ github.event.repository.name }}-$VERSION-windows-x86_64.zip" | |
| asset_dict["linux"]="${{ github.event.repository.name }}-$VERSION.AppImage" | |
| asset_dict["macos"]="${{ github.event.repository.name }}-$VERSION.dmg" | |
| declare -A host_dict | |
| host_dict["ios"]="macos-latest" | |
| host_dict["android-arm64"]="ubuntu-latest" | |
| host_dict["android-arm32"]="ubuntu-latest" | |
| host_dict["android-core"]="ubuntu-latest" | |
| host_dict["windows"]="windows-latest" | |
| host_dict["linux"]="ubuntu-latest" | |
| host_dict["macos"]="macos-latest" | |
| export RELEASE=$(gh release view $VERSION --json id -q .id || echo "NOT_FOUND") | |
| echo "RELEASE : $RELEASE" | |
| if [ "$RELEASE" == "NOT_FOUND" ]; then | |
| echo "Release does not exist. Creating release $VERSION." | |
| gh release create $VERSION -t $VERSION -F ci/version.info.txt --target ${{ github.sha }} | |
| else | |
| echo "Release $VERSION already exists." | |
| fi | |
| gh release view $VERSION --json assets > release_assets.json | |
| echo release_assets.json : | |
| cat release_assets.json | |
| matrix='[' | |
| for key in "${!asset_dict[@]}"; do | |
| asset_name=${asset_dict[$key]} | |
| asset_exists=$(jq ".assets[].label" release_assets.json | grep -Fx "\"$asset_name\"" || echo "NOT_FOUND") | |
| if [ "$asset_exists" == "NOT_FOUND" ]; then | |
| echo "Asset $asset_name does not exist. Upload is required." | |
| matrix+="{\"target\": \"$key\", \"host\": \"${host_dict[$key]}\"}," | |
| else | |
| echo "Asset $asset_name already exists. No upload is required." | |
| fi | |
| done | |
| matrix=${matrix%,} # Remove trailing comma | |
| matrix+=']' | |
| echo matrix=$matrix >> $GITHUB_OUTPUT | |
| echo "GITHUB_OUTPUT : $GITHUB_OUTPUT :" | |
| cat $GITHUB_OUTPUT | |
| build_release_assets: | |
| name: Build release assets | |
| needs: | |
| - check_release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: ${{ fromJson(needs.check_release.outputs.matrix) }} | |
| runs-on: ${{ matrix.config.host }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - 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 }} | |
| - name: checkout core | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GH_TOKEN }} | |
| repository: 'niuhuan/jasmine-rs-core' | |
| path: 'native' | |
| - name: Cache Flutter dependencies (Linux/Android) | |
| if: matrix.config.host == 'ubuntu-latest' | |
| uses: actions/cache@v3 | |
| with: | |
| path: /opt/hostedtoolcache/flutter | |
| key: ${{ runner.os }}-flutter | |
| - name: Setup flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: ${{ env.FLUTTER_CHANNEL }} | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| architecture: x64 | |
| - name: Install cargo tools (non-android) | |
| if: ( matrix.config.target == 'macos' || matrix.config.target == 'windows' || matrix.config.target == 'linux' || matrix.config.target == 'ios' ) | |
| run: | | |
| cargo install --force cbindgen | |
| - name: Install cargo tools (Android) | |
| if: startsWith(matrix.config.target, 'android-') | |
| run: | | |
| cargo install --force cargo-ndk | |
| - name: Setup java (Android) | |
| if: ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'android-core') | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: ${{ env.JDK_VERSION }} | |
| distribution: 'temurin' | |
| - name: Setup android tools (Android) | |
| if: ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'android-core') | |
| uses: android-actions/setup-android@v3 | |
| with: | |
| cmdline-tools-version: 8512546 | |
| packages: 'platform-tools platforms;android-32 build-tools;30.0.2 ndk;${{ env.NDK_VERSION }}' | |
| - name: Install libfuse2 (Linux) | |
| if: matrix.config.target == 'linux' | |
| run: | | |
| sudo apt update | |
| sudo apt install -y libfuse2 | |
| - name: Set-Version (All) | |
| run: | | |
| cd ci | |
| cp version.code.txt ../lib/assets/version.txt | |
| - name: Append application-identifier (ios) | |
| if: ( matrix.config.target == 'ios') | |
| run: | | |
| /usr/libexec/PlistBuddy -c 'Add :application-identifier string opensource.jasmine' ios/Runner/Info.plist | |
| - name: Install rust target and build (ios) | |
| if: ( matrix.config.target == 'ios') | |
| run: | | |
| rustup target install aarch64-apple-ios | |
| cargo build --manifest-path native/jmbackend/platforms/ios/Cargo.toml --features= --lib --release --target=aarch64-apple-ios | |
| cp native/jmbackend/platforms/ios/target/aarch64-apple-ios/release/librust.a ios/ | |
| cbindgen native/jmbackend/src/lib.rs -l c > ios/rust.h | |
| 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 .. | |
| # if ios-sim | |
| # rustup target install aarch64-apple-ios-sim | |
| # rustup target install x86_64-apple-ios | |
| # cargo build --manifest-path native/jmbackend/platforms/ios-sim/Cargo.toml --features= --lib --release --target=aarch64-apple-ios-sim | |
| # cargo build --manifest-path native/jmbackend/platforms/ios-sim/Cargo.toml --features= --lib --release --target=x86_64-apple-ios | |
| # lipo -create -output ios/librust.a native/jmbackend/platforms/ios-sim/target/x86_64-apple-ios/release/librust.a native/jmbackend/platforms/ios-sim/target/aarch64-apple-ios-sim/release/librust.a | |
| # cbindgen native/jmbackend/src/lib.rs -l c > ios/rust.h | |
| - name: Install rust target and build (Android-core) | |
| if: ( matrix.config.target == 'android-core') | |
| run: | | |
| export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }} | |
| rustup target install aarch64-linux-android | |
| rustup target install armv7-linux-androideabi | |
| rustup target install x86_64-linux-android | |
| cd native/jmbackend/platforms/android | |
| cargo ndk -o ../../../../android/app/src/main/jniLibs -t arm64-v8a build --release | |
| cargo ndk -o ../../../../android/app/src/main/jniLibs -t armeabi-v7a build --release | |
| cargo ndk -o ../../../../android/app/src/main/jniLibs -t x86_64 build --release | |
| cd ../../../.. | |
| zip -r -9 android-core.zip android/app/src/main/jniLibs | |
| - name: Install rust target and build (Android-arm64) | |
| if: ( matrix.config.target == 'android-arm64') | |
| run: | | |
| export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }} | |
| rustup target install aarch64-linux-android | |
| cd native/jmbackend/platforms/android | |
| 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: ( matrix.config.target == 'android-arm32') | |
| run: | | |
| export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }} | |
| rustup target install armv7-linux-androideabi | |
| cd native/jmbackend/platforms/android | |
| 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: ( 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 native/jmbackend/platforms/android | |
| 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: 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 | |
| cargo build --manifest-path native/jmbackend/platforms/linux/Cargo.toml --features= --lib --release --target=x86_64-unknown-linux-gnu | |
| cp native/jmbackend/platforms/linux/target/x86_64-unknown-linux-gnu/release/librust.a linux/ | |
| cbindgen native/jmbackend/src/lib.rs -l c++ > linux/rust.h | |
| cbindgen native/jmbackend/platforms/linux/src/lib.rs -l c++ > linux/rust1.h | |
| flutter config --enable-linux-desktop | |
| flutter build linux --release | |
| mv build/linux/x64/release/bundle/{jasmine,AppRun} | |
| cp linux/appimage/* build/linux/x64/release/bundle/ | |
| ./appimagetool build/linux/x64/release/bundle/ | |
| mv *.AppImage build/linux.AppImage | |
| - name: build (windows) | |
| if: matrix.config.target == 'windows' | |
| run: | | |
| cargo build --manifest-path native/jmbackend/platforms/windows/Cargo.toml --release --target x86_64-pc-windows-msvc | |
| cp native/jmbackend/platforms/windows/target/x86_64-pc-windows-msvc/release/rust.lib windows/ | |
| cbindgen native/jmbackend/src/lib.rs -l c++ > windows/rust.h | |
| flutter config --enable-windows-desktop | |
| flutter build windows | |
| cd build/windows/x64/runner/Release | |
| Compress-Archive * ../../../../../build/windows.zip | |
| cd ../../../../.. | |
| - name: Build (macos) | |
| if: matrix.config.target == 'macos' | |
| run: | | |
| rustup target install x86_64-apple-darwin | |
| rustup target install aarch64-apple-darwin | |
| cargo build --manifest-path native/jmbackend/platforms/macos/Cargo.toml --release --target x86_64-apple-darwin | |
| cargo build --manifest-path native/jmbackend/platforms/macos/Cargo.toml --release --target aarch64-apple-darwin | |
| lipo -create -output macos/librust.a native/jmbackend/platforms/macos/target/x86_64-apple-darwin/release/librust.a native/jmbackend/platforms/macos/target/aarch64-apple-darwin/release/librust.a | |
| cbindgen native/jmbackend/src/lib.rs -l c > macos/rust.h | |
| flutter config --enable-macos-desktop | |
| flutter build macos | |
| cd build | |
| mkdir appimage | |
| mv macos/Build/Products/Release/jasmine.app appimage/ | |
| ln -sf /Applications appimage/ | |
| hdiutil create -volname jasmine -srcfolder appimage -ov -format UDBZ macos.dmg | |
| cd .. | |
| - name: Sign APK (Android) | |
| if: ( 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: | | |
| 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: Upload Asset (windows) | |
| if: matrix.config.target == 'windows' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| $VERSION = (Get-Content -Path "ci/version.code.txt").Trim() | |
| $asset_path = "build/windows.zip" | |
| $asset_name = "${{ github.event.repository.name }}-$VERSION-windows-x86_64.zip" | |
| echo "Uploading asset $asset_name from $asset_path" | |
| mv $asset_path $asset_name | |
| gh release upload $VERSION $asset_name#$asset_name --clobber | |
| - name: Upload Asset (android , linux) | |
| if: startsWith(matrix.config.target, 'android') || startsWith(matrix.config.target, 'linux') | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| export VERSION=$(cat ci/version.code.txt | xargs echo) | |
| declare -A asset_dict | |
| asset_dict["ios"]="${{ github.event.repository.name }}-$VERSION-nosign.ipa" | |
| asset_dict["android-arm64"]="${{ github.event.repository.name }}-arm64-$VERSION.apk" | |
| asset_dict["android-arm32"]="${{ github.event.repository.name }}-arm32-$VERSION.apk" | |
| asset_dict["windows"]="${{ github.event.repository.name }}-$VERSION-windows-x86_64.zip" | |
| asset_dict["linux"]="${{ github.event.repository.name }}-$VERSION.AppImage" | |
| asset_dict["macos"]="${{ github.event.repository.name }}-$VERSION.dmg" | |
| asset_dict["android-core"]="${{ github.event.repository.name }}-android-core-$VERSION.zip" | |
| declare -A asset_path_dict | |
| asset_path_dict["ios"]="build/nosign.ipa" | |
| asset_path_dict["android-arm64"]="build/app/outputs/flutter-apk/app-release.apk" | |
| asset_path_dict["android-arm32"]="build/app/outputs/flutter-apk/app-release.apk" | |
| asset_path_dict["windows"]="build/windows.zip" | |
| asset_path_dict["linux"]="build/linux.AppImage" | |
| asset_path_dict["macos"]="build/macos.dmg" | |
| asset_path_dict["android-core"]="android-core.zip" | |
| asset_name=${asset_dict["${{ matrix.config.target }}"]} | |
| asset_path=${asset_path_dict["${{ matrix.config.target }}"]} | |
| echo "Uploading asset $asset_name from $asset_path" | |
| mv $asset_path $asset_name | |
| gh release upload $VERSION "${asset_name}#${asset_name}" --clobber | |
| - name: Upload Asset (macos , ios) | |
| if: startsWith(matrix.config.target, 'macos') || startsWith(matrix.config.target, 'ios') | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| export VERSION=$(cat ci/version.code.txt | xargs echo) | |
| if [ "${{ matrix.config.target }}" == "ios" ]; then | |
| asset_name="${{ github.event.repository.name }}-$VERSION-nosign.ipa" | |
| asset_path="build/nosign.ipa" | |
| else | |
| asset_name="${{ github.event.repository.name }}-$VERSION.dmg" | |
| asset_path="build/macos.dmg" | |
| fi | |
| echo "Uploading asset $asset_name from $asset_path" | |
| mv $asset_path $asset_name | |
| gh release upload $VERSION "${asset_name}#${asset_name}" --clobber | |