-
-
Notifications
You must be signed in to change notification settings - Fork 4
166 lines (145 loc) · 5.94 KB
/
ci.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
name: CI
on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
concurrency:
group: environment-${{ github.ref }}
cancel-in-progress: false
jobs:
job-common:
runs-on: ubuntu-latest
outputs:
SHORT_SHA: ${{ steps.expose_sha.outputs.short_sha }}
steps:
- name: expose short commit sha
id: expose_sha
run: |
SHORT_SHA=${GITHUB_SHA::7}
echo "short_sha=$SHORT_SHA" >> $GITHUB_ENV
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
build-android:
if: ${{ vars.ANDROID_BUILD_ENABLED == 'true' }}
needs: job-common
env:
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
SHORT_SHA: ${{ needs.job-common.outputs.SHORT_SHA }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # клонирует репозиторий с историей коммитов
- name: setup jdk 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: cache gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('/*.gradle*', '/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: cache gradle wrapper
uses: actions/cache@v3
with:
path: ~/.gradle/wrapper
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: clean outputs directory
run: rm -rf app/build/outputs/*
- name: make gradlew executable
run: chmod +x ./gradlew
- name: decode keystore file
id: decode_keystore_file
uses: timheuer/base64-to-file@v1
with:
fileName: 'keystore_release.jks'
encodedString: ${{ secrets.KEYSTORE_FILE }}
- name: set decoded file location as environment
run: echo "KEYSTORE_FILE=${{ steps.decode_keystore_file.outputs.filePath }}" >> $GITHUB_ENV
- name: assemble debug artifact
run: ./gradlew assembleDebug
- name: assemble release artifact
run: ./gradlew assembleRelease
- name: bundle release artifact
run: ./gradlew bundleRelease
- name: upload artifacts to outputs
uses: actions/upload-artifact@v4
with:
path: |
app/build/outputs/apk/debug
app/build/outputs/apk/release
app/build/outputs/bundle/release
- name: expose version name
id: version_name
run: |
VERSION_NAME=$(./gradlew printVersionName -q)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
- name: expose version code
id: version_code
run: |
VERSION_CODE=$(./gradlew printVersionCode -q)
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: expose artifacts
run: |
echo "DEBUG_APK_PATH=$(find app/build/outputs/apk/debug -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
echo "RELEASE_APK_PATH=$(find app/build/outputs/apk/release -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
echo "BUNDLE_APK_PATH=$(find app/build/outputs/bundle/release -name '*.aab' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
- name: send telegram message debug
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
MESSAGE: |
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
<b>Ветка:</b> ${{ github.ref_name }}
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.DEBUG_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
- name: send telegram message release
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
MESSAGE: |
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
<b>Ветка:</b> ${{ github.ref_name }}
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.RELEASE_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
- name: send telegram message bundle
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
MESSAGE: |
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
<b>Ветка:</b> ${{ github.ref_name }}
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.BUNDLE_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"