-
Notifications
You must be signed in to change notification settings - Fork 183
161 lines (144 loc) · 5.57 KB
/
ci_build.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: CI Build
on:
pull_request:
types: [opened, synchronize]
paths-ignore:
- ".github/**"
- "!.github/workflows/**"
- ".idea/"
- "doc/*"
- "*.md"
- "app/src/assets/**"
- ".github/workflows/crowdin.yml"
- "crowdin.yml"
push:
branches: [main]
paths-ignore:
- ".github/**"
- "!.github/workflows/**"
- ".idea/"
- "doc/*"
- "*.md"
- "app/src/assets/**"
- "crowdin.yml"
workflow_dispatch:
jobs:
build_canary_package:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: Build Canary Package
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Create Sign File
run: |
touch signing.properties
echo storePassword=${{ secrets.KEY_STORE_PASSWORD }} >> signing.properties
echo keyAlias=${{ secrets.ALIAS }} >> signing.properties
echo keyPassword='${{ secrets.KEY_STORE_PASSWORD }}' >> signing.properties
echo storeFile=../key.jks >> signing.properties
echo ${{ secrets.SIGNING_KEY }} | base64 --decode > key.jks
- name: Build with Gradle (Canary)
shell: bash
run: ./gradlew assembleCanary
- name: Find APKs
run: |
echo "APK_FILE_CANARY=$(find app/build/outputs/apk/canary -name '*.apk')" >> $GITHUB_ENV
- name: Show APKs SHA256
if: success()
run: |
echo "### Build Success" >> $GITHUB_STEP_SUMMARY
echo "|Artifact|SHA256|" >> $GITHUB_STEP_SUMMARY
echo "|:--------:|:----------|" >> $GITHUB_STEP_SUMMARY
canary=$(sha256sum "${{ env.APK_FILE_CANARY }}")
echo "SHA256=$canary" >> $GITHUB_ENV
echo "|Canary|$canary" >> $GITHUB_STEP_SUMMARY
build_debug_package:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Build Debug Package
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Build with Gradle (Debug)
shell: bash
run: ./gradlew assembleDebug
- name: Find APKs
run: |
echo "APK_FILE_DEBUG=$(find app/build/outputs/apk/debug -name '*.apk')" >> $GITHUB_ENV
- name: Show APKs SHA256
if: success()
run: |
echo "### Build Success" >> $GITHUB_STEP_SUMMARY
echo "|Artifact|SHA256|" >> $GITHUB_STEP_SUMMARY
echo "|:--------:|:----------|" >> $GITHUB_STEP_SUMMARY
debug=$(sha256sum "${{ env.APK_FILE_DEBUG }}")
echo "SHA256=$debug" >> $GITHUB_ENV
echo "|Debug|$debug" >> $GITHUB_STEP_SUMMARY
push_to_canary_channel:
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && ${{ github.ref == 'refs/heads/main' && github.ref_type != 'tag' && contains(github.event.head_commit.message, '[skip post]') == false && contains(github.event.head_commit.message, 's#') == false }}
runs-on: ubuntu-latest
name: Push to Canary Channel
needs: build_canary_package
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Upload Canary APK
uses: actions/upload-artifact@v4
with:
name: HyperCeiler Canary
path: ${{ env.APK_FILE_CANARY }}
- name: Post to Canary Channel
env:
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
CANARY: ${{ env.APK_FILE_CANARY }}
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 }})
run: |
ESCAPED=$(python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))')
cd ${{ github.workspace }}
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://canary%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F canary="@${CANARY}"
push_to_debug_group:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Push to Debug Group
needs: build_debug_package
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Post to Debug Group
shell: bash
env:
GROUP_DEBUG_ID: ${{ secrets.GROUP_DEBUG_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
DEBUG: ${{ env.APK_FILE_DEBUG }}
COMMIT_MESSAGE: |+
New push to GitHub
by `${{ github.triggering_actor }}`
run: |
ESCAPED=$(python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))')
cd ${{ github.workspace }}
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${GROUP_DEBUG_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://debug%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F debug="@${DEBUG}"