From 808ff0a026ddefe4a7e633788bec31f4db8d9544 Mon Sep 17 00:00:00 2001 From: hpp2334 Date: Thu, 21 Nov 2024 01:47:48 +0800 Subject: [PATCH] feat: build apk in CI --- .github/workflows/release.yml | 34 ++++++++----------- android/app/build.gradle.kts | 3 +- .../easemusicplayer/core/MusicPlayer.kt | 15 ++++---- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a64c6230..c169819f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,40 +30,34 @@ jobs: ~/.cargo/git/db/ key: ${{ runner.os }}-cargo restore-keys: ${{ runner.os }}-cargo - - uses: pnpm/action-setup@v3 - with: - version: 8 - - uses: subosito/flutter-action@v2 - with: - flutter-version: "3.22.2" - channel: "stable" + - uses: oven-sh/setup-bun@v2 - uses: nttld/setup-ndk@v1 id: setup-ndk with: - ndk-version: r25c + ndk-version: r28c add-to-path: false + - name: Set Up JDK + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' + cache: 'gradle' - name: Install scripts runtime - run: pnpm install + run: bun install - name: Install cargo-ndk run: | cargo install --locked cargo-ndk || true - rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android - - name: Install flutter dependencies - run: flutter pub get - - name: Install flutter rust bridge - run: | - cargo install --locked cargo-expand@1.0.79 || true - cargo install --locked 'flutter_rust_bridge_codegen@1.82.6' || true - - name: Generate codes - run: pnpm run generate + rustup target add aarch64-linux-android + - name: Build JNI + run: bun run build:jni - name: Run tests - run: pnpm run test + run: bun run test - name: Build APK if: ${{ startsWith(github.ref, 'refs/tags/v') }} || ${{ startsWith(github.ref, 'refs/tags/pre-v') }} run: | mkdir -p ~/.gradle echo "ANDROID_NDK=$ANDROID_NDK_HOME" >> ~/.gradle/gradle.properties - pnpm run build:apk + bun run build:apk env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} ANDROID_SIGN_JKS: ${{ secrets.ANDROID_SIGN_JKS }} diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 98848f68..9a6c1e70 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -27,7 +27,7 @@ android { minSdk = 29 targetSdk = 34 versionCode = 1 - versionName = "0.2" + versionName = "0.2.0-beta.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -62,6 +62,7 @@ android { debugSymbolLevel = "SYMBOL_TABLE" } } + } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/android/app/src/main/java/com/kutedev/easemusicplayer/core/MusicPlayer.kt b/android/app/src/main/java/com/kutedev/easemusicplayer/core/MusicPlayer.kt index 08298d9b..4428bca0 100644 --- a/android/app/src/main/java/com/kutedev/easemusicplayer/core/MusicPlayer.kt +++ b/android/app/src/main/java/com/kutedev/easemusicplayer/core/MusicPlayer.kt @@ -14,10 +14,6 @@ import androidx.media3.common.MediaItem import androidx.media3.common.MediaMetadata import androidx.media3.common.PlaybackException import androidx.media3.common.Player -import androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT -import androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM -import androidx.media3.common.Player.COMMAND_SEEK_TO_PREVIOUS -import androidx.media3.common.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM import androidx.media3.common.util.UnstableApi import androidx.media3.exoplayer.ExoPlayer import androidx.media3.extractor.metadata.flac.PictureFrame @@ -293,10 +289,13 @@ class PlaybackService : MediaSessionService() { .build() val playerCommands = MediaSession.ConnectionResult.DEFAULT_PLAYER_COMMANDS.buildUpon() - .remove(COMMAND_SEEK_TO_PREVIOUS) - .remove(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM) - .remove(COMMAND_SEEK_TO_NEXT) - .remove(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM) + .remove(Player.COMMAND_SEEK_TO_PREVIOUS) + .remove(Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM) + .remove(Player.COMMAND_SEEK_TO_NEXT) + .remove(Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM) + .remove(Player.COMMAND_SEEK_BACK) + .remove(Player.COMMAND_SEEK_FORWARD) + .remove(Player.COMMAND_SEEK_TO_DEFAULT_POSITION) .build() // Custom layout and available commands to configure the legacy/framework session. return MediaSession.ConnectionResult.AcceptedResultBuilder(session)