ci: add GitHub Actions Android build workflow
This commit is contained in:
parent
13c9792791
commit
77a54401fc
|
|
@ -0,0 +1,116 @@
|
|||
name: MotorSignal Android CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: android-build-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyze-and-build:
|
||||
name: Analyze and build Android
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
cache: true
|
||||
|
||||
- name: Flutter version
|
||||
run: flutter --version
|
||||
|
||||
- name: Get dependencies
|
||||
run: flutter pub get
|
||||
|
||||
- name: Analyze
|
||||
run: flutter analyze
|
||||
|
||||
- name: Run tests
|
||||
run: flutter test
|
||||
|
||||
- name: Build debug APK
|
||||
run: flutter build apk --debug
|
||||
|
||||
- name: Upload debug APK
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: motorsignal-debug-apk
|
||||
path: build/app/outputs/flutter-apk/app-debug.apk
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
release:
|
||||
name: Build signed release APK
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
cache: true
|
||||
|
||||
- name: Get dependencies
|
||||
run: flutter pub get
|
||||
|
||||
- name: Restore release keystore
|
||||
env:
|
||||
KEYSTORE_BASE64: ${{ secrets.MOTORSIGNAL_KEYSTORE_BASE64 }}
|
||||
run: |
|
||||
test -n "$KEYSTORE_BASE64" || { echo "Missing MOTORSIGNAL_KEYSTORE_BASE64 repository secret"; exit 1; }
|
||||
echo "$KEYSTORE_BASE64" | base64 --decode > android/app/motorsignal-upload-keystore.jks
|
||||
|
||||
- name: Create signing properties
|
||||
env:
|
||||
STORE_PASSWORD: ${{ secrets.MOTORSIGNAL_STORE_PASSWORD }}
|
||||
KEY_PASSWORD: ${{ secrets.MOTORSIGNAL_KEY_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.MOTORSIGNAL_KEY_ALIAS }}
|
||||
run: |
|
||||
test -n "$STORE_PASSWORD" || { echo "Missing MOTORSIGNAL_STORE_PASSWORD repository secret"; exit 1; }
|
||||
test -n "$KEY_PASSWORD" || { echo "Missing MOTORSIGNAL_KEY_PASSWORD repository secret"; exit 1; }
|
||||
test -n "$KEY_ALIAS" || { echo "Missing MOTORSIGNAL_KEY_ALIAS repository secret"; exit 1; }
|
||||
cat > android/key.properties <<EOF
|
||||
storePassword=$STORE_PASSWORD
|
||||
keyPassword=$KEY_PASSWORD
|
||||
keyAlias=$KEY_ALIAS
|
||||
storeFile=app/motorsignal-upload-keystore.jks
|
||||
EOF
|
||||
|
||||
- name: Build release APK
|
||||
run: flutter build apk --release
|
||||
|
||||
- name: Build release App Bundle
|
||||
run: flutter build appbundle --release
|
||||
|
||||
- name: Upload release APK
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: motorsignal-release-apk
|
||||
path: build/app/outputs/flutter-apk/app-release.apk
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload release App Bundle
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: motorsignal-release-aab
|
||||
path: build/app/outputs/bundle/release/app-release.aab
|
||||
if-no-files-found: error
|
||||
retention-days: 30
|
||||
Loading…
Reference in New Issue