-
-
Notifications
You must be signed in to change notification settings - Fork 116
247 lines (206 loc) · 9.4 KB
/
Copy pathgradle.yml
File metadata and controls
247 lines (206 loc) · 9.4 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: Android Build & Sign
on:
push:
branches: [main]
tags:
- 'v*'
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Gradle
uses: actions/cache@v5
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-gms-universal-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-gms-universal-
${{ runner.os }}-gradle-
- name: Create local.properties
run: echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
- name: Create google-services.json
if: env.HAS_GOOGLE_SERVICES == 'true'
env:
HAS_GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES_JSON != '' }}
GOOGLE_SERVICES_CONTENT: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: |
printf "%s" "$GOOGLE_SERVICES_CONTENT" > app/google-services.json
- name: Set up Signing Keystore
if: env.HAS_KEYSTORE == 'true'
env:
HAS_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' }}
RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
run: |
mkdir -p app/keystore
echo "$RELEASE_KEYSTORE_BASE64" | base64 --decode > app/keystore/release.keystore
- name: Build and Sign Release APK (Push to main / Dispatch / Tag)
env:
STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
LASTFM_SECRET: ${{ secrets.LASTFM_SECRET }}
run: ./gradlew assembleUniversalGmsRelease
- name: Rename and Organize APKs
run: |
VERSION_NAME=$(grep "versionName =" app/build.gradle.kts | head -n 1 | awk -F '"' '{print $2}')
echo "App Version: $VERSION_NAME"
mkdir -p app/build/outputs/apk/release-artifacts
find app/build/outputs/apk/ -name "*.apk" ! -path "*/release-artifacts/*" | while read -r apk_path; do
target_name="Echo-${VERSION_NAME}-Universal.apk"
cp "$apk_path" "app/build/outputs/apk/release-artifacts/$target_name"
echo "Copied $apk_path -> app/build/outputs/apk/release-artifacts/$target_name"
done
- name: Upload APK Artifact
uses: actions/upload-artifact@v4
with:
name: Echo-Universal
path: app/build/outputs/apk/release-artifacts/*.apk
- name: Parse Release Info
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
# 1. Read first line and strip the "# " to get the Title
TITLE=$(head -n 1 RELEASE_INFO.md | sed 's/^# //')
echo "RELEASE_TITLE=$TITLE" >> $GITHUB_ENV
# 2. Read from line 3 onwards to get the Description body
tail -n +3 RELEASE_INFO.md > release-body.md
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_TITLE }}
body_path: release-body.md
files: app/build/outputs/apk/release-artifacts/*.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Send Telegram Notification
if: startsWith(github.ref, 'refs/tags/v')
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
RELEASE_TITLE: ${{ env.RELEASE_TITLE }}
run: |
# Read release body
BODY=$(cat release-body.md)
# Escape HTML characters for Telegram and truncate if too long
SAFE_BODY=$(echo "$BODY" | sed 's/&/\&/g; s/</\</g; s/>/\>/g')
if [ ${#SAFE_BODY} -gt 3000 ]; then
SAFE_BODY="${SAFE_BODY:0:3000}..."$'\n\n'"[Changelog truncated due to length. See GitHub Release for full details.]"
fi
# Construct HTML formatted message (Telegram supports HTML tags)
if echo "$BODY" | grep -q "Support the Project"; then
MESSAGE="hello everyone,
<b>$RELEASE_TITLE</b>
$SAFE_BODY
Note: If you encounter an 'App not installed' error during installation, please uninstall the previous version before installing this update."
else
MESSAGE="hello everyone,
<b>$RELEASE_TITLE</b>
$SAFE_BODY
Note: If you encounter an 'App not installed' error during installation, please uninstall the previous version before installing this update.
Thank you for your continued support. If you encounter any issues, please report them through the usual channels.
<b>Support the Project</b>
If you'd like to support ongoing development, you can do so through any of the following:
• Buy Me a Coffee: https://buymeacoffee.com/iad1tya
• GitHub Sponsors: https://github.com/sponsors/iad1tya
• Support Page: https://support.iad1tya.cyou/
Every contribution helps support continued development, maintenance, and future improvements.
Thank you for your support, and enjoy the update!"
fi
# Create JSON payload securely using jq
jq -n \
--arg chat_id "$TELEGRAM_CHAT_ID" \
--arg text "$MESSAGE" \
--arg parse_mode "HTML" \
'{
chat_id: $chat_id,
text: $text,
parse_mode: $parse_mode,
disable_web_page_preview: true
}' > telegram-payload.json
# Send message using Telegram Bot API
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d @telegram-payload.json
- name: Send Discord Release Notification
if: startsWith(github.ref, 'refs/tags/v')
env:
DISCORD_RELEASE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_WEBHOOK || secrets.DISCORD_WEBHOOK }}
RELEASE_TITLE: ${{ env.RELEASE_TITLE }}
run: |
# Read release body
BODY=$(cat release-body.md)
# Construct ping text
PING_TEXT="@everyone New Release Available - **$RELEASE_TITLE**"
# Create Discord Embed JSON securely using jq
jq -n \
--arg ping "$PING_TEXT" \
--arg desc "$BODY" \
'{
content: $ping,
embeds: [{
title: "Release Changelog",
description: $desc,
color: 16738660,
footer: { text: "Echo Music Automation System" }
}]
}' > discord-release-payload.json
# Post to Discord Webhook if configured
if [ -n "$DISCORD_RELEASE_WEBHOOK" ]; then
curl -H "Content-Type: application/json" -d @discord-release-payload.json "$DISCORD_RELEASE_WEBHOOK"
else
echo "DISCORD_RELEASE_WEBHOOK is not set, skipping notification."
fi
- name: Send Discord Notification
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && !startsWith(github.ref, 'refs/tags/')
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
RELEASE_TITLE: ${{ env.RELEASE_TITLE }}
run: |
# Read release body
BODY=$(cat release-body.md)
# Fetch version name
VERSION_NAME=$(grep "versionName =" app/build.gradle.kts | head -n 1 | awk -F '"' '{print $2}')
# Set title and download link parameters
TARGET_TITLE="New Beta Build - v$VERSION_NAME"
DOWNLOAD_LINK="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
LINK_LABEL="Click here to download APK ZIP from GitHub Actions Run Page"
# Construct pings and warning messages
PING_TEXT="<@&1498758915536584714> New Build Available"
WARNING_TEXT="Note: If you're getting an update notification, there's no need to update since you're already using the latest version. Simply disable Automatic Update Check and Update Notifications in the update settings."
# Create Discord Embed JSON securely using jq
jq -n \
--arg ping "$PING_TEXT" \
--arg warn "$WARNING_TEXT" \
--arg title "$TARGET_TITLE" \
--arg desc "$BODY" \
--arg link "$DOWNLOAD_LINK" \
--arg label "$LINK_LABEL" \
'{
content: $ping,
embeds: [{
title: $title,
description: ($desc + "\n\n" + $warn),
color: 7303122,
fields: [
{ name: "Download APK", value: ("[" + $label + "](" + $link + ")"), inline: false }
],
footer: { text: "Echo Music Automation System" }
}]
}' > discord-payload.json
# Post to Discord Webhook
curl -H "Content-Type: application/json" -d @discord-payload.json "$DISCORD_WEBHOOK"