Files
neomovies-mobile/.github/workflows/release.yml
Cursor Agent 1e5451859f fix: resolve gray screens and add automatic versioning
1. Fix Downloads screen gray screen issue:
   - Add DownloadsProvider to main.dart providers list
   - Remove @RoutePage() decorator from DownloadsScreen
   - Downloads screen now displays torrent list correctly

2. Fix movie detail screen gray screen issue:
   - Improve Movie.fromJson() with better error handling
   - Safe parsing of genres field (handles both Map and String formats)
   - Add fallback 'Untitled' for movies without title
   - Add detailed logging in MovieDetailProvider
   - Better error messages with stack traces

3. Add automatic version update from CI/CD tags:
   - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build
   - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build
   - Version format: tag v0.0.18 becomes version 0.0.18+18
   - Applies to all build jobs (arm64, arm32, x64)

How versioning works:
- When you create tag v0.0.18, CI automatically updates pubspec.yaml
- Build uses version 0.0.18+18 (version+buildNumber)
- APK shows correct version in About screen and Google Play
- No manual pubspec.yaml updates needed

Example:
- Create tag: git tag v0.0.18 && git push origin v0.0.18
- CI reads tag, extracts '0.0.18'
- Updates: version: 0.0.18+18 in pubspec.yaml
- Builds APK with this version
- Release created with proper version number

Changes:
- lib/main.dart: Add DownloadsProvider
- lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage
- lib/data/models/movie.dart: Safe JSON parsing with error handling
- lib/presentation/providers/movie_detail_provider.dart: Add detailed logging
- .gitlab-ci.yml: Add version update script in all build jobs
- .github/workflows/release.yml: Add version update step in all build jobs

Result:
 Downloads screen displays properly
 Movie details screen loads correctly
 Automatic versioning from tags (0.0.18, 0.0.19, etc.)
 No more gray screens!
2025-10-05 16:28:47 +00:00

278 lines
9.7 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: Update version from tag
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION_NAME=${GITHUB_REF#refs/tags/v}
BUILD_NUMBER=$(echo $VERSION_NAME | sed 's/[^0-9]//g')
echo "Updating version to $VERSION_NAME+$BUILD_NUMBER"
sed -i "s/^version: .*/version: $VERSION_NAME+$BUILD_NUMBER/" pubspec.yaml
- 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
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/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-H "Content-Type: application/json" \
-d "{
\"chat_id\": \"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"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/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \
-F "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
-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/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \
-F "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
-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/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument" \
-F "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
-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