-
Notifications
You must be signed in to change notification settings - Fork 11
180 lines (157 loc) · 5.1 KB
/
androidsign.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Android CI Release
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: NLChat # 确保代码被检出到NLChat目录
- name: Set up JDK 17
id: setup-java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Set JAVA_HOME
run: echo "JAVA_HOME=${{ steps.setup-java.outputs.path }}" >> $GITHUB_ENV
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 'current' # 使用最新的 Gradle 版本
- name: Grant execute permission for gradlew
run: chmod +x NLChat/gradlew
- name: Build Project
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }} # 显式设置 JAVA_HOME
run: |
echo "JAVA_HOME=${JAVA_HOME}" # 确认 JAVA_HOME 已设置
cd NLChat
./gradlew assembleRelease
- name: Sign
uses: r0adkll/sign-android-release@v1
id: sign_app
with:
releaseDirectory: NLChat/app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "34.0.0"
- name: List files in release directory
run: ls -R NLChat/app/build/outputs/apk/release
- name: Upload Signed APK
uses: actions/upload-artifact@v3
with:
name: signed-apk
path: NLChat/app/build/outputs/apk/release/app-release-unsigned-signed.apk
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: NLChat # 确保代码被检出到NLChat目录
- name: Download Signed APK
uses: actions/download-artifact@v3
with:
name: signed-apk
path: NLChat/app/build/outputs/apk/release
- name: Release Ready
run: |
if [ -f "NLChat/app/build/outputs/apk/release/app-release-unsigned-signed.apk" ]; then
mv NLChat/app/build/outputs/apk/release/app-release-unsigned-signed.apk NLChat_${{ github.ref_name }}.apk
else
echo "Error: APK file not found!"
exit 1
fi
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "NLChat_${{ github.ref_name }}.apk"
token: ${{ secrets.GITHUB_TOKEN }} # 使用 PAT
generateReleaseNotes: true
- name: Get Commit Message
id: get_commit_message
run: |
cd NLChat
echo "COMMIT_MESSAGE=$(git log -1 --pretty=%B)" >> $GITHUB_ENV
continue-on-error: true
- name: Create or Update Release Notes
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ env.COMMIT_MESSAGE }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用环境变量
continue-on-error: true
multi-platform-test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
api-level: [28, 29, 31, 33] # 你可以根据需要调整 API 级别
target: [default, google_apis]
arch: [x86_64, arm64-v8a] # 你可以根据需要调整架构
include:
- api-level: 29
target: default
arch: x86_64
- api-level: 29
target: default
arch: arm64-v8a
- api-level: 29
target: google_apis
arch: arm64-v8a
- api-level: 31
target: default
arch: x86_64
- api-level: 31
target: google_apis
arch: x86_64
- api-level: 31
target: google_apis
arch: arm64-v8a
- api-level: 33
target: default
arch: x86_64
- api-level: 33
target: google_apis
arch: x86_64
- api-level: 33
target: google_apis
arch: arm64-v8a
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Instrumentation Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew connectedAndroidTest --stacktrace