Skip to content

Instantly share code, notes, and snippets.

@rodydavis
Last active February 25, 2024 05:40
Show Gist options
  • Save rodydavis/bde9a9a8c2fcdcf3474c0f50248f2e3a to your computer and use it in GitHub Desktop.
Save rodydavis/bde9a9a8c2fcdcf3474c0f50248f2e3a to your computer and use it in GitHub Desktop.
Flutter Github Actions Build and Deploy Web to Firebase Hosting, iOS to Testflight, Android to Google Play (fastlane)
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_web:
name: Build Flutter (Web)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
channel: 'dev'
- run: flutter pub get
- run: flutter config --enable-web
- run: flutter build web
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: web-build
path: build/web
build_ios:
name: Build Flutter (iOS)
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: 'dev'
- run: flutter pub get
- run: flutter clean
- run: flutter build ios --release --no-codesign
- name: Upload iPA
uses: actions/upload-artifact@master
with:
name: ios-build
path: build/ios/iphoneos
build_apk:
name: Build Flutter (Android)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: 'dev'
- run: flutter pub get
# - run: flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
# - run: flutter build appbundle --target-platform android-arm,android-arm64
- run: flutter build appbundle
- name: Upload APK
uses: actions/upload-artifact@master
with:
name: apk-build
path: build/app/outputs/apk/release
deploy_web:
name: Deploy Web to Firebase Hosting
needs: build_web
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: web-build
path: web-build
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting --public web-build
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
PROJECT_ID: default
# deploy_ios:
# name: Deploy iOS Beta
# needs: [build_ios]
# runs-on: macOS-latest
# steps:
# - uses: actions/checkout@v1
# - uses: subosito/flutter-action@v1
# with:
# channel: 'dev'
# - run: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
# - uses: webfactory/ssh-agent@v0.1.1
# with:
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# - uses: maierj/fastlane-action@v0.9.5
# with:
# lane: 'beta'
# subdirectory: 'ios'
# env:
# GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
# deploy_apk:
# name: Deploy Android Beta
# needs: [build_apk]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-java@v1
# with:
# java-version: '12.x'
# - uses: subosito/flutter-action@v1
# with:
# channel: 'dev'
# - uses: maierj/fastlane-action@v0.9.5
# with:
# lane: 'beta'
# subdirectory: 'android'
# env:
# GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
beta_ios:
name: Upload iOS Beta to Firebase App Distribution
needs: [build_ios]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: ios-build
- name: Upload IPA
uses: wzieba/Firebase-Distribution-Github-Action@v1.0.0
with:
appId: ${{secrets.FIREBASE_IOS_APPID}}
token: ${{secrets.FIREBASE_TOKEN}}
group: testers
file: Runner.ipa
beta_apk:
name: Upload Android Beta to Firebase App Distribution
needs: [build_apk]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: apk-build
- name: Upload APK
uses: wzieba/Firebase-Distribution-Github-Action@v1.0.0
with:
appId: ${{secrets.FIREBASE_ANDROID_APPID}}
token: ${{secrets.FIREBASE_TOKEN}}
group: testers
file: app-release.aap
@joaquini
Copy link

joaquini commented Jun 4, 2020

GitHub actions on job deploy_web keeps on saying that
i deploying hosting Error: Specified public directory 'web-build' does not exist, can't deploy hosting to site.

@rodydavis
Copy link
Author

Thank you! I will update soon

@ahmetcj4
Copy link

GitHub actions on job deploy_web keeps on saying that
i deploying hosting Error: Specified public directory 'web-build' does not exist, can't deploy hosting to site.

I look at download action compatibility. It seems download location changed on new release of download action. So, we should add path attribute for download-artifact@v2 compatibility.

    - name: Download Artifact
        uses: actions/download-artifact@master
        with:
          name: web-build
          path: web-build

@esDotDev
Copy link

Curious how long this typically takes? Also have you experimented with docker to pull down the build times?

@MuhammadAhmedBaig-Airlift
Copy link

failed to upload distribution. HTTP Error: 400, Unknown Error
receiving this error

@santhoshvgts
Copy link

failed to upload distribution. error processing your binary: There's been an error processing your distribution. Ensure you are uploading a valid IPA or APK and try again. (Code: INVALID_ZIP)

Getting this error when trying upload ios to Firebase App Distribution

@rodydavis
Copy link
Author

For just web you can use the following:

name: CI
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
jobs:
  build_web:
    name: Build Flutter (Web)
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: subosito/flutter-action@v1
      with:
          channel: 'dev'
    - run: flutter pub get
    - run: flutter config --enable-web
    - run: flutter build web
    - name: Deploy to Firebase
      uses: w9jds/firebase-action@master
      with:
        args: deploy --only hosting --public build/web
      env:
        FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
        PROJECT_ID: default

@RodrigoPorras
Copy link

Hello rodydavis how do you convert the Runner.app generated by flutter build ios --release --no-codesign into a Runner.ipa ?

@luongvo
Copy link

luongvo commented Sep 7, 2021

Hello rodydavis how do you convert the Runner.app generated by flutter build ios --release --no-codesign into a Runner.ipa ?

Same question, I think we do need to use fastlane for code signing

@RodrigoPorras
Copy link

Hello rodydavis how do you convert the Runner.app generated by flutter build ios --release --no-codesign into a Runner.ipa ?

Same question, I think we do need to use fastlane for code signing

yeah, i had to use fastlane, i was able to convert the Runner.app to .ipa but fastlane is a best approach

@Saifallak
Copy link

@RodrigoPorras any tutorial on how to do that?

@RodrigoPorras
Copy link

@RodrigoPorras any tutorial on how to do that?

Hello @Saifallak. I have some messy files, no exactly a tutorial.

@AbhiShake1
Copy link

AbhiShake1 commented Jun 28, 2022

how do we config flutter version?

edit:
just edited instead of deleting incase someone needs it in future. found that it can be found here https://github.com/subosito/flutter-action

@stevenosse
Copy link

Had the same issue with the iPA generation. Fortunately, i found this article that described the steps to generate the iPA very well: https://damienaicheh.github.io/flutter/github/actions/2021/04/22/build-sign-flutter-ios-github-actions-en.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment