Replace setup-env action with reusable flutter-setup workflow; streamline CI configuration and enhance dependency management

This commit is contained in:
Dr.Blank 2025-04-04 23:01:18 +05:30
parent 0d2db7778a
commit d55ddc5b78
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
3 changed files with 74 additions and 44 deletions

49
.github/workflows/flutter-setup.yaml vendored Normal file
View file

@ -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

View file

@ -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