This commit is contained in:
ShirosakiMio 2024-01-16 13:53:43 +08:00
parent a48234b17a
commit 0470b780ca
2 changed files with 80 additions and 24 deletions

View File

@ -11,27 +11,32 @@ on:
jobs: jobs:
build: build:
strategy:
matrix:
arch: [ "all", "arm", "arm64", "x86", "x64" ]
fail-fast: false
env: env:
FCL_KEYSTORE_PASSWORD: ${{ secrets.FCL_KEYSTORE_PASSWORD }} FCL_KEYSTORE_PASSWORD: ${{ secrets.FCL_KEYSTORE_PASSWORD }}
name: Build for ${{matrix.arch}}
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: set up JDK 17 - name: set up JDK 17
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 17 java-version: 17
- name: Build debug .apk - name: Build debug ${{matrix.arch}} .apk
run: | run: |
chmod +x gradlew chmod +x gradlew
./gradlew assembleautobuild ./gradlew assembleautobuild -Darch=${{matrix.arch}}
- name : upload apk - name: upload apk
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: app-release name: app-debug-${{matrix.arch}}
path: FCL/build/outputs/apk/autobuild/* path: FCL/build/outputs/apk/autobuild/*
# retention-days: 1 # retention-days: 1

View File

@ -8,11 +8,17 @@ android {
compileSdk 34 compileSdk 34
signingConfigs { signingConfigs {
autoBuild { FCLKey {
def pwd = System.getenv("FCL_KEYSTORE_PASSWORD")
if (pwd == null) {
Properties prop = new Properties()
prop.load(new FileInputStream("${rootDir}/local.properties"))
pwd = prop.get("pwd")
}
storeFile file("../key-store.jks") storeFile file("../key-store.jks")
storePassword System.getenv("FCL_KEYSTORE_PASSWORD") storePassword pwd
keyAlias "FCL-Key" keyAlias "FCL-Key"
keyPassword System.getenv("FCL_KEYSTORE_PASSWORD") keyPassword pwd
} }
} }
@ -30,10 +36,11 @@ android {
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.FCLKey
} }
autobuild { autobuild {
initWith debug initWith debug
signingConfig signingConfigs.autoBuild signingConfig signingConfigs.FCLKey
} }
configureEach { configureEach {
resValue "string", "app_version", "${defaultConfig.versionName}" resValue "string", "app_version", "${defaultConfig.versionName}"
@ -41,7 +48,28 @@ android {
} }
applicationVariants.configureEach { variant -> applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output -> variant.outputs.configureEach { output ->
outputFileName = "FCL-${variant.buildType.name}-${defaultConfig.versionName}.apk" def abi = output.getFilter(ABI)
if (abi == null) {
abi = "all"
}
variant.mergeAssetsProvider.get().doLast {
def arch = System.getProperty("arch", "all")
def assetsDir = mergeAssetsProvider.get().outputDir.get()
def java = ['jre8', 'jre17']
println(arch)
java.forEach { String str ->
def runtimeDir = new File([assetsDir, "app_runtime/java/" + str].join(File.separator))
println(runtimeDir)
def files = fileTree(dir: runtimeDir, include: ['*.tar.xz'])
files.forEach { File file ->
if (arch != 'all' && !file.getName().contains(arch)) {
print("delete:${file} :")
println(delete(file))
}
}
}
}
outputFileName = "FCL-${variant.buildType.name}-${defaultConfig.versionName}-${abi}.apk"
} }
} }
compileOptions { compileOptions {
@ -53,6 +81,29 @@ android {
useLegacyPackaging true useLegacyPackaging true
} }
} }
splits {
def arch = System.getProperty("arch", "all")
if (arch != 'all') {
abi {
enable true
reset()
switch (arch) {
case 'arm':
include 'armeabi-v7a'
break
case 'arm64':
include 'arm64-v8a'
break
case 'x86':
include 'x86'
break
case 'x64':
include 'x86_64'
break
}
}
}
}
} }
tasks.whenTaskAdded { Task task -> tasks.whenTaskAdded { Task task ->
@ -130,7 +181,7 @@ remotes {
user = prop.getProperty("sftp.username") user = prop.getProperty("sftp.username")
password = prop.getProperty("sftp.password") password = prop.getProperty("sftp.password")
} }
} catch (Exception e) { } catch (Exception ignored) {
} }
} }