Skip to content

chore: Update README.md #1091

chore: Update README.md

chore: Update README.md #1091

Workflow file for this run

# ==================================================
# This is the main worflow for testing and building
# the app.
# The following is not yet implemented:
# - Use fastlane (?)
# - Obfuscate the build and remove debug symbols
# (https://docs.flutter.dev/deployment/obfuscate)
# ==================================================
name: CI
on:
push:
branches: [master, development]
pull_request:
types: [opened, synchronize]
workflow_dispatch:
env:
flutter_version: "3.7.1"
flutter_channel: "stable"
java_version: "12.x"
jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Fetch code from repository
uses: actions/checkout@v2
- name: Cache Flutter install
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/flutter
key: cache-flutter-${{ env.flutter_channel }}-${{ env.flutter_version }}-${{ runner.os }}
- name: Setup the Flutter environment
uses: subosito/flutter-action@v2
with:
channel: ${{ env.flutter_channel }}
flutter-version: ${{ env.flutter_version }}
- name: Get Flutter dependencies
run: flutter pub get .
- name: Check for any formatting issues
run: flutter format --dry-run --set-exit-if-changed .
- name: Build generated code
run: |
flutter pub run flutter_oss_licenses:generate.dart lib/presentation/licenses/oss_licenses.dart
flutter pub run build_runner build --delete-conflicting-outputs
- name: Cache files including generated
id: code-cache
uses: actions/cache@v3
with:
path: .
key: code-cache-${{ github.sha }}
- name: Statically analyze the Dart code
run: |
echo "" | base64 -d > .env
flutter analyze .
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Fetch code from repository
uses: actions/checkout@v2
- name: Cache Flutter install
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/flutter
key: cache-flutter-${{ env.flutter_channel }}-${{ env.flutter_version }}-${{ runner.os }}
- name: Setup the Flutter environment
uses: subosito/flutter-action@v2
with:
channel: ${{ env.flutter_channel }}
flutter-version: ${{ env.flutter_version }}
- name: Get Flutter dependencies
run: flutter pub get .
- name: Generate test file
run: ./.github/scripts/coverage_gen.sh
- name: Build generated code
run: |
flutter pub run flutter_oss_licenses:generate.dart lib/presentation/licenses/oss_licenses.dart
flutter pub run build_runner build --delete-conflicting-outputs
- name: Run tests and generate coverage
run: |
echo "" | base64 -d > .env
flutter test --coverage -r expanded .
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
verbose: true
file: coverage/lcov.info
build_android:
if: ${{ github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master' }}
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [analyze, test]
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Fetch code from cache
id: code-cache
uses: actions/cache@v3
with:
path: .
key: code-cache-${{ github.sha }}
restore-keys: |
code-cache-${{ github.sha }}
code-cache-
code-cache
- name: Create release notes file
run: |
cat > release_notes.txt <<EOF
Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
Commit: $(git rev-parse --short HEAD)
Author: $(git log -1 --pretty=format:'%an')
Message: $(git log -1 --pretty=%B)
EOF
- name: Setup Java for Android
uses: actions/setup-java@v1
with:
java-version: ${{ env.java_version }}
- name: Cache Flutter install
uses: actions/cache@v3
with:
# Linux (deprecate):
# path: /opt/hostedtoolcache/flutter
# MacOS:
path: /Users/runner/hostedtoolcache/flutter
key: cache-flutter-${{ env.flutter_channel }}-${{ env.flutter_version }}-${{ runner.os }}
- name: Setup the Flutter environment
uses: subosito/flutter-action@v2
with:
channel: ${{ env.flutter_channel }}
flutter-version: ${{ env.flutter_version }}
- name: Get Flutter dependencies
run: flutter pub get .
- name: Generate app icons
run: flutter pub run flutter_launcher_icons:main
- name: Build appbundle
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: |
echo ${{ secrets.ENV }} | base64 -d > .env
echo $GOOGLE_SERVICES_JSON | base64 -d > android/app/google-services.json
flutter build appbundle --release --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons --obfuscate --split-debug-info=build-info/
cp release_notes.txt build/app/outputs/
- name: Sign appbundle
uses: r0adkll/sign-android-release@v1
id: sign_appbundle
with:
releaseDirectory: build/app/outputs/bundle/release
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
alias: ${{ secrets.ANDROID_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Upload android build artifacts
uses: actions/upload-artifact@v2
with:
name: android-release
path: |
${{steps.sign_appbundle.outputs.signedReleaseFile}}
build/app/outputs/logs
build/app/outputs/release_notes.txt
# Prerequisites for building iOS
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
build_ios:
if: ${{ github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master' }}
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [analyze, test]
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Fetch code from cache
id: code-cache
uses: actions/cache@v3
with:
path: .
key: code-cache-${{ github.sha }}
restore-keys: |
code-cache-${{ github.sha }}
code-cache-
code-cache
- name: Create release notes file
run: |
cat > release_notes.txt <<EOF
Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
Commit: $(git rev-parse --short HEAD)
Author: $(git log -1 --pretty=format:'%an')
Message: $(git log -1 --pretty=%B)
EOF
- name: Cache Flutter install
uses: actions/cache@v3
with:
# Linux (deprecate):
# path: /opt/hostedtoolcache/flutter
# MacOS:
path: /Users/runner/hostedtoolcache/flutter
key: cache-flutter-${{ env.flutter_channel }}-${{ env.flutter_version }}-${{ runner.os }}
- name: Setup the Flutter environment
uses: subosito/flutter-action@v2
with:
channel: ${{ env.flutter_channel }}
flutter-version: ${{ env.flutter_version }}
- name: Get Flutter dependencies
run: flutter pub get .
- name: Generate app icons
run: flutter pub run flutter_launcher_icons:main
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_CERT_P12 }}
P12_PASSWORD: ${{ secrets.IOS_P12_PASS }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.IOS_MOBILEPROVISION }}
KEYCHAIN_PASSWORD: ${{ secrets.IOS_P12_PASS }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Build iOS app
env:
IOS_GOOGLESERVICE_INFO_PLIST: ${{ secrets.IOS_GOOGLESERVICE_INFO_PLIST }}
run: |
echo ${{ secrets.ENV }} | base64 -d > .env
echo $IOS_GOOGLESERVICE_INFO_PLIST | base64 --decode > ios/Runner/GoogleService-Info.plist
flutter build ipa --release --export-options-plist=ExportOptions.plist --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons --obfuscate --split-debug-info=build-info/
cp release_notes.txt build/ios/ipa/
- name: Upload iOS build artifacts
uses: actions/upload-artifact@v2
with:
name: ios-release
path: |
build/ios/ipa/*.ipa
build/ios/ipa/release_notes.txt
- name: Clean up keychain and provisioning profile
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
distribute_android:
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [build_android]
runs-on: ubuntu-latest
steps:
- name: Download generated apk from the artifacts
uses: actions/download-artifact@v2
with:
name: android-release
- name: Upload generated apk to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{secrets.FIREBASE_ANDROID_APP_ID}}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: internal
file: bundle/release/app-release.aab
releaseNotesFile: release_notes.txt
distribute_ios:
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
needs: [build_ios]
runs-on: macos-latest
steps:
- name: Download generated ipa from the artifacts
uses: actions/download-artifact@v2
with:
name: ios-release
- name: "Upload iOS app to TestFlight"
uses: apple-actions/upload-testflight-build@v1
with:
app-path: "CollAction.ipa"
issuer-id: ${{ secrets.IOS_APPSTORE_ISSUER_ID }}
api-key-id: ${{ secrets.IOS_APPSTORE_API_KEY_ID }}
api-private-key: ${{ secrets.IOS_APPSTORE_API_PRIVATE_KEY }}