name: build
on:
  push:
    branches: ["main"]
jobs:
  android:
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v4
      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: stable
          flutter-version: 3.29.3
      - run: flutter pub get
      - run: flutter build appbundle
        env:
          KEYSTORE: ${{ secrets.KEYSTORE }}
          KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
          KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
          KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
          KEYSTORE_SHA256: ${{ secrets.KEYSTORE_SHA256 }}
      - run: flutter build apk --split-per-abi
        env:
          KEYSTORE: ${{ secrets.KEYSTORE }}
          KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
          KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
          KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
          KEYSTORE_SHA256: ${{ secrets.KEYSTORE_SHA256 }}
      - uses: actions/upload-artifact@v4
        with:
          name: "release.aab"
          path: "build/app/outputs/bundle/release/app-release.aab"
      - uses: actions/upload-artifact@v4
        with:
          name: "app-arm64-v8a-release.apk"
          path: "build/app/outputs/flutter-apk/app-arm64-v8a-release.apk"
      - uses: actions/upload-artifact@v4
        with:
          name: "app-armeabi-v7a-release.apk"
          path: "build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk"
      - uses: actions/upload-artifact@v4
        with:
          name: "app-x86_64-release.apk"
          path: "build/app/outputs/flutter-apk/app-x86_64-release.apk"
  ios:
    runs-on: macos-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v4
      - name: Set up Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: stable
      - run: flutter pub get
      - run: flutter build ios --no-codesign