-
Notifications
You must be signed in to change notification settings - Fork 4
58 lines (56 loc) · 2.54 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
name: Android CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: |
echo ${{ secrets.SIGNING_KEY }} | base64 -d > keystore.jks
./gradlew assemble
env:
KEYSTORE_PATH: "../keystore.jks"
KEYSTORE_PASS: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Upload Release Snapshot
uses: actions/upload-artifact@v4
with:
name: MediaControl-Release-Snapshot
path: app/build/outputs/apk/release
compression-level: 9
- name: Upload Debug Snapshot
uses: actions/upload-artifact@v4
with:
name: MediaControl-Debug-Snapshot
path: app/build/outputs/apk/debug
compression-level: 9
- name: Post to Telegram ci channel
if: ${{ success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' }}
env:
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
export RELEASE=$(find "app/build/outputs/apk/release/" -name "*.apk")
export DEBUG=$(find "app/build/outputs/apk/debug/" -name "*.apk")
event_path=$GITHUB_EVENT_PATH
commit_count=$(jq -r '.commits | length' $event_path)
{ echo -e 'New CI from MediaControl-BlurBg\n'; git log -$commit_count --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=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fdebug%22%2C%22caption%22%3A%22${ESCAPED}%22%2C%22parse_mode%22%3A%22MarkdownV2%22%7D%5D" -F release="@$RELEASE" -F debug="@$DEBUG"
fi