-
Notifications
You must be signed in to change notification settings - Fork 11
133 lines (114 loc) · 3.8 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
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: Check and Delete Existing Tag
run: |
cd NLChat
if git rev-parse ${{ github.ref_name }} >/dev/null 2>&1; then
git tag -d ${{ github.ref_name }}
git push --delete origin ${{ github.ref_name }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "NLChat_${{ github.ref_name }}.apk"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # 使用 PAT
generateReleaseNotes: true
- name: Bump version and generate changelog
id: version
run: |
cd NLChat
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
npm install -g standard-version
standard-version --release-as ${{ github.ref_name }}
git push --follow-tags origin ${{ github.ref_name }}
- 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: Release ${{ github.ref_name }}
body: ${{ env.COMMIT_MESSAGE }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用环境变量
continue-on-error: true