-
-
Notifications
You must be signed in to change notification settings - Fork 22
134 lines (115 loc) · 4.63 KB
/
pre_release.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
name: Pre-Release
# Trigger
on:
workflow_dispatch:
push:
branches:
- 'master'
paths-ignore:
- '**.md'
- 'doc/**'
- 'image/**'
jobs:
build:
name: Build
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Checkout Secret
uses: actions/checkout@v4
with:
repository: ${{ secrets.SECRET_REPO }}
token: ${{ secrets.TOKEN }} # Repo token
path: secret
# Prepare secret files
- name: Copy Secret Files
run: |
cd secret/AniVu
cp key.jks ../..
cp secret.gradle.kts ../..
# Clean secret files
- name: Clean Temp Secret Files
run: |
rm -rf ./secret
# Build
- name: Build with Gradle
run: |
bash ./gradlew assembleGitHubRelease
# Upload apk (arm64-v8a)
- name: Upload Pre-Release Apk (arm64-v8a)
uses: actions/upload-artifact@v4
with:
name: Pre-Release Apk (arm64-v8a)
path: app/build/outputs/apk/GitHub/release/*arm64-v8a*.apk
compression-level: 9
# Upload apk (armeabi-v7a)
- name: Upload Pre-Release Apk (armeabi-v7a)
uses: actions/upload-artifact@v4
with:
name: Pre-Release Apk (armeabi-v7a)
path: app/build/outputs/apk/GitHub/release/*armeabi-v7a*.apk
compression-level: 9
# Upload apk (x86_64)
- name: Upload Pre-Release Apk (x86_64)
uses: actions/upload-artifact@v4
with:
name: Pre-Release Apk (x86_64)
path: app/build/outputs/apk/GitHub/release/*x86_64*.apk
compression-level: 9
# Upload apk (x86)
- name: Upload Pre-Release Apk (x86)
uses: actions/upload-artifact@v4
with:
name: Pre-Release Apk (x86)
path: |
app/build/outputs/apk/GitHub/release/*x86*.apk
!app/build/outputs/apk/GitHub/release/*x86_64*.apk
compression-level: 9
# Upload apk (universal)
- name: Upload Pre-Release Apk (universal)
uses: actions/upload-artifact@v4
with:
name: Pre-Release Apk (universal)
path: app/build/outputs/apk/GitHub/release/*universal*.apk
compression-level: 9
# Upload mapping
- name: Upload Pre-Release Mapping
uses: actions/upload-artifact@v4
with:
name: Pre-Release Mapping
path: app/build/outputs/mapping/GitHubRelease/mapping.txt
compression-level: 9
# Get apk path
- name: Get Pre-Release Apk File Path
run: |
echo "PRE_RELEASE_APK_ARM64_V8=$(find app/build/outputs/apk/GitHub/release -name '*arm64-v8a*.apk' -type f | head -1)" >> $GITHUB_ENV
echo "PRE_RELEASE_APK_ARM_V7=$(find app/build/outputs/apk/GitHub/release -name '*armeabi-v7a*.apk' -type f | head -1)" >> $GITHUB_ENV
echo "PRE_RELEASE_APK_X86_64=$(find app/build/outputs/apk/GitHub/release -name '*x86_64*.apk' -type f | head -1)" >> $GITHUB_ENV
echo "PRE_RELEASE_APK_X86=$(find app/build/outputs/apk/GitHub/release -name '*x86*.apk' -type f | head -1)" >> $GITHUB_ENV
echo "PRE_RELEASE_APK_UNIVERSAL=$(find app/build/outputs/apk/GitHub/release -name '*universal*.apk' -type f | head -1)" >> $GITHUB_ENV
# Send to Telegram
- name: Post to Telegram Channel
if: github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[skip_post]') == false
env:
CHANNEL_ID: ${{ secrets.TELEGRAM_TO }}
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
PRE_RELEASE_ARM64_V8: ${{ env.PRE_RELEASE_APK_ARM64_V8 }}
PRE_RELEASE_ARM_V7: ${{ env.PRE_RELEASE_APK_ARM_V7 }}
PRE_RELEASE_X86_64: ${{ env.PRE_RELEASE_APK_X86_64 }}
PRE_RELEASE_X86: ${{ env.PRE_RELEASE_APK_X86 }}
PRE_RELEASE_UNIVERSAL: ${{ env.PRE_RELEASE_APK_UNIVERSAL }}
COMMIT_MESSAGE: |+
GitHub New CI: AniVu\
`${{ github.event.head_commit.message }}`
by `${{ github.event.head_commit.author.name }}`
Commit details [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"])))'`
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%2Fpre_release_arm64_v8%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" -F pre_release_arm64_v8="@$PRE_RELEASE_ARM64_V8"