add: release CI
This commit is contained in:
74
.github/workflows/release.yml
vendored
Normal file
74
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
name: Release CI
|
||||
on:
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Clean Gradle Cache
|
||||
run: ./gradlew clean
|
||||
|
||||
- name: Build Release APK
|
||||
run: ./gradlew assembleRelease
|
||||
|
||||
- name: Sign armv7 APK
|
||||
id: sign_armv7_app
|
||||
uses: kevin-david/zipalign-sign-android-release@v1.1
|
||||
with:
|
||||
releaseDirectory: app/build/outputs/apk/armv7/release/
|
||||
signingKeyBase64: ${{ secrets.JAVA_KEYSTORE_DATA }}
|
||||
alias: ${{ secrets.KEYSTORE_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
|
||||
|
||||
- name: Upload armv7 artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: app-armv7-release
|
||||
path: ${{ steps.sign_armv7_app.outputs.signedReleaseFile }}
|
||||
|
||||
- name: Sign armv8 APK
|
||||
id: sign_armv8_app
|
||||
uses: kevin-david/zipalign-sign-android-release@v1.1
|
||||
with:
|
||||
releaseDirectory: app/build/outputs/apk/armv8/release/
|
||||
signingKeyBase64: ${{ secrets.JAVA_KEYSTORE_DATA }}
|
||||
alias: ${{ secrets.KEYSTORE_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
keyPassword: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
|
||||
|
||||
- name: Upload armv8 artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: app-armv8-release
|
||||
path: ${{ steps.sign_armv8_app.outputs.signedReleaseFile }}
|
||||
|
||||
- name: Generate Version
|
||||
run: |
|
||||
./gradlew getVersion
|
||||
|
||||
- name: Set Version to Environment
|
||||
id: version-env
|
||||
run: echo "version=$(cat app/build/version.txt)" >> $GITHUB_ENV
|
||||
|
||||
- name: Publish APK
|
||||
uses: marvinpinto/action-automatic-releases@latest
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
prerelease: false
|
||||
files: |
|
||||
${{ steps.sign_armv7_app.outputs.signedReleaseFile }}
|
||||
${{ steps.sign_armv8_app.outputs.signedReleaseFile }}
|
||||
automatic_release_tag: v${{ env.version }}
|
||||
@@ -6,8 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
def appVersionName = "0.1.1"
|
||||
def appVersionCode = 1
|
||||
def lspatchReleaseUrl = "https://api.github.com/repos/LSPosed/LSPatch/releases/latest"
|
||||
def appVersionCode = 3
|
||||
|
||||
android {
|
||||
compileSdk 33
|
||||
@@ -56,12 +55,6 @@ android {
|
||||
}
|
||||
dimension "release"
|
||||
}
|
||||
prod {
|
||||
ndk {
|
||||
abiFilter("none")
|
||||
}
|
||||
dimension "release"
|
||||
}
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
@@ -71,48 +64,6 @@ android {
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
getTasks().getByPath(":app:assembleProdDebug").doLast {
|
||||
def apkReleaseFile = android.applicationVariants.find { it.buildType.name == "debug" && 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/debug/"
|
||||
}
|
||||
}
|
||||
|
||||
//auto install for debug purpose
|
||||
getTasks().getByPath(":app:assembleArmv8Debug").doLast {
|
||||
def apkDebugFile = android.applicationVariants.find { it.buildType.name == "debug" && it.flavorName == "armv8" }.outputs[0].outputFile
|
||||
@@ -136,6 +87,13 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
task getVersion {
|
||||
doLast {
|
||||
def version = new File('app/build/version.txt')
|
||||
version.text = android.defaultConfig.versionName
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.8.21'
|
||||
|
||||
Reference in New Issue
Block a user