forked from LibChecker/LibChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (158 loc) · 6.65 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
162
163
164
165
name: Android CI
on:
push:
branches:
- master
paths-ignore:
- '.idea/**'
- '.gitattributes'
- '.github/**.json'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- 'NOTICE'
pull_request:
paths-ignore:
- '.idea/**'
- '.gitattributes'
- '.github/**.json'
- '.gitignore'
- '.gitmodules'
- '**.md'
- 'LICENSE'
- 'NOTICE'
workflow_dispatch:
env:
APP_CENTER_SECRET: ${{secrets.APP_CENTER_SECRET}}
jobs:
check:
name: Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Skip duplicate actions
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: true
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/gradle-build-action@v2
- run: ./gradlew lintKotlin
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/gradle-build-action@v2
- name: Retrieve version
run: |
echo VERSION=$(echo ${{ github.event.head_commit.id }} | head -c 10) >> $GITHUB_ENV
- name: Write sign info
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'LibChecker/LibChecker'
run: |
if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
echo releaseStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
echo releaseKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
echo releaseKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
echo releaseStoreFile='${{ github.workspace }}/key.jks' >> gradle.properties
echo ${{ secrets.SIGNING_KEY }} | base64 --decode > ${{ github.workspace }}/key.jks
fi
- name: Build with Gradle
run: ./gradlew -PappVerName=${{ env.VERSION }} app:assembleRelease
- name: Upload built Foss apk
if: success() && github.event_name != 'pull_request' && github.repository == 'LibChecker/LibChecker'
uses: actions/upload-artifact@v3
with:
name: Foss
path: ${{ github.workspace }}/app/build/outputs/apk/foss/release
- name: Upload built Market apk
if: success() && github.event_name != 'pull_request' && github.repository == 'LibChecker/LibChecker'
uses: actions/upload-artifact@v3
with:
name: Market
path: ${{ github.workspace }}/app/build/outputs/apk/market/release
- name: Upload mappings
if: success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: mappings
path: "app/build/outputs/mapping/marketRelease"
- name: Set apk path
id: apk-path
run: |
foss_path=$(find **/build/outputs/apk/foss -name '*.apk' -type f | head -1)
echo "::set-output name=foss_path::$foss_path"
market_path=$(find **/build/outputs/apk/market -name '*.apk' -type f | head -1)
echo "::set-output name=market_path::$market_path"
- name: Get apk info
if: success() && github.event_name != 'pull_request' && github.repository == 'LibChecker/LibChecker'
id: apk-info
uses: hkusu/apk-info-action@v1
with:
apk-path: ${{ steps.apk-path.outputs.foss_path }}
- name: Upload mappings with App Center CLI
if: success() && github.event_name != 'pull_request' && github.repository == 'LibChecker/LibChecker'
uses: avocaddo/AppCenter-Github-Action@v1.0.2
with:
command: appcenter crashes upload-mappings --mapping app/build/outputs/mapping/marketRelease/mapping.txt --version-name ${{ steps.apk-info.outputs.version-name }} --version-code ${{ steps.apk-info.outputs.version-code }} --app zhaobozhen2025-gmail.com/LibChecker
token: ${{secrets.APP_CENTER_TOKEN}}
- name: Send commit to telegram
if: success() && github.repository == 'LibChecker/LibChecker' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
env:
CHANNEL_ID: ${{ secrets.TELEGRAM_TO }}
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
FOSS_FILE: ${{ steps.apk-path.outputs.foss_path }}
MARKET_FILE: ${{ steps.apk-path.outputs.market_path }}
COMMIT_MESSAGE: |+
New push to github\!
```
${{ github.event.head_commit.message }}
```by `${{ github.event.head_commit.author.name }}`
See commit detail [here](${{ github.event.head_commit.url }})
Snapshot apk is attached
run: |
ESCAPED=`python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))'`
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2FmarketRelease%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22:${ESCAPED}%7D%5D" -F marketRelease="@$MARKET_FILE"
skipped:
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message, '[skip ci]') }}
steps:
- uses: actions/checkout@v3
- name: Send commit to telegram
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |+
New push to github!
*${{ github.event.head_commit.message }}* by ${{ github.event.head_commit.author.name }}
See commit detail [here](${{ github.event.head_commit.url }})
This push skipped building
cancelled:
runs-on: ubuntu-latest
if: ${{ cancelled() && github.repository == 'LibChecker/LibChecker' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
needs: [check, build]
steps:
- name: Send commit to telegram if cancelled
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |+
New push to github!
*${{ github.event.head_commit.message }}* by ${{ github.event.head_commit.author.name }}
See commit detail [here](${{ github.event.head_commit.url }})
This push cancelled building