Files
FridaBox/.github/workflows/build_and_telegram.yml
T

168 lines
7.4 KiB
YAML

name: Build and Send APK to Telegram
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-send:
runs-on: ubuntu-latest
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Accept Android SDK licenses
run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses || yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses || true
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build APKs and AARs
run: ./gradlew assembleDebug assembleRelease :Bcore:assembleDebug :Bcore:assembleRelease :black-reflection:assemble :compiler:assemble
- name: Find Bcore AAR paths
id: aar_paths
run: |
DEBUG_AAR=$(find ./Bcore/build/outputs/aar -name "*debug.aar" | head -n 1)
RELEASE_AAR=$(find ./Bcore/build/outputs/aar -name "*release.aar" | head -n 1)
echo "debug_aar_path=$DEBUG_AAR" >> $GITHUB_OUTPUT
echo "release_aar_path=$RELEASE_AAR" >> $GITHUB_OUTPUT
- name: Find black-reflection and compiler artifact paths
id: additional_artifacts
run: |
BLACK_REFLECTION_ART=$(find ./black-reflection/build/libs ./black-reflection/build/outputs -name "*.jar" -o -name "*.aar" 2>/dev/null | head -n 1)
COMPILER_ART=$(find ./compiler/build/libs ./compiler/build/outputs -name "*.jar" -o -name "*.aar" 2>/dev/null | head -n 1)
echo "black_reflection_path=$BLACK_REFLECTION_ART" >> $GITHUB_OUTPUT
echo "compiler_path=$COMPILER_ART" >> $GITHUB_OUTPUT
- name: Send Bcore Debug AAR to Telegram and Pin
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
AAR_PATH="${{ steps.aar_paths.outputs.debug_aar_path }}"
if [ -n "$AAR_PATH" ] && [ -f "$AAR_PATH" ]; then
RESPONSE=$(curl -s -F document=@"$AAR_PATH" \
-F chat_id="$TELEGRAM_CHAT_ID" \
-F caption="[Bcore DEBUG AAR] $COMMIT_MSG" \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument)
MESSAGE_ID=$(echo $RESPONSE | jq '.result.message_id')
if [ "$MESSAGE_ID" != "null" ] && [ -n "$MESSAGE_ID" ]; then
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/pinChatMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d message_id="$MESSAGE_ID"
fi
else
echo "Debug AAR not found at $AAR_PATH"
fi
- name: Send Bcore Release AAR to Telegram and Pin
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
AAR_PATH="${{ steps.aar_paths.outputs.release_aar_path }}"
if [ -n "$AAR_PATH" ] && [ -f "$AAR_PATH" ]; then
RESPONSE=$(curl -s -F document=@"$AAR_PATH" \
-F chat_id="$TELEGRAM_CHAT_ID" \
-F caption="[Bcore RELEASE AAR] $COMMIT_MSG" \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument)
MESSAGE_ID=$(echo $RESPONSE | jq '.result.message_id')
if [ "$MESSAGE_ID" != "null" ] && [ -n "$MESSAGE_ID" ]; then
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/pinChatMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d message_id="$MESSAGE_ID"
fi
else
echo "Release AAR not found at $AAR_PATH"
fi
- name: Send black-reflection Artifact to Telegram and Pin
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
ART_PATH="${{ steps.additional_artifacts.outputs.black_reflection_path }}"
if [ -n "$ART_PATH" ] && [ -f "$ART_PATH" ]; then
FILENAME=$(basename "$ART_PATH")
RESPONSE=$(curl -s -F document=@"$ART_PATH" \
-F chat_id="$TELEGRAM_CHAT_ID" \
-F caption="[black-reflection] $FILENAME - $COMMIT_MSG" \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument)
MESSAGE_ID=$(echo $RESPONSE | jq '.result.message_id')
if [ "$MESSAGE_ID" != "null" ] && [ -n "$MESSAGE_ID" ]; then
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/pinChatMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d message_id="$MESSAGE_ID"
fi
else
echo "black-reflection artifact not found at $ART_PATH"
fi
- name: Send compiler Artifact to Telegram and Pin
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
ART_PATH="${{ steps.additional_artifacts.outputs.compiler_path }}"
if [ -n "$ART_PATH" ] && [ -f "$ART_PATH" ]; then
FILENAME=$(basename "$ART_PATH")
RESPONSE=$(curl -s -F document=@"$ART_PATH" \
-F chat_id="$TELEGRAM_CHAT_ID" \
-F caption="[compiler] $FILENAME - $COMMIT_MSG" \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument)
MESSAGE_ID=$(echo $RESPONSE | jq '.result.message_id')
if [ "$MESSAGE_ID" != "null" ] && [ -n "$MESSAGE_ID" ]; then
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/pinChatMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d message_id="$MESSAGE_ID"
fi
else
echo "compiler artifact not found at $ART_PATH"
fi
- name: Send ALL Debug APKs to Telegram and Pin
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
for APK in ./app/build/outputs/apk/debug/*.apk; do
if [ -f "$APK" ]; then
RESPONSE=$(curl -s -F document=@"$APK" \
-F chat_id="$TELEGRAM_CHAT_ID" \
-F caption="[DEBUG] $(basename $APK) $COMMIT_MSG" \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument)
MESSAGE_ID=$(echo $RESPONSE | jq '.result.message_id')
if [ "$MESSAGE_ID" != "null" ] && [ -n "$MESSAGE_ID" ]; then
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/pinChatMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d message_id="$MESSAGE_ID"
fi
fi
done
- name: Send ALL Release APKs to Telegram and Pin
run: |
COMMIT_MSG=$(git log -1 --pretty=%s)
for APK in ./app/build/outputs/apk/release/*.apk; do
if [ -f "$APK" ]; then
RESPONSE=$(curl -s -F document=@"$APK" \
-F chat_id="$TELEGRAM_CHAT_ID" \
-F caption="[RELEASE] $(basename $APK) $COMMIT_MSG" \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument)
MESSAGE_ID=$(echo $RESPONSE | jq '.result.message_id')
if [ "$MESSAGE_ID" != "null" ] && [ -n "$MESSAGE_ID" ]; then
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/pinChatMessage" \
-d chat_id="$TELEGRAM_CHAT_ID" \
-d message_id="$MESSAGE_ID"
fi
fi
done