mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-27 15:18:50 +05:00
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!
264 lines
8.8 KiB
YAML
264 lines
8.8 KiB
YAML
stages:
|
|
- test
|
|
- build
|
|
- deploy
|
|
|
|
variables:
|
|
FLUTTER_VERSION: "stable"
|
|
# Optimize for RAM usage
|
|
FLUTTER_BUILD_FLAGS: "--split-debug-info=./debug-symbols --obfuscate --dart-define=dart.vm.profile=false"
|
|
PUB_CACHE: "${CI_PROJECT_DIR}/.pub-cache"
|
|
|
|
cache:
|
|
paths:
|
|
- .pub-cache/
|
|
|
|
# Test stage - runs first to catch issues early
|
|
test:dart:
|
|
stage: test
|
|
image: ghcr.io/cirruslabs/flutter:${FLUTTER_VERSION}
|
|
script:
|
|
- flutter --version
|
|
- flutter pub get
|
|
- flutter analyze --fatal-warnings
|
|
- flutter test --coverage
|
|
- flutter build web --release --dart-define=dart.vm.profile=false
|
|
artifacts:
|
|
reports:
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage/cobertura.xml
|
|
paths:
|
|
- coverage/
|
|
- build/web/
|
|
expire_in: 7 days
|
|
rules:
|
|
- if: $CI_MERGE_REQUEST_IID
|
|
- if: $CI_COMMIT_BRANCH
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
build:apk:arm64:
|
|
stage: build
|
|
image: ghcr.io/cirruslabs/flutter:${FLUTTER_VERSION}
|
|
script:
|
|
- flutter pub get
|
|
- mkdir -p debug-symbols
|
|
- flutter build apk --release --target-platform android-arm64 --split-per-abi ${FLUTTER_BUILD_FLAGS}
|
|
artifacts:
|
|
paths:
|
|
- build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
|
|
expire_in: 30 days
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: always
|
|
- if: $CI_COMMIT_BRANCH =~ /^dev|main/
|
|
when: on_success
|
|
|
|
build:apk:arm:
|
|
stage: build
|
|
image: ghcr.io/cirruslabs/flutter:${FLUTTER_VERSION}
|
|
before_script:
|
|
# Update version from tag if present
|
|
- |
|
|
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
VERSION_NAME="${CI_COMMIT_TAG#v}"
|
|
BUILD_NUMBER=$(echo $CI_COMMIT_TAG | sed 's/[^0-9]//g')
|
|
echo "Updating version to $VERSION_NAME+$BUILD_NUMBER"
|
|
sed -i "s/^version: .*/version: $VERSION_NAME+$BUILD_NUMBER/" pubspec.yaml
|
|
fi
|
|
script:
|
|
- flutter pub get
|
|
- mkdir -p debug-symbols
|
|
- flutter build apk --release --target-platform android-arm --split-per-abi ${FLUTTER_BUILD_FLAGS}
|
|
artifacts:
|
|
paths:
|
|
- build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
|
|
expire_in: 30 days
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: always
|
|
- if: $CI_COMMIT_BRANCH =~ /^dev|main/
|
|
when: on_success
|
|
|
|
build:apk:x64:
|
|
stage: build
|
|
image: ghcr.io/cirruslabs/flutter:${FLUTTER_VERSION}
|
|
script:
|
|
- flutter pub get
|
|
- mkdir -p debug-symbols
|
|
- flutter build apk --release --target-platform android-x64 --split-per-abi ${FLUTTER_BUILD_FLAGS}
|
|
artifacts:
|
|
paths:
|
|
- build/app/outputs/flutter-apk/app-x86_64-release.apk
|
|
expire_in: 30 days
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: always
|
|
- if: $CI_COMMIT_BRANCH =~ /^dev|main/
|
|
when: on_success
|
|
|
|
deploy:release:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
needs:
|
|
- build:apk:arm64
|
|
- build:apk:arm
|
|
- build:apk:x64
|
|
before_script:
|
|
- apk add --no-cache curl jq coreutils
|
|
script:
|
|
- |
|
|
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
VERSION="$CI_COMMIT_TAG"
|
|
else
|
|
VERSION="v0.0.${CI_PIPELINE_ID}"
|
|
fi
|
|
|
|
echo "Creating GitLab Release: $VERSION"
|
|
echo "Commit: ${CI_COMMIT_SHORT_SHA}"
|
|
echo "Branch: ${CI_COMMIT_BRANCH}"
|
|
|
|
APK_ARM64="build/app/outputs/flutter-apk/app-arm64-v8a-release.apk"
|
|
APK_ARM32="build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk"
|
|
APK_X86="build/app/outputs/flutter-apk/app-x86_64-release.apk"
|
|
|
|
RELEASE_DESCRIPTION="## NeoMovies Mobile ${VERSION}
|
|
|
|
**Build Info:**
|
|
- Commit: \`${CI_COMMIT_SHORT_SHA}\`
|
|
- Branch: \`${CI_COMMIT_BRANCH}\`
|
|
- Pipeline: [#${CI_PIPELINE_ID}](${CI_PIPELINE_URL})
|
|
|
|
**Downloads:**"
|
|
|
|
FILE_COUNT=0
|
|
|
|
if [ -f "$APK_ARM64" ]; then
|
|
FILE_COUNT=$((FILE_COUNT+1))
|
|
SIZE_ARM64=$(du -h "$APK_ARM64" | cut -f1)
|
|
RELEASE_DESCRIPTION="${RELEASE_DESCRIPTION}\n- ARM64 (arm64-v8a): \`app-arm64-v8a-release.apk\` (${SIZE_ARM64}) - Recommended for modern devices"
|
|
fi
|
|
|
|
if [ -f "$APK_ARM32" ]; then
|
|
FILE_COUNT=$((FILE_COUNT+1))
|
|
SIZE_ARM32=$(du -h "$APK_ARM32" | cut -f1)
|
|
RELEASE_DESCRIPTION="${RELEASE_DESCRIPTION}\n- ARM32 (armeabi-v7a): \`app-armeabi-v7a-release.apk\` (${SIZE_ARM32}) - For older devices"
|
|
fi
|
|
|
|
if [ -f "$APK_X86" ]; then
|
|
FILE_COUNT=$((FILE_COUNT+1))
|
|
SIZE_X86=$(du -h "$APK_X86" | cut -f1)
|
|
RELEASE_DESCRIPTION="${RELEASE_DESCRIPTION}\n- x86_64: \`app-x86_64-release.apk\` (${SIZE_X86}) - For emulators"
|
|
fi
|
|
|
|
if [ $FILE_COUNT -eq 0 ]; then
|
|
echo "No release artifacts found!"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Found $FILE_COUNT artifact(s) to release"
|
|
|
|
RELEASE_DATA=$(jq -n \
|
|
--arg name "NeoMovies ${VERSION}" \
|
|
--arg tag "${VERSION}" \
|
|
--arg desc "$RELEASE_DESCRIPTION" \
|
|
--arg ref "${CI_COMMIT_SHA}" \
|
|
'{name: $name, tag_name: $tag, description: $desc, ref: $ref}')
|
|
|
|
echo "Creating release via GitLab API..."
|
|
|
|
curl --fail-with-body -s -X POST \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases" \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$RELEASE_DATA" || \
|
|
curl -s -X PUT \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases/${VERSION}" \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$RELEASE_DATA"
|
|
|
|
echo ""
|
|
echo "Uploading APK files to Package Registry..."
|
|
|
|
if [ -f "$APK_ARM64" ]; then
|
|
echo "Uploading app-arm64-v8a-release.apk..."
|
|
curl --fail -s --request PUT \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "$APK_ARM64" \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/neomovies/${VERSION}/app-arm64-v8a-release.apk"
|
|
|
|
LINK_DATA=$(jq -n \
|
|
--arg name "app-arm64-v8a-release.apk" \
|
|
--arg url "${CI_PROJECT_URL}/-/package_files/${CI_PROJECT_ID}/packages/generic/neomovies/${VERSION}/app-arm64-v8a-release.apk" \
|
|
--arg type "package" \
|
|
'{name: $name, url: $url, link_type: $type}')
|
|
|
|
curl -s --request POST \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$LINK_DATA" \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases/${VERSION}/assets/links"
|
|
|
|
echo "ARM64 APK uploaded"
|
|
fi
|
|
|
|
if [ -f "$APK_ARM32" ]; then
|
|
echo "Uploading app-armeabi-v7a-release.apk..."
|
|
curl --fail -s --request PUT \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "$APK_ARM32" \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/neomovies/${VERSION}/app-armeabi-v7a-release.apk"
|
|
|
|
LINK_DATA=$(jq -n \
|
|
--arg name "app-armeabi-v7a-release.apk" \
|
|
--arg url "${CI_PROJECT_URL}/-/package_files/${CI_PROJECT_ID}/packages/generic/neomovies/${VERSION}/app-armeabi-v7a-release.apk" \
|
|
--arg type "package" \
|
|
'{name: $name, url: $url, link_type: $type}')
|
|
|
|
curl -s --request POST \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$LINK_DATA" \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases/${VERSION}/assets/links"
|
|
|
|
echo "ARM32 APK uploaded"
|
|
fi
|
|
|
|
if [ -f "$APK_X86" ]; then
|
|
echo "Uploading app-x86_64-release.apk..."
|
|
curl --fail -s --request PUT \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--upload-file "$APK_X86" \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/neomovies/${VERSION}/app-x86_64-release.apk"
|
|
|
|
LINK_DATA=$(jq -n \
|
|
--arg name "app-x86_64-release.apk" \
|
|
--arg url "${CI_PROJECT_URL}/-/package_files/${CI_PROJECT_ID}/packages/generic/neomovies/${VERSION}/app-x86_64-release.apk" \
|
|
--arg type "package" \
|
|
'{name: $name, url: $url, link_type: $type}')
|
|
|
|
curl -s --request POST \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$LINK_DATA" \
|
|
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases/${VERSION}/assets/links"
|
|
|
|
echo "x86_64 APK uploaded"
|
|
fi
|
|
|
|
echo ""
|
|
echo "================================================"
|
|
echo "Release created successfully!"
|
|
echo "View release: ${CI_PROJECT_URL}/-/releases/${VERSION}"
|
|
echo "Pipeline artifacts: ${CI_JOB_URL}/artifacts/browse"
|
|
echo "================================================"
|
|
artifacts:
|
|
paths:
|
|
- build/app/outputs/flutter-apk/*.apk
|
|
expire_in: 90 days
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: always
|
|
- if: $CI_COMMIT_BRANCH =~ /^dev|main/
|
|
when: on_success |