Skip to content

Commit 0f2935f

Browse files
committed
1
1 parent 753d230 commit 0f2935f

24 files changed

Lines changed: 1088 additions & 674 deletions

.github/workflows/Build-Apk.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build-Apk
2+
3+
on:
4+
workflow_dispatch:
5+
6+
push:
7+
branches:
8+
- '**'
9+
paths-ignore:
10+
- 'LICENSE'
11+
- '*.md'
12+
- '.github/**'
13+
14+
jobs:
15+
build:
16+
if: ${{ !startsWith(github.event.head_commit.message, 'chore:') && !startsWith(github.event.head_commit.message, 'chore(') }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- uses: actions/setup-java@v5
22+
with:
23+
distribution: 'zulu'
24+
java-version: '21'
25+
26+
- uses: gradle/actions/setup-gradle@v5
27+
with:
28+
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
29+
30+
- name: write secrets info
31+
run: |
32+
echo keystore.password='${{ secrets.STORE_PASSWORD }}' >> signing.properties
33+
echo key.alias='${{ secrets.KEY_ALIAS }}' >> signing.properties
34+
echo key.password='${{ secrets.KEY_PASSWORD }}' >> signing.properties
35+
36+
- run: chmod 777 ./gradlew
37+
- run: ./gradlew app:assembleGkdRelease
38+
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: release
42+
path: app/build/outputs/apk/release
43+
44+
- uses: actions/upload-artifact@v4
45+
with:
46+
name: outputs
47+
path: app/build/outputs
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Build-Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
14+
- uses: actions/setup-java@v5
15+
with:
16+
distribution: 'zulu'
17+
java-version: '21'
18+
19+
- uses: gradle/actions/setup-gradle@v5
20+
with:
21+
cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }}
22+
23+
- name: write secrets info
24+
run: |
25+
echo keystore.password='${{ secrets.STORE_PASSWORD }}' >> signing.properties
26+
echo key.alias='${{ secrets.KEY_ALIAS }}' >> signing.properties
27+
echo key.password='${{ secrets.KEY_PASSWORD }}' >> signing.properties
28+
29+
- run: chmod 777 ./gradlew
30+
- run: ./gradlew app:assembleGkdRelease app:bundlePlayRelease
31+
32+
- uses: actions/upload-artifact@v4
33+
with:
34+
name: release
35+
path: app/build/outputs/apk/release
36+
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: outputs
40+
path: app/build/outputs
41+
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: CHANGELOG.md
45+
path: CHANGELOG.md
46+
47+
release:
48+
needs: build
49+
permissions: write-all
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/download-artifact@v4
53+
with:
54+
name: outputs
55+
path: outputs
56+
57+
- uses: actions/download-artifact@v4
58+
with:
59+
name: release
60+
path: release
61+
62+
- uses: actions/download-artifact@v4
63+
with:
64+
name: CHANGELOG.md
65+
66+
- run: ls -R
67+
68+
- id: create_release
69+
uses: actions/create-release@v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
tag_name: ${{ github.ref_name }}
74+
release_name: Release ${{ github.ref_name }}
75+
body_path: ./CHANGELOG.md
76+
prerelease: ${{ contains(github.ref_name, 'beta') }}
77+
78+
- name: Find and upload APK
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
run: |
82+
APK_PATH=$(find release -name "AutoGLM-*-release.apk" -type f | head -1)
83+
if [ -z "$APK_PATH" ]; then
84+
echo "Error: APK file not found"
85+
exit 1
86+
fi
87+
echo "Found APK: $APK_PATH"
88+
curl -X POST \
89+
-H "Authorization: token $GITHUB_TOKEN" \
90+
-H "Content-Type: application/vnd.android.package-archive" \
91+
--data-binary @"$APK_PATH" \
92+
"${{ steps.create_release.outputs.upload_url }}?name=AutoGLM-${{ github.ref_name }}.apk"
93+
94+
- run: zip -r outputs.zip outputs
95+
- uses: actions/upload-release-asset@v1
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
upload_url: ${{ steps.create_release.outputs.upload_url }}
100+
asset_path: outputs.zip
101+
asset_name: outputs-${{ github.ref_name }}.zip
102+
asset_content_type: application/zip

app/build.gradle.kts

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import com.android.build.api.variant.ApplicationVariant
2+
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
3+
import java.text.SimpleDateFormat
4+
import java.util.Date
5+
import java.util.Locale
6+
import java.util.Properties
7+
18
plugins {
29
alias(libs.plugins.android.application)
310
alias(libs.plugins.kotlin.android)
@@ -7,14 +14,6 @@ plugins {
714
}
815

916
android {
10-
signingConfigs {
11-
create("release") {
12-
storeFile = file("E:\\Android\\certificate\\repobor.jks")
13-
storePassword = "kx2015"
14-
keyAlias = "key0"
15-
keyPassword = "kx2015"
16-
}
17-
}
1817
namespace = "io.repobor.autoglm"
1918
compileSdk = 36
2019

@@ -28,16 +27,14 @@ android {
2827
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2928
}
3029

31-
buildTypes {
32-
release {
33-
isMinifyEnabled = true
34-
proguardFiles(
35-
getDefaultProguardFile("proguard-android-optimize.txt"),
36-
"proguard-rules.pro"
37-
)
38-
signingConfig = signingConfigs.getByName("release")
30+
applicationVariants.all {
31+
outputs.all {
32+
@Suppress("DEPRECATION")
33+
(this as BaseVariantOutputImpl).outputFileName =
34+
"${rootProject.name}-${versionName}-${buildType.name}.apk"
3935
}
4036
}
37+
4138
compileOptions {
4239
sourceCompatibility = JavaVersion.VERSION_11
4340
targetCompatibility = JavaVersion.VERSION_11
@@ -49,6 +46,37 @@ android {
4946
compose = true
5047
aidl = true
5148
}
49+
50+
// ===== signing config =====
51+
val signingPropsFile = rootProject.file("signing.properties")
52+
val signingProps = Properties()
53+
if (signingPropsFile.exists()) {
54+
signingPropsFile.inputStream().use(signingProps::load)
55+
val storePath = "release.jks"
56+
val storePwd = signingProps.getProperty("keystore.password")
57+
val keyAliasVal = signingProps.getProperty("key.alias")
58+
val keyPwd = signingProps.getProperty("key.password")
59+
signingConfigs {
60+
create("release") {
61+
storeFile = rootProject.file(storePath)
62+
storePassword = storePwd
63+
keyAlias = keyAliasVal
64+
keyPassword = keyPwd
65+
}
66+
}
67+
68+
} else {
69+
logger.lifecycle(">>> signing.properties NOT FOUND, release will use debug signing")
70+
}
71+
72+
buildTypes {
73+
release {
74+
// 只有在 signing.properties 存在时才使用 release 签名
75+
signingConfig =
76+
signingConfigs.findByName("release")
77+
?: signingConfigs.getByName("debug")
78+
}
79+
}
5280
}
5381

5482
dependencies {

0 commit comments

Comments
 (0)