This repository was archived by the owner on Jul 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
137 lines (120 loc) · 4.03 KB
/
Copy pathandroid_ci.yml
File metadata and controls
137 lines (120 loc) · 4.03 KB
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
name: WeKit Android CI
on:
push:
branches:
- master
paths-ignore:
- '**/*.md'
- '**/*.txt'
- 'renovate.json'
- '.editorconfig'
- '.gitignore'
- '.github/**'
- '.github/workflows/**'
- '.idea/**'
pull_request:
branches:
- master
paths-ignore:
- '**/*.md'
- '**/*.txt'
- 'renovate.json'
- '.editorconfig'
- '.gitignore'
- '.github/**'
- '.github/workflows/**'
- '.idea/**'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
(
!startsWith(github.event.head_commit.message, '[skip ci]') &&
(github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Decode keystore
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master'
run: |
mkdir -p app
echo "$KEYSTORE_B64" | base64 -d > app/wekit.jks
env:
KEYSTORE_B64: ${{ secrets.KEYSTORE_B64 }}
- name: Grant execute permission
run: chmod +x gradlew
- name: Build unsigned Release for PR
if: github.event_name == 'pull_request'
run: ./gradlew assembleRelease --warning-mode all --stacktrace
- name: Build signed Release for master
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master'
run: |
./gradlew assembleRelease \
-PKEYSTORE_FILE=wekit.jks \
-PKEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }} \
-PKEY_ALIAS=key0 \
-PKEY_PASSWORD=${{ secrets.KEY_PASSWORD }} \
--warning-mode all --stacktrace
- name: Upload Release APK
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: wekit-apk
path: app/build/outputs/apk/release/**/*.apk
upload-telegram:
needs: build
runs-on: ubuntu-latest
if: ${{ success() && github.ref == 'refs/heads/master' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Download APK artifact
uses: actions/download-artifact@v4
with:
name: wekit-apk
path: artifacts
- name: Find APK file
id: find_apk
run: |
apk=$(ls artifacts/*.apk)
echo "apk_path=$apk" >> $GITHUB_OUTPUT
- name: Send APK via Telegram API
env:
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
APK_PATH: ${{ steps.find_apk.outputs.apk_path }}
SHA: ${{ github.sha }}
COMMIT_MSG: ${{ github.event.head_commit.message || 'Manual Build' }}
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name || github.actor }}
REPO: ${{ github.repository }}
run: |
echo "Sending $APK_PATH"
commit_msg="$COMMIT_MSG"
commit_author="$COMMIT_AUTHOR"
commit_url="https://github.com/${REPO}/commit/${SHA}"
caption="🎉 *检测到新的 GitHub 推送!*
*Commit SHA:* \`${SHA}\`
\`\`\`
${commit_msg}
\`\`\`
*提交者* \`${commit_author}\`
[查看详情](${commit_url})"
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document=@"${APK_PATH}" \
-F caption="${caption}" \
-F parse_mode=Markdown