-
Notifications
You must be signed in to change notification settings - Fork 165
88 lines (79 loc) · 3.85 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
name: Android CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths-ignore:
- ".github/**"
- "!.github/workflows/**"
- ".idea/"
- "doc/*"
- "*.md"
- ".github/workflows/crowdin.yml"
- "crowdin.yml"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Build App
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up JDK 20
uses: actions/setup-java@v3
with:
java-version: '20'
distribution: 'temurin'
cache: gradle
- name: Create Sign File
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
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
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 "|Canary|$canary" >> $GITHUB_STEP_SUMMARY
- name: Upload Canary APK
if: contains(github.event.head_commit.message, '[upload]') == true
uses: actions/upload-artifact@v3
with:
name: HyperCeiler Canary
path: ${{ env.APK_FILE_CANARY }}
- name: Post to Beta Channel & Canary Group
if: ${{ github.event_name != 'pull_request' && 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 }}
shell: bash
env:
GROUP_ID: ${{ secrets.CANARY_GROUP_ID }}
GROUP_ID_TEMPORARY: ${{ secrets.GROUP_TEMPORARY_ID }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
CANARY: ${{ env.APK_FILE_CANARY }}
run: |
mkdir -p ${{ github.workspace }}/git_clone
git clone ${{ github.event.repository.url }} ${{ github.workspace }}/git_clone -b ${{ github.ref_name }}
cd ${{ github.workspace }}/git_clone
{ echo -e 'Github CI\n'; git log ${{ github.event.before }}..${{ github.event.after }} --pretty=format:"%h %s"; } > ${{ github.workspace }}/git_log
ESCAPED="$(cat ${{ github.workspace }}/git_log | gawk '{gsub(/[_*[\]()~`>#+=\|{}.!-]/,"\\\\\\\\&")}1' | sed -e 's|"|\\"|g' -e 's|^[0-9a-z]\+|__&__|' | hexdump -v -e '/1 "%02X"' | sed 's/\(..\)/%\1/g')"
cd ${{ github.workspace }}
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${GROUP_ID}&message_thread_id=${MESSAGE_THREAD_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Fcanary%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A%22${ESCAPED}%22%7D%5D" -F canary="@${CANARY}"
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%2Fcanary%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A%22${ESCAPED}%22%7D%5D" -F canary="@${CANARY}"