diff --git a/.github/actions/setup-env.yaml b/.github/actions/setup-env.yaml deleted file mode 100644 index 9ea9077..0000000 --- a/.github/actions/setup-env.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: 🛠️ Setup Env - -on: - workflow_call: - inputs: - flutter_version: - required: false - type: string - default: "stable" - description: "Flutter version to use. Default is 'stable'." -jobs: - setup: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - channel: "${{ inputs.flutter_version }}" - flutter-version-file: pubspec.yaml - - name: Install dependencies - run: flutter pub get diff --git a/.github/workflows/flutter-setup.yaml b/.github/workflows/flutter-setup.yaml new file mode 100644 index 0000000..17bbaa4 --- /dev/null +++ b/.github/workflows/flutter-setup.yaml @@ -0,0 +1,49 @@ +name: 🛠️ Reusable Flutter Setup + +on: + workflow_call: + inputs: + flutter-channel: + description: "Flutter channel to use (stable, beta, dev, master)" + required: false + type: string + default: "stable" + java-version: + description: "Java version to set up" + required: false + type: string + default: "17" + +jobs: + setup: + name: Setup Flutter Environment + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: "temurin" + # Use the input value, fallback to default if not provided + java-version: ${{ inputs.java-version }} + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: ${{ inputs.flutter-channel }} + flutter-version-file: pubspec.yaml + cache: true # Cache Flutter SDK itself + - name: Cache Flutter dependencies + id: cache-pub # Give the step an ID to potentially reference its outputs later if needed + uses: actions/cache@v4 + with: + path: ${{ env.FLUTTER_HOME }}/.pub-cache + # Use a consistent key structure based on the lock file + key: ${{ runner.os }}-flutter-pub-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter-pub- + + - name: Get Flutter dependencies + run: flutter pub get diff --git a/.github/workflows/flutter_test.yaml b/.github/workflows/flutter_test.yaml index 13d3ee0..bcd661d 100644 --- a/.github/workflows/flutter_test.yaml +++ b/.github/workflows/flutter_test.yaml @@ -5,17 +5,23 @@ on: branches: - main pull_request: + branches: + - main # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: test: - runs-on: ubuntu-latest - steps: - - name: setup env - uses: ./.github/actions/setup-env.yaml + name: Test + uses: ./.github/workflows/flutter-setup.yaml + secrets: inherit + with: + flutter-channel: stable + java-version: 17 + + steps: # Debug: Echo current directory contents - name: List root directory contents run: | @@ -37,14 +43,21 @@ jobs: echo "\nSubmodule details:" git submodule foreach 'echo $path: && pwd && ls -la' - - name: Run flutter tests + - name: Run static analysis + run: flutter analyze + + - name: Run tests run: flutter test build_android: + name: Build Android APKs needs: test runs-on: ubuntu-latest steps: - - uses: ./.github/actions/setup-env.yaml + - uses: ./.github/workflows/flutter-setup.yaml + with: + flutter-channel: stable + java-version: 17 - name: Decode android/upload.jks run: echo "${{ secrets.UPLOAD_KEYSTORE_JKS }}" | base64 --decode > android/upload.jks @@ -52,18 +65,16 @@ jobs: - name: Decode android/key.properties run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > android/key.properties - - name: Set Up Java - uses: actions/setup-java@v3.12.0 - with: - distribution: "oracle" - java-version: "17" - - name: Build Universal APK run: flutter build apk --release - name: Rename Universal APK run: mv build/app/outputs/flutter-apk/{app-release,app-universal-release}.apk - + - name: Upload Android APK Artifact + uses: actions/upload-artifact@v4 + with: + name: release-apk + path: build/app/outputs/flutter-apk/*.apk build_linux: needs: test runs-on: ubuntu-latest @@ -75,14 +86,9 @@ jobs: - name: Build Linux AppImage run: fastforge package --platform linux --targets deb - upload_artifacts: - needs: [build_android, build_linux] - runs-on: ubuntu-latest - steps: - - name: Upload Artifacts + - name: Upload deb Artifacts uses: actions/upload-artifact@v4 with: name: build-artifacts path: | - build/app/outputs/flutter-apk/*.apk dist/*/*.deb