Skip to content

Commit b51fdd9

Browse files
authored
ci: upload mapping artifacts and improve Telegram notifications (#1343)
- Update Python script to handle two APK uploads via sendMediaGroup * Add Release1 (release APK) and Release2 (debug APK) media attachments * Move caption to second document for better visibility - Fix Telegram workflow to match field names with script * Use -F "Release1=@$RELEASE_APK" -F "Release2=@$DEBUG_APK" * Upload both variants in single request instead of separate calls - Add ProGuard mapping file upload for crash deobfuscation - Merge artifacts into single APatch package containing both variants This enables simultaneous delivery of both build variants, improving testing workflows. Signed-off-by: Prslc <[email protected]>
1 parent 2e67027 commit b51fdd9

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed

.github/scripts/telegram_url.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import urllib.parse
55

6-
76
url = f'https://api.telegram.org/bot{os.environ["BOT_TOKEN"]}'
87
url += f'/sendMediaGroup?chat_id={urllib.parse.quote(sys.argv[1])}&media='
98

@@ -17,8 +16,9 @@
1716
caption = f"[{commit_id}]({commit_url})\n{msg}"[:1024]
1817

1918
data = json.dumps([
20-
{"type": "document", "media": "attach://Release","caption": caption,"parse_mode":"MarkdownV2"}
21-
])
19+
{"type": "document", "media": "attach://Release1"},
20+
{"type": "document", "media": "attach://Release2", "caption": caption, "parse_mode": "MarkdownV2"}
21+
])
2222

2323
url += urllib.parse.quote(data)
2424
print(url)

.github/workflows/build.yml

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -109,53 +109,41 @@ jobs:
109109
keyPassword: ${{ secrets.KEY_PASSWORD }}
110110
zipAlign: true
111111

112-
113-
114-
- name: Upload release build artifact
115-
env:
116-
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
117-
if: ${{ env.SIGNING_KEY != '' }}
118-
uses: actions/upload-artifact@v6
112+
- name: Upload mappings
113+
uses: actions/upload-artifact@v5
119114
with:
120-
name: APatch_Release
121-
path: ${{steps.sign_app.outputs.signedReleaseFile}}
115+
name: "mappings"
116+
path: "app/build/outputs/mapping/release/"
122117

123-
- name: Upload debug build artifact
118+
- name: Upload build artifact
124119
env:
125120
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
126121
if: ${{ env.SIGNING_KEY != '' }}
127122
uses: actions/upload-artifact@v6
128123
with:
129-
name: APatch_Debug
130-
path: ${{steps.sign_debug_app.outputs.signedReleaseFile}}
124+
name: APatch
125+
path: |
126+
${{ steps.sign_app.outputs.signedReleaseFile }}
127+
${{ steps.sign_debug_app.outputs.signedReleaseFile }}
131128
132129
- name: Post to channel
133-
if: ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag'}}
130+
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' }}
134131
env:
135132
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
136133
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
137134
COMMIT_URL: ${{ github.event.head_commit.url }}
138135
COMMIT_ID: ${{ github.event.head_commit.id }}
139136
run: |
140-
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
141-
OUTPUT_DIRS=(
142-
"app/build/outputs/apk/release"
143-
"app/build/outputs/apk/debug"
144-
)
145-
for OUTPUT_DIR in "${OUTPUT_DIRS[@]}"; do
146-
if [ -d "$OUTPUT_DIR" ]; then
147-
# 查找APK文件
148-
APK_FILE=$(find "$OUTPUT_DIR" -name "*.apk" | head -n 1)
149-
150-
if [ ! -z "$APK_FILE" ] && [ -f "$APK_FILE" ]; then
151-
echo "Found APK: $APK_FILE"
152-
153-
for GROUP_ID in "-1002058433411" "-1001910818234"; do
154-
URL=$(python3 .github/scripts/telegram_url.py $GROUP_ID)
155-
curl -v "$URL" -F Release=@"$APK_FILE"
156-
done
157-
fi
158-
fi
137+
if [ -n "${BOT_TOKEN}" ]; then
138+
CHANNELS=(-1002058433411 -1001910818234)
139+
RELEASE_APK="${{ steps.sign_app.outputs.signedReleaseFile }}"
140+
DEBUG_APK="${{ steps.sign_debug_app.outputs.signedReleaseFile }}"
141+
142+
for CHANNEL in "${CHANNELS[@]}"; do
143+
URL=$(python3 .github/scripts/telegram_url.py $CHANNEL)
144+
if [ -f "$RELEASE_APK" ] && [ -f "$DEBUG_APK" ]; then
145+
curl -v "$URL" -F "Release1=@$RELEASE_APK" -F "Release2=@$DEBUG_APK"
146+
fi
159147
done
160148
fi
161149

0 commit comments

Comments
 (0)