-
Notifications
You must be signed in to change notification settings - Fork 32
161 lines (139 loc) · 5.18 KB
/
android.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
name: Android CI
on:
push:
branches:
- master
paths-ignore:
- 'source/**'
- '**.md'
- '.**'
- 'fastlane/**'
pull_request:
paths-ignore:
- 'source/**'
- '**.md'
- '.**'
- 'fastlane/**'
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
NDK_VERSION: 26.3.11579264
steps:
- name: Setup Repo
uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
- name: Install Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install NDK
run: echo "y" | sdkmanager --install "ndk;${{ env.NDK_VERSION }}"
- name: Install Cargo with aarch64-linux-android
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android
- name: Add Rust targe tarchitectures
run: |
rustup target add x86_64-linux-android
rustup target add armv7-linux-androideabi
- name: Retrieve version
run: |
echo VERSION=$(git rev-parse --short HEAD) >> $GITHUB_ENV
# Split due https://github.com/mozilla/rust-android-gradle/issues/38
- name: Build with Gradle (debug)
run: ./gradlew -PappVerName=${{ env.VERSION }} assembleDebug
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Build with Gradle (release)
if: ${{ !github.event.pull_request }}
run: ./gradlew -PappVerName=${{ env.VERSION }} assembleRelease
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Sign Android release
if: ${{ !github.event.pull_request }}
id: sign
uses: r0adkll/[email protected]
env:
BUILD_TOOLS_VERSION: "32.0.0"
with:
releaseDirectory: app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Upload debug apk
uses: actions/upload-artifact@v4
if: ${{ !github.event.pull_request }}
with:
path: './app/build/outputs/apk/debug/*.apk'
name: build_debug_${{ env.VERSION }}
- name: Upload release apk
uses: actions/upload-artifact@v4
if: ${{ !github.event.pull_request }}
with:
path: ${{ steps.sign.outputs.signedReleaseFile }}
name: build_release_${{ env.VERSION }}
- name: Get apk info
if: ${{ !github.event.pull_request }}
id: apk-info
uses: hkusu/apk-info-action@v1
with:
apk-path: ${{ steps.sign.outputs.signedReleaseFile }}
# - name: Upload mappings with App Center CLI
# if: ${{ !github.event.pull_request }}
# uses: zhaobozhen/[email protected]
# with:
# command: appcenter crashes upload-mappings --mapping app/build/outputs/mapping/release/mapping.txt --version-name ${{ steps.apk-info.outputs.version-name }} --version-code ${{ steps.apk-info.outputs.version-code }} --app DUpdateSystem/UpgradeAll
# token: ${{secrets.APP_CENTER_TOKEN}}
- name: Find debug APK
if: ${{ !github.event.pull_request }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
OUTPUT="app/build/outputs/apk/debug/"
DEBUG_APK=$(find $OUTPUT -name "*.apk")
echo "DEBUG_APK=$DEBUG_APK" >> $GITHUB_ENV
fi
- name: Generate Commit Message
if: ${{ !github.event.pull_request }}
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:%s)
AUTHOR_NAME=$(git log -1 --pretty=format:%an)
REMOTE_URL=$(git remote get-url origin)
HOME_URL=$(echo $REMOTE_URL | sed -E "s|[email protected]:|https://github.com/|" | sed -E "s|\.git$||")
COMMIT_URL=$HOME_URL/commit/${{ env.VERSION }}
TELEGRAM_MESSAGE="New push to Github!
\`\`\`$COMMIT_MESSAGE\`\`\`
by \`$AUTHOR_NAME\`
See commit detail [Here]($COMMIT_URL)
Snapshot apk is attached"
echo "TELEGRAM_MESSAGE<<EOF" >> $GITHUB_ENV
echo "$TELEGRAM_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Send commit to Telegram
if: ${{ !github.event.pull_request }}
uses: xz-dev/[email protected]
env:
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
API_ID: ${{ secrets.TELEGRAM_API_ID }}
API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
with:
to-who: ${{ secrets.TELEGRAM_TO }}
message: ${{ env.TELEGRAM_MESSAGE }}
files: |
/github/workspace/${{ steps.sign.outputs.signedReleaseFile }}
/github/workspace/${{ env.DEBUG_APK }}
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 2