add abi split

pull/28/head
fengyuecanzhu 3 years ago
parent 620e5e085e
commit 8d69b115a5
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 46
      .github/workflows/build.yml
  2. 31
      app/build.gradle

@ -59,47 +59,31 @@ jobs:
if [[ ${{ steps.config.outputs.need_create_release }} != 'true' ]];then if [[ ${{ steps.config.outputs.need_create_release }} != 'true' ]];then
path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug" path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug"
fi fi
files=$(ls $path) echo ::set-output name=file_path::"$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"
- name: Upload App To Artifact - name: Upload App To Artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: FYReader-apk name: FYReader-apk
path: ${{ steps.get_path.outputs.file_path }} path: ${{ steps.get_path.outputs.file_path }}
- name: Upload App To Lanzou - name: Upload App To Lanzou
run: | run: |
echo "上传APP至蓝奏云" 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 }}" echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: ${{ steps.config.outputs.lanzou_share_url }}"
- name: Create Release - name: Release
id: create_release
if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }} if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }}
uses: actions/create-release@v1 uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TZ: Asia/Shanghai
with: with:
tag_name: ${{ steps.config.outputs.version_name }} body_path: ./app/release.md
release_name: FYReader_${{ steps.config.outputs.version_name }} prerelease: false
body_path: ${{ github.workspace }}/app/release.md
draft: false draft: false
- name: Upload Release Asset tag_name: ${{ steps.config.outputs.version_name }}
id: upload_release_asset name: FYReader_${{ steps.config.outputs.version_name }}
if: ${{ steps.config.outputs.need_create_release == 'true' && steps.create_release.outputs.upload_url }} files: |
uses: actions/upload-release-asset@v1 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: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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

@ -20,6 +20,7 @@ apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao' apply plugin: 'org.greenrobot.greendao'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
import com.android.build.OutputFile
def releaseTime() { def releaseTime() {
return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+08:00")) return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+08:00"))
} }
@ -46,7 +47,8 @@ def getVersionC() {
def name = "风月读书" def name = "风月读书"
def versionC = getVersionC() def versionC = getVersionC()
def versionN = versionC.toString().join("", ".") def versionN = versionC.toString()
versionN = versionN[0] + "." + versionN[1] + "." + versionN[2]
// keystore.properties // keystore.properties
def keyProps = new Properties() def keyProps = new Properties()
@ -83,6 +85,15 @@ android {
viewBinding true 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 { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
@ -90,9 +101,6 @@ android {
if (keyPropsFile.exists()) { if (keyPropsFile.exists()) {
signingConfig signingConfigs.myConifg signingConfig signingConfigs.myConifg
} }
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
} }
debug { debug {
minifyEnabled false minifyEnabled false
@ -102,18 +110,19 @@ android {
} }
applicationIdSuffix ".debug" applicationIdSuffix ".debug"
versionNameSuffix "-" + commitId versionNameSuffix "-" + commitId
ndk {
abiFilters "arm64-v8a"
}
} }
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
def buildType = variant.buildType.name def buildType = variant.buildType.name
def fileName = "${name}v${defaultConfig.versionName}.apk" 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"){ if (buildType == "debug"){
fileName = "${name}v${defaultConfig.versionName}-${commitId}.apk" fileName = "${name}v${defaultConfig.versionName}-${abi}-${commitId}.apk"
} }
variant.outputs.all { output.outputFileName = fileName
outputFileName = fileName
} }
} }
} }

Loading…
Cancel
Save