Files
sure/.github/workflows/flutter-build.yml
Juan José Mata 2f4e2eab8d Workflow chores: publish Flutter builds & bump alpha versions (#599)
* Add debug mobile artifacts to GitHub releases

- Modify flutter-build.yml to trigger on version tags (v*) and support
  workflow_call for use by other workflows
- Add mobile job to publish.yml that calls flutter-build workflow
- Add release job that creates GitHub release with debug APK and
  unsigned iOS build when a version tag is pushed
- Auto-detect debug vs release APK and name appropriately
- Mark alpha/beta/rc versions as pre-releases

* Add automatic alpha version bump after release

When an alpha tag (e.g., v0.6.7-alpha.3) is published and the Docker
image is built, automatically bump the alpha number in version.rb
(e.g., alpha.3 -> alpha.4) and push to main branch.

* Fix APK copying to include both debug and release builds

Change if/elif to separate if statements so both app-debug.apk and
app-release.apk are copied to release assets when both exist.

* Rename artifact names in publish workflow

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>

* Revert rename of artifact names

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>

* Enhance version bump process in publish.yml

Refactor version bump script to ensure version file exists and improve error handling.

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>

---------

Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-10 10:59:15 +01:00

183 lines
5.4 KiB
YAML

name: Flutter Mobile Build
on:
push:
branches:
- main
tags:
- 'v*'
paths:
- 'mobile/lib/**'
- 'mobile/android/**'
- 'mobile/ios/**'
- 'mobile/pubspec.yaml'
- '.github/workflows/flutter-build.yml'
pull_request:
paths:
- 'mobile/lib/**'
- 'mobile/android/**'
- 'mobile/ios/**'
- 'mobile/pubspec.yaml'
- '.github/workflows/flutter-build.yml'
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
build-android:
name: Build Android APK
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.32.4'
channel: 'stable'
cache: true
- name: Get dependencies
working-directory: mobile
run: flutter pub get
- name: Generate app icons
working-directory: mobile
run: flutter pub run flutter_launcher_icons
- name: Analyze code
working-directory: mobile
run: flutter analyze --no-fatal-infos
- name: Run tests
working-directory: mobile
run: flutter test
- name: Check if keystore secrets exist
id: check_secrets
run: |
if [ -n "${{ secrets.KEYSTORE_BASE64 }}" ]; then
echo "has_keystore=true" >> $GITHUB_OUTPUT
echo "✓ Keystore secrets found, will build signed APK"
else
echo "has_keystore=false" >> $GITHUB_OUTPUT
echo "⚠ No keystore secrets, will build unsigned debug APK"
fi
- name: Decode and setup keystore
if: steps.check_secrets.outputs.has_keystore == 'true'
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
run: |
echo "$KEYSTORE_BASE64" | base64 -d > mobile/android/app/upload-keystore.jks
echo "storePassword=$KEY_STORE_PASSWORD" > mobile/android/key.properties
echo "keyPassword=$KEY_PASSWORD" >> mobile/android/key.properties
echo "keyAlias=$KEY_ALIAS" >> mobile/android/key.properties
echo "storeFile=upload-keystore.jks" >> mobile/android/key.properties
echo "✓ Keystore configured successfully"
- name: Build APK (Release)
working-directory: mobile
run: |
if [ "${{ steps.check_secrets.outputs.has_keystore }}" == "true" ]; then
echo "Building signed release APK..."
flutter build apk --release
else
echo "Building debug-signed APK..."
flutter build apk --debug
fi
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: app-release-apk
path: |
mobile/build/app/outputs/flutter-apk/app-release.apk
mobile/build/app/outputs/flutter-apk/app-debug.apk
retention-days: 30
if-no-files-found: ignore
- name: Build App Bundle (Release)
if: steps.check_secrets.outputs.has_keystore == 'true'
working-directory: mobile
run: flutter build appbundle --release
- name: Upload AAB artifact
if: steps.check_secrets.outputs.has_keystore == 'true'
uses: actions/upload-artifact@v4
with:
name: app-release-aab
path: mobile/build/app/outputs/bundle/release/app-release.aab
retention-days: 30
build-ios:
name: Build iOS IPA
runs-on: macos-latest
timeout-minutes: 45
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.32.4'
channel: 'stable'
cache: true
- name: Get dependencies
working-directory: mobile
run: flutter pub get
- name: Generate app icons
working-directory: mobile
run: flutter pub run flutter_launcher_icons
- name: Install CocoaPods dependencies
working-directory: mobile/ios
run: pod install
- name: Analyze code
working-directory: mobile
run: flutter analyze --no-fatal-infos
- name: Run tests
working-directory: mobile
run: flutter test
- name: Build iOS (No Code Signing)
working-directory: mobile
run: flutter build ios --release --no-codesign
- name: Create IPA archive info
working-directory: mobile
run: |
echo "iOS build completed successfully" > build/ios-build-info.txt
echo "Build date: $(date)" >> build/ios-build-info.txt
echo "Note: This build is not code-signed and cannot be installed on physical devices" >> build/ios-build-info.txt
echo "For distribution, you need to configure code signing with Apple certificates" >> build/ios-build-info.txt
- name: Upload iOS build artifact
uses: actions/upload-artifact@v4
with:
name: ios-build-unsigned
path: |
mobile/build/ios/iphoneos/Runner.app
mobile/build/ios-build-info.txt
retention-days: 30