Last active
March 18, 2023 19:04
-
-
Save jaredsburrows/d04b980d0f530f54858a094d5e7f3f85 to your computer and use it in GitHub Desktop.
Flutter - Android + iOS + Web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
- name: Cache Dependencies | |
uses: actions/[email protected] | |
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/[email protected] | |
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/[email protected] | |
- name: Validate Gradle Wrapper | |
uses: gradle/[email protected] | |
- name: Cache Dependencies | |
uses: actions/[email protected] | |
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/[email protected] | |
with: | |
java-version: 19 | |
distribution: temurin | |
cache: gradle | |
- name: Run Build | |
uses: gradle/gradle-build-action@v2 | |
- name: Configure Flutter | |
uses: subosito/[email protected] | |
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/[email protected] | |
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/[email protected] | |
- name: Cache Dependencies | |
uses: actions/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
- name: Cache Dependencies | |
uses: actions/[email protected] | |
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/[email protected] | |
with: | |
channel: stable | |
cache: true | |
- name: Build Website | |
run: | | |
flutter build web --release --base-href /flutter-app-playground/ | |
- name: Upload Artifacts | |
uses: actions/[email protected] | |
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: "[email protected]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment