mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-29 21:10:20 +02:00
build: add variants
This commit is contained in:
parent
a70ef74130
commit
ccdf5c6318
9
.github/workflows/android.yml
vendored
9
.github/workflows/android.yml
vendored
@ -23,11 +23,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
|
- name: Clean Gradle Cache
|
||||||
|
run: ./gradlew clean
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew assembleRelease -PtargetApkUrl=${{ secrets.TARGET_APK_URL }}
|
||||||
|
- name: Upload debug artifacts
|
||||||
- name: Upload debug artifact
|
|
||||||
uses: actions/upload-artifact@v3.1.2
|
uses: actions/upload-artifact@v3.1.2
|
||||||
with:
|
with:
|
||||||
name: app-debug
|
name: app-debug
|
||||||
path: app/build/outputs/apk/debug/app-debug.apk
|
path: app/build/outputs/apk/**/release/*.apk
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
id 'org.jetbrains.kotlin.android'
|
id 'org.jetbrains.kotlin.android'
|
||||||
}
|
}
|
||||||
|
|
||||||
def appVersionName = "0.0.1"
|
def appVersionName = "0.1.0"
|
||||||
def appVersionCode = 1
|
def appVersionCode = 1
|
||||||
|
def lspatchReleaseUrl = "https://api.github.com/repos/LSPosed/LSPatch/releases/latest"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 33
|
compileSdk 33
|
||||||
@ -31,12 +34,33 @@ android {
|
|||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
//keep arm64-v8a native libs
|
applicationVariants.configureEach { variant ->
|
||||||
packagingOptions {
|
variant.outputs.configureEach {
|
||||||
exclude "META-INF/**"
|
outputFileName = "app-${appVersionName}-${variant.flavorName}.apk"
|
||||||
exclude 'lib/x86/**'
|
}
|
||||||
exclude 'lib/x86_64/**'
|
}
|
||||||
exclude 'lib/armeabi-v7a/**'
|
|
||||||
|
flavorDimensions "release"
|
||||||
|
|
||||||
|
productFlavors {
|
||||||
|
armv8 {
|
||||||
|
ndk {
|
||||||
|
abiFilters "arm64-v8a"
|
||||||
|
}
|
||||||
|
dimension "release"
|
||||||
|
}
|
||||||
|
armv7 {
|
||||||
|
ndk {
|
||||||
|
abiFilters "armeabi-v7a"
|
||||||
|
}
|
||||||
|
dimension "release"
|
||||||
|
}
|
||||||
|
prod {
|
||||||
|
ndk {
|
||||||
|
abiFilter("none")
|
||||||
|
}
|
||||||
|
dimension "release"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
@ -46,6 +70,48 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
|
getTasks().getByPath(":app:assembleProdRelease").doLast {
|
||||||
|
def apkReleaseFile = android.applicationVariants.find { it.buildType.name == "release" && it.flavorName == "prod" }.outputs[0].outputFile
|
||||||
|
|
||||||
|
//download the target apk
|
||||||
|
println "Downloading target apk"
|
||||||
|
def targetApkFile = new File("${buildDir}/${apkReleaseFile.name}")
|
||||||
|
try {
|
||||||
|
def targetApkUrl = project.property("targetApkUrl")
|
||||||
|
targetApkFile.withOutputStream { out ->
|
||||||
|
new URL(targetApkUrl).withInputStream { input ->
|
||||||
|
out << input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
println "No target apk url provided"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//download the latest lspatch jar
|
||||||
|
def connection = new URL(lspatchReleaseUrl).openConnection()
|
||||||
|
def json = new JsonSlurper().parseText(connection.getInputStream().getText())
|
||||||
|
def downloadUrl = json.assets[0].browser_download_url
|
||||||
|
println "Downloading LSPatch from ${downloadUrl}"
|
||||||
|
|
||||||
|
def lspatchJarfile = new File("${buildDir}/lspatch.jar")
|
||||||
|
lspatchJarfile.withOutputStream { out ->
|
||||||
|
new URL(downloadUrl).withInputStream { input ->
|
||||||
|
out << input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println "Executing LSPatch"
|
||||||
|
exec {
|
||||||
|
commandLine "java", "-jar", lspatchJarfile.absolutePath,
|
||||||
|
targetApkFile.absolutePath,
|
||||||
|
"--force", "-l", "2", "-m",
|
||||||
|
apkReleaseFile.absolutePath,
|
||||||
|
"-o",
|
||||||
|
"${buildDir}/outputs/apk/lspatch/release/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//auto install for debug purpose
|
//auto install for debug purpose
|
||||||
getTasks().getByPath(":app:assembleDebug").doLast {
|
getTasks().getByPath(":app:assembleDebug").doLast {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user