-
-
Notifications
You must be signed in to change notification settings - Fork 23
84 lines (73 loc) · 2.9 KB
/
Copy pathandroid.yaml
File metadata and controls
84 lines (73 loc) · 2.9 KB
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
name: Android
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up signing key
if: github.ref == 'refs/heads/main'
run: |
if [ ! -z "${{ secrets.KEY_STORE }}" ]; then
echo key.store.password='${{ secrets.KEY_STORE_PASSWORD }}' >> signing.properties
echo key.alias='${{ secrets.KEY_ALIAS }}' >> signing.properties
echo key.password='${{ secrets.KEY_PASSWORD }}' >> signing.properties
echo key.store='${{ github.workspace }}/key.jks' >> signing.properties
echo ${{ secrets.KEY_STORE }} | base64 --decode > ${{ github.workspace }}/key.jks
fi
- name: Set up JDK
uses: actions/setup-java@v6
with:
distribution: 'jetbrains'
java-version: 21
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
with:
build-scan-publish: false
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
- name: Build with Gradle
run: ./gradlew assembleRelease
- name: Get release name
if: success() && github.ref == 'refs/heads/main'
id: release-name
run: |
name=`ls app/build/outputs/apk/release/*.apk | awk -F '(/|.apk)' '{print $6}'` && echo "name=${name}" >> $GITHUB_OUTPUT
- name: Upload apk
if: success() && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v7
with:
name: ${{ steps.release-name.outputs.name }}
path: app/build/outputs/apk/release/*.apk*
- name: Upload mapping
if: success() && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v7
with:
name: ${{ steps.release-name.outputs.name }}-mapping
path: app/build/outputs/mapping/release
- name: Post to channel
if: success() && github.ref == 'refs/heads/main'
continue-on-error: true
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
RELEASE_FILE=$(find app/build/outputs/apk/release -name "*.apk")
ESCAPED=$(python3 -c 'import json,os; print(json.dumps(os.environ["COMMIT_MESSAGE"]))')
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup" \
-F "chat_id=${CHANNEL_ID}" \
-F "media=[{\"type\":\"document\",\"media\":\"attach://release\",\"caption\":${ESCAPED}}]" \
-F "release=@${RELEASE_FILE}"
fi