diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d7d56db..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,185 +0,0 @@ -name: Build NeoMovies Mobile - -on: - push: - branches: [ dev, feature/torrent-engine-integration ] - pull_request: - branches: [ dev ] - workflow_dispatch: - -env: - FLUTTER_VERSION: '3.35.5' - JAVA_VERSION: '17' - -jobs: - # ============================================ - # Сборка TorrentEngine модуля - # ============================================ - build-torrent-engine: - name: Build TorrentEngine Library - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '17' - cache: 'gradle' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: wrapper - - - name: Build TorrentEngine AAR - working-directory: android - run: | - ./gradlew :torrentengine:assembleRelease \ - --no-daemon \ - --parallel \ - --build-cache \ - -Dorg.gradle.jvmargs="-Xmx2g -XX:MaxMetaspaceSize=512m" - - - name: Upload TorrentEngine AAR - uses: actions/upload-artifact@v4 - with: - name: torrentengine-aar - path: android/torrentengine/build/outputs/aar/*.aar - retention-days: 7 - - # ============================================ - # Сборка Debug APK - # ============================================ - build-debug-apk: - name: Build Debug APK - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: ${{ env.FLUTTER_VERSION }} - channel: 'stable' - cache: true - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '17' - cache: 'gradle' - - - name: Flutter Doctor - run: flutter doctor -v - - - name: Get Flutter dependencies - run: flutter pub get - - - name: Build Debug APK - run: | - flutter build apk \ - --debug \ - --target-platform android-arm64 - - - name: Upload Debug APK - uses: actions/upload-artifact@v4 - with: - name: debug-apk - path: build/app/outputs/flutter-apk/app-debug.apk - retention-days: 7 - - # ============================================ - # Сборка Release APK - # ============================================ - build-release-apk: - name: Build Release APK - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/dev' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: ${{ env.FLUTTER_VERSION }} - channel: 'stable' - cache: true - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '17' - cache: 'gradle' - - - name: Get Flutter dependencies - run: flutter pub get - - - name: Build Release APK (split per ABI) - run: | - flutter build apk \ - --release \ - --split-per-abi \ - --target-platform android-arm64 - - - name: Upload Release APK (ARM64) - uses: actions/upload-artifact@v4 - with: - name: release-apk-arm64 - path: build/app/outputs/flutter-apk/app-arm64-v8a-release.apk - retention-days: 30 - - # ============================================ - # Анализ кода - # ============================================ - code-quality: - name: Code Quality Checks - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: ${{ env.FLUTTER_VERSION }} - channel: 'stable' - cache: true - - - name: Get Flutter dependencies - run: flutter pub get - - - name: Flutter Analyze - run: flutter analyze --no-fatal-infos - continue-on-error: true - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '17' - - - name: Android Lint - working-directory: android - run: ./gradlew lint --no-daemon - continue-on-error: true - - - name: Upload Lint Reports - uses: actions/upload-artifact@v4 - if: always() - with: - name: lint-reports - path: | - android/app/build/reports/lint-results*.html - android/torrentengine/build/reports/lint-results*.html - retention-days: 7 diff --git a/.github/workflows/flutter-ci.yml b/.github/workflows/flutter-ci.yml deleted file mode 100644 index 3a2e2d8..0000000 --- a/.github/workflows/flutter-ci.yml +++ /dev/null @@ -1,122 +0,0 @@ -# NeoMovies – GitHub Actions CI/CD for Flutter (Android APK + Linux desktop) -# Requires GitHub-hosted Ubuntu runners. - -name: Flutter CI - -on: - push: - branches: [ main ] - pull_request: - workflow_dispatch: - release: - types: [created] - -env: - FLUTTER_VERSION: "3.22.1" - -jobs: - # --------------------------------------------------------------------------- - test: - name: Test & Analyze - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter ${{ env.FLUTTER_VERSION }} (beta) - uses: subosito/flutter-action@v2 - with: - channel: beta - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Get dependencies - run: flutter pub get - - - name: Static analysis - run: flutter analyze --no-pub --fatal-infos --fatal-warnings - - - name: Run tests - run: flutter test --coverage - - - name: Upload coverage - uses: actions/upload-artifact@v4 - with: - name: coverage - path: coverage/ - - # --------------------------------------------------------------------------- - build_android: - name: Build Android APK - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: subosito/flutter-action@v2 - with: - channel: beta - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Get dependencies - run: flutter pub get - - - name: Build release APK & AAB - run: | - flutter build apk --release - flutter build appbundle --release - - - name: Upload APK & AAB artifacts - uses: actions/upload-artifact@v4 - with: - name: android-build - path: | - build/app/outputs/flutter-apk/app-release.apk - build/app/outputs/bundle/release/app-release.aab - - # --------------------------------------------------------------------------- - build_linux: - name: Build Linux desktop bundle - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: subosito/flutter-action@v2 - with: - channel: beta - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Install Linux build dependencies - run: sudo apt-get update && sudo apt-get install -y libjsoncpp-dev libsecret-1-dev clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - - - name: Enable Linux desktop and get deps - run: | - flutter config --enable-linux-desktop - flutter pub get - - - name: Build Linux release bundle - run: flutter build linux --release - - - name: Upload Linux bundle artifact - uses: actions/upload-artifact@v4 - with: - name: linux-build - path: build/linux/x64/release/bundle/ - - # --------------------------------------------------------------------------- - release_assets: - name: Attach assets to GitHub Release - if: github.event_name == 'release' - needs: [build_android, build_linux] - runs-on: ubuntu-latest - steps: - - name: Download build artifacts - uses: actions/download-artifact@v4 - - - name: Upload to GitHub Release - uses: softprops/action-gh-release@v1 - with: - files: | - android-build/app-release.apk - android-build/app-release.aab - linux-build/** diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2f55765 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,211 @@ +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.24.0' + 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.24.0' + 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.24.0' + 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: 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/') }} + 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: 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 "" >> $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 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2cb094e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,136 @@ +name: Test and Analyze + +on: + push: + branches: + - main + - dev + - 'feature/**' + pull_request: + branches: + - main + - dev + +jobs: + flutter-analyze: + name: Flutter Analyze + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.24.0' + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Run Flutter Analyze + run: flutter analyze + + - name: Check formatting + run: dart format --set-exit-if-changed . + + flutter-test: + name: Flutter Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.24.0' + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Run tests + run: flutter test --coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: ./coverage/lcov.info + fail_ci_if_error: false + if: always() + + android-lint: + name: Android Lint + 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.24.0' + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Run Android Lint + run: | + cd android + chmod +x gradlew + ./gradlew lint + + - name: Upload lint reports + uses: actions/upload-artifact@v4 + with: + name: android-lint-reports + path: | + android/app/build/reports/lint-*.html + android/torrentengine/build/reports/lint-*.html + retention-days: 7 + if: always() + + build-debug: + name: Build Debug APK + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/dev' + 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.24.0' + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Build Debug APK + run: flutter build apk --debug + + - name: Upload Debug APK + uses: actions/upload-artifact@v4 + with: + name: apk-debug + path: build/app/outputs/flutter-apk/app-debug.apk + retention-days: 7 \ No newline at end of file diff --git a/.github/workflows/torrent-engine.yml b/.github/workflows/torrent-engine.yml new file mode 100644 index 0000000..b55c747 --- /dev/null +++ b/.github/workflows/torrent-engine.yml @@ -0,0 +1,123 @@ +name: Build Torrent Engine + +on: + push: + branches: + - main + - dev + paths: + - 'android/torrentengine/**' + - '.github/workflows/torrent-engine.yml' + pull_request: + branches: + - main + - dev + paths: + - 'android/torrentengine/**' + +jobs: + build-torrent-engine: + name: Build Torrent Engine AAR + 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 Android SDK + uses: android-actions/setup-android@v3 + + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Create local.properties + run: | + echo "sdk.dir=$ANDROID_HOME" > android/local.properties + + - name: Build Torrent Engine + run: | + cd android + chmod +x gradlew + ./gradlew :torrentengine:assembleRelease --no-daemon --stacktrace + + - name: Get AAR info + id: aar_info + run: | + AAR_FILE=$(find android/torrentengine/build/outputs/aar -name "*.aar" | head -n 1) + AAR_SIZE=$(du -h "$AAR_FILE" | cut -f1) + AAR_NAME=$(basename "$AAR_FILE") + + echo "file=$AAR_FILE" >> $GITHUB_OUTPUT + echo "size=$AAR_SIZE" >> $GITHUB_OUTPUT + echo "name=$AAR_NAME" >> $GITHUB_OUTPUT + + - name: Upload Torrent Engine AAR + uses: actions/upload-artifact@v4 + with: + name: torrent-engine-aar + path: android/torrentengine/build/outputs/aar/*.aar + retention-days: 30 + + - name: Summary + run: | + echo "## Torrent Engine Built Successfully!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**AAR File:** \`${{ steps.aar_info.outputs.name }}\`" >> $GITHUB_STEP_SUMMARY + echo "**Size:** ${{ steps.aar_info.outputs.size }}" >> $GITHUB_STEP_SUMMARY + echo "**Path:** \`android/torrentengine/build/outputs/aar/\`" >> $GITHUB_STEP_SUMMARY + + test-torrent-engine: + name: Test Torrent Engine + 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 Android SDK + uses: android-actions/setup-android@v3 + + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Create local.properties + run: | + echo "sdk.dir=$ANDROID_HOME" > android/local.properties + + - name: Run Unit Tests + run: | + cd android + chmod +x gradlew + ./gradlew :torrentengine:test --no-daemon + + - name: Upload Test Results + uses: actions/upload-artifact@v4 + with: + name: torrent-engine-test-results + path: android/torrentengine/build/test-results/ + retention-days: 7 + if: always() \ No newline at end of file