Files
TimeTracker/.github/workflows/build-mobile.yml
T
Dries Peeters da85aedefb feat(mobile): add data layer, OTLP telemetry, and CI build fixes
Implement the missing Flutter data layer so release builds compile: Dio ApiClient for /api/v1 (timer, time entries, projects, tasks, finance, time-off, users/me), JSON models, Hive LocalStorage, and offline SyncService queue.

Add OpenTelemetry (opentelemetry package) with initMobileOpenTelemetry() reading OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_TOKEN via --dart-define, matching server OTLP base URL and Basic auth behavior. Instrument login token validation, timer start/stop, and sync pending.

Fix SyncUseCase to import storage SyncService, use trusted insecure hosts, and call syncAll().

GitHub Actions (build-mobile.yml, cd-release.yml): run flutter test; pass OTLP secrets into flutter build apk/appbundle/ios; switch iOS CI to release simulator builds and package build/ios/iphonesimulator/Runner.app to avoid requiring an Apple Development Team for generic device builds.

.gitignore: allow tracking mobile/lib/data/ despite the repo-wide data/ ignore rule.
2026-03-28 18:01:10 +01:00

137 lines
4.0 KiB
YAML

name: Build Mobile Apps
on:
push:
branches: [ main, develop ]
paths:
- 'mobile/**'
- '.github/workflows/build-mobile.yml'
pull_request:
branches: [ main ]
paths:
- 'mobile/**'
workflow_dispatch:
jobs:
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.4'
channel: 'stable'
- name: Disable Flutter analytics
run: flutter config --no-analytics
- name: Install dependencies
working-directory: mobile
run: flutter pub get
- name: Generate app icons
run: |
pip install Pillow
python scripts/generate-mobile-icon.py
- name: Generate launcher icons
working-directory: mobile
run: dart run flutter_launcher_icons
- name: Run tests
working-directory: mobile
run: flutter test
- name: Build APK
working-directory: mobile
env:
OTEL_EXPORTER_OTLP_ENDPOINT: ${{ secrets.OTEL_EXPORTER_OTLP_ENDPOINT }}
OTEL_EXPORTER_OTLP_TOKEN: ${{ secrets.OTEL_EXPORTER_OTLP_TOKEN }}
run: |
flutter build apk --release \
--dart-define=OTEL_EXPORTER_OTLP_ENDPOINT="${OTEL_EXPORTER_OTLP_ENDPOINT:-}" \
--dart-define=OTEL_EXPORTER_OTLP_TOKEN="${OTEL_EXPORTER_OTLP_TOKEN:-}"
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: android-apk
path: mobile/build/app/outputs/flutter-apk/app-release.apk
build-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.4'
channel: 'stable'
- name: Disable Flutter analytics
run: flutter config --no-analytics
- name: Install dependencies
working-directory: mobile
run: flutter pub get
- name: Generate iOS platform files
working-directory: mobile
run: flutter create --platforms=ios .
- name: Generate app icons
run: |
pip install Pillow
python scripts/generate-mobile-icon.py
- name: Generate launcher icons
working-directory: mobile
run: |
dart run flutter_launcher_icons
dart run flutter_launcher_icons -f flutter_launcher_icons_ios.yaml
# Simulator build avoids Apple Development Team / provisioning (device ipa still needs signing locally).
- name: Run tests
working-directory: mobile
run: flutter test
- name: Build iOS (simulator)
working-directory: mobile
env:
OTEL_EXPORTER_OTLP_ENDPOINT: ${{ secrets.OTEL_EXPORTER_OTLP_ENDPOINT }}
OTEL_EXPORTER_OTLP_TOKEN: ${{ secrets.OTEL_EXPORTER_OTLP_TOKEN }}
run: |
flutter build ios --release --simulator \
--dart-define=OTEL_EXPORTER_OTLP_ENDPOINT="${OTEL_EXPORTER_OTLP_ENDPOINT:-}" \
--dart-define=OTEL_EXPORTER_OTLP_TOKEN="${OTEL_EXPORTER_OTLP_TOKEN:-}"
- name: Create iOS archive
if: success()
working-directory: mobile
run: |
mkdir -p dist
if [ -d "build/ios/iphonesimulator/Runner.app" ]; then
cd build/ios/iphonesimulator
zip -r ../../../dist/TimeTracker-iOS.zip Runner.app
cd ../../..
else
echo "Warning: Runner.app not found at build/ios/iphonesimulator/Runner.app"
ls -la build/ios/ || true
ls -la build/ || true
fi
- name: Upload iOS build
if: success()
uses: actions/upload-artifact@v4
with:
name: ios-build
path: mobile/dist/*.zip
if-no-files-found: warn