Created
March 20, 2022 15:00
-
-
Save iamEtornam/21c3931291a66caf497cd64d5e627e44 to your computer and use it in GitHub Desktop.
Github actions for Flutter app
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: Release assets | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
release-asset: | |
name: Release (foss) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Download Android keystore | |
id: android_keystore | |
uses: timheuer/[email protected] | |
with: | |
fileName: key.jks | |
encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
- name: Create key.properties | |
run: | | |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties | |
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties | |
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties | |
- name: Build Android App Bundle | |
run: flutter build apk --flavor foss | |
- name: Get the upload URL for a release | |
id: get_release | |
uses: bruceadams/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Upload to release assets | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_release.outputs.upload_url }} | |
asset_path: build/app/outputs/flutter-apk/app-foss-release.apk | |
asset_name: FastShopping.apk | |
asset_content_type: application/vnd.android.package-archive |
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: App Store | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
apple-appstore: | |
name: Release (full) | |
runs-on: macos-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Enable Firebase Crashlytics | |
run: | | |
sed -i '' 's/crashlytics\/foss/crashlytics\/full/g' pubspec.yaml | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Build iOS application bundle | |
run: flutter build ios --no-codesign | |
- name: Cache bundle dependencies | |
uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: ${{ runner.os }}-gems- | |
- name: Download bundle dependencies | |
run: | | |
gem install bundler:2.0.2 | |
bundle config path vendor/bundle | |
bundle install | |
- name: Release to App Store | |
env: | |
MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }} | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
APPLE_APP_IDENTIFIER: ${{ secrets.APPLE_APP_IDENTIFIER }} | |
APPLE_APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.APPLE_APP_STORE_CONNECT_API_KEY_ID }} | |
APPLE_APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APPLE_APP_STORE_CONNECT_API_KEY_ISSUER_ID }} | |
APPLE_APP_STORE_CONNECT_API_KEY: ${{ secrets.APPLE_APP_STORE_CONNECT_API_KEY }} | |
run: bundle exec fastlane ios release |
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: Google Play | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
google-play: | |
name: Release (full) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Enable Firebase Crashlytics | |
run: | | |
sed -i 's/crashlytics\/foss/crashlytics\/full/g' pubspec.yaml | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Download Android keystore | |
id: android_keystore | |
uses: timheuer/[email protected] | |
with: | |
fileName: key.jks | |
encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
- name: Create key.properties | |
run: | | |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties | |
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties | |
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties | |
- name: Build Android App Bundle | |
run: flutter build appbundle --flavor full | |
- name: Cache bundle dependencies | |
uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: ${{ runner.os }}-gems- | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.6 | |
- name: Download bundle dependencies | |
run: | | |
gem install bundler:2.0.2 | |
bundle config path vendor/bundle | |
bundle install | |
- name: Release to Google Play (production) | |
env: | |
SUPPLY_PACKAGE_NAME: ${{ secrets.ANDROID_PACKAGE_NAME }} | |
SUPPLY_JSON_KEY_DATA: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} | |
run: | | |
bundle exec fastlane run supply \ | |
aab:build/app/outputs/bundle/fullRelease/app-full-release.aab \ | |
track:production |
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: Huawei AppGallery | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
appgallery: | |
name: Release (foss) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Download Android keystore | |
id: android_keystore | |
uses: timheuer/[email protected] | |
with: | |
fileName: key.jks | |
encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
- name: Create key.properties | |
run: | | |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties | |
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties | |
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties | |
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties | |
- name: Build Android App Bundle | |
run: flutter build appbundle --flavor foss | |
- name: Cache bundle dependencies | |
uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: ${{ runner.os }}-gems- | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.6 | |
- name: Download bundle dependencies | |
run: | | |
gem install bundler:2.0.2 | |
bundle config path vendor/bundle | |
bundle install | |
- name: Release to Huawei AppGallery | |
env: | |
HUAWEI_APPGALLERY_CONNECT_APP_ID: ${{ secrets.APPGALLERY_APP_ID }} | |
HUAWEI_APPGALLERY_CONNECT_CLIENT_ID: ${{ secrets.APPGALLERY_CLIENT_ID }} | |
HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET: ${{ secrets.APPGALLERY_CLIENT_SECRET }} | |
run: | | |
bundle exec fastlane run huawei_appgallery_connect \ | |
apk_path:build/app/outputs/bundle/fossRelease/app-foss-release.aab \ | |
is_aab:true |
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: Test | |
on: | |
push: | |
branches: [master] | |
tags-ignore: ['v*'] | |
pull_request: | |
branches: [master] | |
jobs: | |
test-app: | |
name: App | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Run analyzer | |
run: flutter analyze | |
- name: Run tests | |
run: flutter test --coverage | |
- name: Upload code coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
flags: app | |
test-bloc: | |
name: Business logic | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: fast_shopping_bloc | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Dart | |
uses: dart-lang/setup-dart@v1 | |
with: | |
sdk: 2.12.4 | |
- name: Dart version | |
run: dart --version | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-bloc-pub--${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-bloc-pub- | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Run analyzer | |
run: flutter analyze | |
- name: Run tests | |
run: | | |
dart test --coverage=coverage | |
flutter pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib | |
- name: Upload code coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
flags: bloc |
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: Take screenshots | |
on: | |
workflow_dispatch: | |
jobs: | |
android: | |
name: Take Android screenshots | |
runs-on: macos-10.15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Take AVD screenshots (Pixel 2 XL) | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 28 | |
profile: pixel_2_xl | |
script: | | |
# Demo mode | |
adb shell settings put global sysui_demo_allowed 1 | |
adb shell am broadcast -a com.android.systemui.demo -e command enter | |
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 0941 | |
# Run | |
flutter drive --target=test_driver/screenshots_android.dart --flavor foss | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: android-screenshots | |
path: fastlane/metadata/android/*/images | |
ios: | |
name: Take iOS screenshots | |
runs-on: macos-10.15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v1 | |
with: | |
flutter-version: '2.2.0-10.2.pre' | |
channel: beta | |
- name: Flutter version | |
run: flutter --version | |
- name: Cache pub dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Enable Firebase Crashlytics | |
run: | | |
# https://stackoverflow.com/a/44864004/3158312 | |
sed -i '' 's/crashlytics\/foss/crashlytics\/full/g' pubspec.yaml | |
- name: Download pub dependencies | |
run: flutter pub get | |
- name: Launch iOS Simulator (iPhone 12) | |
run: | | |
xcrun simctl list --json devices available | |
export UDID=$( | |
xcrun simctl list --json devices available | \ | |
jq --raw-output '.devices."com.apple.CoreSimulator.SimRuntime.iOS-14-4"[] | select(.name == "iPhone 12").udid' | |
) | |
xcrun simctl boot $UDID | |
xcrun simctl status_bar booted override --time "9:41" --batteryState charged --batteryLevel 100 | |
- name: Take iOS Simulator screenshots | |
run: flutter drive --target=test_driver/screenshots_ios.dart | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ios-screenshots | |
path: fastlane/screenshots | |
pull-request: | |
name: Create Pull Request | |
needs: [android, ios] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Download Android artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: android-screenshots | |
path: fastlane/metadata/android | |
- name: Download iOS artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: ios-screenshots | |
path: fastlane/screenshots | |
- name: Extract branch name | |
id: extract-branch | |
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" | |
- name: Submit Pull Request | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
branch: screenshots/${{ steps.extract-branch.outputs.branch }} | |
commit-message: Update fastlane screenshots | |
title: Update fastlane screenshots | |
body: '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment