Skip to content

Instantly share code, notes, and snippets.

@jaredsburrows
Last active March 18, 2023 19:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredsburrows/d04b980d0f530f54858a094d5e7f3f85 to your computer and use it in GitHub Desktop.
Save jaredsburrows/d04b980d0f530f54858a094d5e7f3f85 to your computer and use it in GitHub Desktop.
Flutter - Android + iOS + Web
name: build
on:
push:
branches:
- main
pull_request:
types: [ opened, labeled, unlabeled, synchronize ]
env:
REPO_NAME: flutter-app-playground
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx4g -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m"
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout Project
uses: actions/checkout@v3.3.0
- name: Cache Dependencies
uses: actions/cache@v3.3.1
with:
path: |
~/.gradle/caches
~/.gradle/wrapper/
~/.android/build-cache
ios/Pods
/Users/runner/hostedtoolcache/flutter
/Users/runner/.pub-cache
key: ${{ runner.os }}-build
restore-keys: |
${{ runner.os }}-build
- name: Configure Flutter
uses: subosito/flutter-action@v2.8.0
with:
channel: stable
cache: true
- name: Run Analyzer
run: flutter analyze --suppress-analytics --no-fatal-infos --no-fatal-warnings
android:
runs-on: macos-latest
needs:
- build
steps:
- name: Checkout Project
uses: actions/checkout@v3.3.0
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1.0.6
- name: Cache Dependencies
uses: actions/cache@v3.3.1
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.android/build-cache
ios/Pods
/opt/hostedtoolcache/flutter
/Users/runner/hostedtoolcache/flutter
/Users/runner/.pub-cache
key: ${{ runner.os }}-android
restore-keys: |
${{ runner.os }}-android
- name: Configure JDK
uses: actions/setup-java@v3.10.0
with:
java-version: 19
distribution: temurin
cache: gradle
- name: Run Build
uses: gradle/gradle-build-action@v2
- name: Configure Flutter
uses: subosito/flutter-action@v2.8.0
with:
channel: stable
cache: true
- name: Build Android
run: |
flutter build apk --release --obfuscate --split-debug-info build/app/outputs/symbols-apk/ --target-platform android-arm64
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
if: github.repository == 'jaredsburrows/flutter-app-playground' && github.ref == 'refs/heads/main'
with:
name: ${{ env.REPO_NAME }}-android-${{ github.run_id }}
path: |
build/app/outputs/apk/release
build/app/outputs/bundle/release
build/app/outputs/symbols-apk
build/app/outputs/symbols-appbundle
ios:
runs-on: macos-latest
needs:
- build
steps:
- name: Checkout Project
uses: actions/checkout@v3.3.0
- name: Cache Dependencies
uses: actions/cache@v3.3.1
with:
path: |
~/.gradle/caches
~/.gradle/wrapper/
~/.android/build-cache
/Users/runner/hostedtoolcache/flutter
/Users/runner/.pub-cache
key: ${{ runner.os }}-ios
restore-keys: |
${{ runner.os }}-ios
- name: Configure Flutter
uses: subosito/flutter-action@v2.8.0
with:
channel: stable
cache: true
- name: Build iOS
run: |
flutter build ios --release --obfuscate --split-debug-info build/ios/outputs/symbols --no-codesign
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
if: github.repository == 'jaredsburrows/flutter-app-playground' && github.ref == 'refs/heads/main'
with:
name: ${{ env.REPO_NAME }}-ios-${{ github.run_id }}
path: |
build/ios/Release-iphoneos
build/ios/symbols
web:
runs-on: macos-latest
needs:
- build
steps:
- name: Checkout Project
uses: actions/checkout@v3.3.0
- name: Cache Dependencies
uses: actions/cache@v3.3.1
with:
path: |
~/.gradle/caches
~/.gradle/wrapper/
~/.android/build-cache
/Users/runner/hostedtoolcache/flutter
/Users/runner/.pub-cache
key: ${{ runner.os }}-build
restore-keys: |
${{ runner.os }}-web
- name: Configure Flutter
uses: subosito/flutter-action@v2.8.0
with:
channel: stable
cache: true
- name: Build Website
run: |
flutter build web --release --base-href /flutter-app-playground/
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
if: github.repository == 'jaredsburrows/flutter-app-playground' && github.ref == 'refs/heads/main'
with:
name: ${{ env.REPO_NAME }}-web-${{ github.run_id }}
path: |
build/web
publish:
runs-on: macos-latest
if: github.repository == 'jaredsburrows/flutter-app-playground' && github.ref == 'refs/heads/main'
needs:
- build
- android
- ios
- web
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ env.REPO_NAME }}-web-${{ github.run_id }}
path: ./build/web
- name: Publish Website
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web
user_name: "Github Actions"
user_email: "action@github.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment