Files
neomovies-mobile/.github/workflows/release.yml
factory-droid[bot] fa88fd20c8 Add Telegram bot integration for release notifications
ADDED FUNCTIONALITY:
- Telegram Bot API integration for publishing releases to channel
- Automatic APK file uploads (ARM64, ARM32, x86_64) to Telegram
- Rich formatted messages with release info (version, commit, branch, files sizes)
- Same message format as GitHub releases with Markdown formatting

INTEGRATION DETAILS:
- Bot Token: 8376391003:AAHhDrAkGDQbxK7DAvtFfoXyp3cv9sGdkwg
- Channel ID: -1003117144167 (3117144167)
- Uploads all 3 APK variants with descriptions
- Sends release info message with download links

WORKFLOW:
- Runs after successful GitHub release creation
- Uses curl for Telegram Bot API calls
- Includes error handling and progress logging
- Updates GitHub Actions summary with Telegram status

This enables automated release distribution through both GitHub and Telegram channels.
2025-10-03 15:03:07 +00:00

281 lines
9.9 KiB
YAML

name: Build and Release
on:
push:
branches:
- main
- dev
tags:
- 'v*'
pull_request:
branches:
- main
- dev
jobs:
build-arm64:
name: Build APK (ARM64)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.5'
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Build ARM64 APK
run: flutter build apk --release --target-platform android-arm64 --split-per-abi
- name: Upload ARM64 APK
uses: actions/upload-artifact@v4
with:
name: apk-arm64
path: build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
retention-days: 30
build-arm32:
name: Build APK (ARM32)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.5'
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Build ARM32 APK
run: flutter build apk --release --target-platform android-arm --split-per-abi
- name: Upload ARM32 APK
uses: actions/upload-artifact@v4
with:
name: apk-arm32
path: build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
retention-days: 30
build-x64:
name: Build APK (x86_64)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.5'
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Build x86_64 APK
run: flutter build apk --release --target-platform android-x64 --split-per-abi
- name: Upload x86_64 APK
uses: actions/upload-artifact@v4
with:
name: apk-x64
path: build/app/outputs/flutter-apk/app-x86_64-release.apk
retention-days: 30
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-arm64, build-arm32, build-x64]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download ARM64 APK
uses: actions/download-artifact@v4
with:
name: apk-arm64
path: ./apks
- name: Download ARM32 APK
uses: actions/download-artifact@v4
with:
name: apk-arm32
path: ./apks
- name: Download x86_64 APK
uses: actions/download-artifact@v4
with:
name: apk-x64
path: ./apks
- name: Generate version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="v0.0.${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Get file sizes
id: sizes
run: |
ARM64_SIZE=$(du -h ./apks/app-arm64-v8a-release.apk | cut -f1)
ARM32_SIZE=$(du -h ./apks/app-armeabi-v7a-release.apk | cut -f1)
X64_SIZE=$(du -h ./apks/app-x86_64-release.apk | cut -f1)
echo "arm64_size=$ARM64_SIZE" >> $GITHUB_OUTPUT
echo "arm32_size=$ARM32_SIZE" >> $GITHUB_OUTPUT
echo "x64_size=$X64_SIZE" >> $GITHUB_OUTPUT
- name: Create Release Notes
id: notes
run: |
cat << EOF > release_notes.md
## NeoMovies Mobile ${{ steps.version.outputs.version }}
**Build Info:**
- Commit: \`${{ github.sha }}\`
- Branch: \`${{ github.ref_name }}\`
- Workflow Run: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
**Downloads:**
- **ARM64 (arm64-v8a)**: \`app-arm64-v8a-release.apk\` (${{ steps.sizes.outputs.arm64_size }}) - Recommended for modern devices
- **ARM32 (armeabi-v7a)**: \`app-armeabi-v7a-release.apk\` (${{ steps.sizes.outputs.arm32_size }}) - For older devices
- **x86_64**: \`app-x86_64-release.apk\` (${{ steps.sizes.outputs.x64_size }}) - For emulators
### What's Changed
See the [full commit history](${{ github.server_url }}/${{ github.repository }}/compare/${{ github.event.before }}...${{ github.sha }})
EOF
- name: Delete previous release if exists
run: |
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.version.outputs.version }}" \
| jq -r '.id // empty')
if [ ! -z "$RELEASE_ID" ]; then
echo "Deleting previous release $RELEASE_ID"
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: NeoMovies ${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}
make_latest: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
files: |
./apks/app-arm64-v8a-release.apk
./apks/app-armeabi-v7a-release.apk
./apks/app-x86_64-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Telegram
run: |
# Prepare Telegram message
VERSION="${{ steps.version.outputs.version }}"
COMMIT_SHA="${{ github.sha }}"
BRANCH="${{ github.ref_name }}"
RUN_NUMBER="${{ github.run_number }}"
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
# Create message text
MESSAGE="🚀 *NeoMovies Mobile ${VERSION}*
📋 *Build Info:*
• Commit: \`${COMMIT_SHA:0:7}\`
• Branch: \`${BRANCH}\`
• Workflow Run: [#${RUN_NUMBER}](${REPO_URL}/actions/runs/${{ github.run_id }})
📦 *Downloads:*
• *ARM64 (arm64-v8a)*: ${{ steps.sizes.outputs.arm64_size }} - Recommended for modern devices
• *ARM32 (armeabi-v7a)*: ${{ steps.sizes.outputs.arm32_size }} - For older devices
• *x86_64*: ${{ steps.sizes.outputs.x64_size }} - For emulators
🔗 [View Release](${REPO_URL}/releases/tag/${VERSION})"
# Send message to Telegram
curl -s -X POST "https://api.telegram.org/bot8376391003:AAHhDrAkGDQbxK7DAvtFfoXyp3cv9sGdkwg/sendMessage" \
-H "Content-Type: application/json" \
-d "{
\"chat_id\": \"-1003117144167\",
\"text\": \"$MESSAGE\",
\"parse_mode\": \"Markdown\",
\"disable_web_page_preview\": true
}"
# Send APK files
echo "Uploading ARM64 APK to Telegram..."
curl -s -X POST "https://api.telegram.org/bot8376391003:AAHhDrAkGDQbxK7DAvtFfoXyp3cv9sGdkwg/sendDocument" \
-F "chat_id=-1003117144167" \
-F "document=@./apks/app-arm64-v8a-release.apk" \
-F "caption=📱 NeoMovies ${VERSION} - ARM64 (Recommended)"
echo "Uploading ARM32 APK to Telegram..."
curl -s -X POST "https://api.telegram.org/bot8376391003:AAHhDrAkGDQbxK7DAvtFfoXyp3cv9sGdkwg/sendDocument" \
-F "chat_id=-1003117144167" \
-F "document=@./apks/app-armeabi-v7a-release.apk" \
-F "caption=📱 NeoMovies ${VERSION} - ARM32 (For older devices)"
echo "Uploading x86_64 APK to Telegram..."
curl -s -X POST "https://api.telegram.org/bot8376391003:AAHhDrAkGDQbxK7DAvtFfoXyp3cv9sGdkwg/sendDocument" \
-F "chat_id=-1003117144167" \
-F "document=@./apks/app-x86_64-release.apk" \
-F "caption=📱 NeoMovies ${VERSION} - x86_64 (For emulators)"
echo "Telegram notification sent successfully!"
- name: Summary
run: |
echo "## Release Created Successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "**Release URL:** ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "**Telegram:** Published to channel" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### APK Files:" >> $GITHUB_STEP_SUMMARY
echo "- ARM64: ${{ steps.sizes.outputs.arm64_size }}" >> $GITHUB_STEP_SUMMARY
echo "- ARM32: ${{ steps.sizes.outputs.arm32_size }}" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: ${{ steps.sizes.outputs.x64_size }}" >> $GITHUB_STEP_SUMMARY