From 8d69b115a54187f5866c3ff1f6e358ad3851fd8f Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Sun, 29 May 2022 16:17:22 +0800 Subject: [PATCH] add abi split --- .github/workflows/build.yml | 48 +++++++++++++------------------------ app/build.gradle | 35 +++++++++++++++++---------- 2 files changed, 38 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c57cb32..762359e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,47 +59,31 @@ jobs: if [[ ${{ steps.config.outputs.need_create_release }} != 'true' ]];then path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug" fi - files=$(ls $path) - for f in $files - do - if [[ $f == *"apk" ]]; then - file=$f - echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 文件:$file" - break - fi - done - echo ::set-output name=file_name::"$file" - echo ::set-output name=file_path::"$path/$file" + echo ::set-output name=file_path::"$path" - name: Upload App To Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: FYReader-apk path: ${{ steps.get_path.outputs.file_path }} - name: Upload App To Lanzou run: | echo "上传APP至蓝奏云" - python3 $GITHUB_WORKSPACE/keystore/scripts/lzy.py "${{ steps.get_path.outputs.file_path }}" "${{ steps.config.outputs.lanzou_folder_id }}" + python3 $GITHUB_WORKSPACE/keystore/scripts/lzy.py "${{ steps.get_path.outputs.file_path }}" "${{ steps.config.outputs.lanzou_folder_id }}" "${{ steps.config.outputs.version_name }}" echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: ${{ steps.config.outputs.lanzou_share_url }}" - - name: Create Release - id: create_release + - name: Release if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }} - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TZ: Asia/Shanghai + uses: softprops/action-gh-release@v1 with: - tag_name: ${{ steps.config.outputs.version_name }} - release_name: FYReader_${{ steps.config.outputs.version_name }} - body_path: ${{ github.workspace }}/app/release.md + body_path: ./app/release.md + prerelease: false draft: false - - name: Upload Release Asset - id: upload_release_asset - if: ${{ steps.config.outputs.need_create_release == 'true' && steps.create_release.outputs.upload_url }} - uses: actions/upload-release-asset@v1 + tag_name: ${{ steps.config.outputs.version_name }} + name: FYReader_${{ steps.config.outputs.version_name }} + files: | + app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-arm64-v8a.apk + app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-armeabi-v7a.apk + app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-x86_64.apk + app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-x86.apk + app/build/outputs/apk/release/风月读书${{ steps.config.outputs.version_name }}-universal.apk env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ steps.get_path.outputs.file_path }} - asset_name: FYReader_${{ steps.config.outputs.version_name }}.apk - asset_content_type: application/vnd.android.package-archive \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 05dec11..ae81850 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,6 +20,7 @@ apply plugin: 'com.android.application' apply plugin: 'org.greenrobot.greendao' apply plugin: 'kotlin-android' +import com.android.build.OutputFile def releaseTime() { return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+08:00")) } @@ -46,7 +47,8 @@ def getVersionC() { def name = "风月读书" def versionC = getVersionC() -def versionN = versionC.toString().join("", ".") +def versionN = versionC.toString() +versionN = versionN[0] + "." + versionN[1] + "." + versionN[2] // 读取keystore.properties def keyProps = new Properties() @@ -83,6 +85,15 @@ android { viewBinding true } + splits { + abi { + reset() + enable true + universalApk true // If true, also generate a universal APK + include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + } + } + buildTypes { release { minifyEnabled false @@ -90,9 +101,6 @@ android { if (keyPropsFile.exists()) { signingConfig signingConfigs.myConifg } - ndk { - abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" - } } debug { minifyEnabled false @@ -102,18 +110,19 @@ android { } applicationIdSuffix ".debug" versionNameSuffix "-" + commitId - ndk { - abiFilters "arm64-v8a" - } } android.applicationVariants.all { variant -> def buildType = variant.buildType.name - def fileName = "${name}v${defaultConfig.versionName}.apk" - if (buildType == "debug"){ - fileName = "${name}v${defaultConfig.versionName}-${commitId}.apk" - } - variant.outputs.all { - outputFileName = fileName + variant.outputs.each { output -> + def abi = output.getFilter(OutputFile.ABI) + if (abi == null) { + abi = "universal" + } + def fileName = "${name}v${defaultConfig.versionName}-${abi}.apk" + if (buildType == "debug"){ + fileName = "${name}v${defaultConfig.versionName}-${abi}-${commitId}.apk" + } + output.outputFileName = fileName } } }