diff --git a/.github/workflows/.gitkeep b/.github/workflows/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..04552d7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: Build + +on: + push: + branches: [main, khesir/dev] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-android: + name: Build Android + runs-on: ubuntu-latest + environment: production + steps: + - 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.4' + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Build APK + run: | + flutter build apk --release \ + --dart-define="PROD=true" \ + --dart-define="SUPABASE_URL=${{ secrets.SUPABASE_URL }}" \ + --dart-define="SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" \ + --dart-define="GOOGLE_WEB_CLIENT_ID=${{ secrets.GOOGLE_WEB_CLIENT_ID }}" + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8f9027f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,102 @@ +name: Release + +on: + push: + tags: + - 'v*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-android: + name: Build Android + runs-on: ubuntu-latest + environment: production + steps: + - 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.4' + channel: 'stable' + cache: true + + - name: Get dependencies + run: flutter pub get + + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Build APK + run: | + flutter build apk --release \ + --dart-define="PROD=true" \ + --dart-define="SUPABASE_URL=${{ secrets.SUPABASE_URL }}" \ + --dart-define="SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" \ + --dart-define="GOOGLE_WEB_CLIENT_ID=${{ secrets.GOOGLE_WEB_CLIENT_ID }}" + + - name: Build App Bundle + run: | + flutter build appbundle --release \ + --dart-define="PROD=true" \ + --dart-define="SUPABASE_URL=${{ secrets.SUPABASE_URL }}" \ + --dart-define="SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" \ + --dart-define="GOOGLE_WEB_CLIENT_ID=${{ secrets.GOOGLE_WEB_CLIENT_ID }}" + + - name: Rename artifacts + run: | + mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/KeepTrack-${{ steps.version.outputs.VERSION }}.apk + mv build/app/outputs/bundle/release/app-release.aab build/app/outputs/bundle/release/KeepTrack-${{ steps.version.outputs.VERSION }}.aab + + - name: Upload APK artifact + uses: actions/upload-artifact@v4 + with: + name: android-apk + path: build/app/outputs/flutter-apk/KeepTrack-${{ steps.version.outputs.VERSION }}.apk + + - name: Upload AAB artifact + uses: actions/upload-artifact@v4 + with: + name: android-aab + path: build/app/outputs/bundle/release/KeepTrack-${{ steps.version.outputs.VERSION }}.aab + + create-release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: [build-android] + permissions: + contents: write + steps: + - name: Extract version from tag + id: version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Display downloaded files + run: ls -R artifacts + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + name: Keep Track v${{ steps.version.outputs.VERSION }} + draft: true + generate_release_notes: true + files: | + artifacts/android-apk/*.apk + artifacts/android-aab/*.aab + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 4848f9f..c878bb7 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -11,6 +11,7 @@ android { ndkVersion = flutter.ndkVersion compileOptions { + isCoreLibraryDesugaringEnabled = true sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } @@ -42,3 +43,7 @@ android { flutter { source = "../.." } + +dependencies { + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index afd79b7..f5b0b31 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -3,6 +3,12 @@ + + + + + + + + + + + + + + + + + + +