Skip to content

Commit

Permalink
cicd: attempt at caching files
Browse files Browse the repository at this point in the history
  • Loading branch information
Xazin committed Dec 10, 2022
1 parent aca10b0 commit 17043b7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
69 changes: 58 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,41 @@ jobs:
steps:
- name: Fetch code from repository
uses: actions/checkout@v2

- name: Cache Flutter install
uses: actions/cache@v2
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/checkout@v3
with:
path: .
key: code-cache-${{ github.sha }}
restore-keys: |
code-cache-${{ github.sha }}
code-cache-
code-cache
- name: Statically analyze the Dart code
run: |
echo ${{ secrets.ENV }} | base64 -d > .env
Expand All @@ -56,28 +73,40 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Fetch code from repository
uses: actions/checkout@v2
- name: Fetch code from cache
id: code-cache
uses: actions/checkout@v3
with:
path: .
key: code-cache-${{ github.sha }}
restore-keys: |
code-cache-${{ github.sha }}
code-cache-
code-cache
- name: Cache Flutter install
uses: actions/cache@v2
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: Build generated code
run: flutter pub run build_runner build --delete-conflicting-outputs

- name: Generate test file
run: ./.github/scripts/coverage_gen.sh

- name: Run tests and generate coverage
run: |
echo ${{ secrets.ENV }} | base64 -d > .env
flutter test --coverage -r expanded .
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
Expand All @@ -90,8 +119,17 @@ jobs:
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Fetch code from repository
uses: actions/checkout@v2
- name: Fetch code from cache
id: code-cache
uses: actions/checkout@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
Expand All @@ -100,10 +138,12 @@ jobs:
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@v2
with:
Expand All @@ -112,23 +152,26 @@ jobs:
# 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: Build generated code
run: flutter pub run build_runner build --delete-conflicting-outputs

- name: Generate app icons
run: flutter pub run flutter_launcher_icons:main

- name: Build appbundle
run: |
echo ${{ github.ref == 'refs/heads/master' && secrets.ENV_PROD || secrets.ENV_DEV }} | base64 -d > .env
echo ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON }} | base64 -d > android/app/google-services.json
flutter build appbundle --release --build-number $GITHUB_RUN_NUMBER
cp release_notes.txt build/app/outputs/
- name: Sign appbundle
uses: r0adkll/sign-android-release@v1
id: sign_appbundle
Expand All @@ -138,6 +181,7 @@ jobs:
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:
Expand All @@ -148,6 +192,7 @@ jobs:
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

- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_CERT_P12 }}
Expand Down Expand Up @@ -176,18 +221,21 @@ jobs:
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Build iOS app
run: |
echo ${{ secrets.IOS_GOOGLESERVICE_INFO_PLIST }} | base64 -d > ios/Runner/GoogleService-Info.plist
flutter build ipa --release --export-options-plist=ExportOptions.plist --build-number $GITHUB_RUN_NUMBER
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
Expand All @@ -199,9 +247,6 @@ jobs:
env:
WIDGETBOOK_API_KEY: ${{ secrets.WIDGETBOOK_API_KEY }}
steps:
- name: Build generated code
run: flutter pub run build_runner build --delete-conflicting-outputs

- name: Build web
run: flutter build web -t widgetbook/main.dart

Expand All @@ -216,6 +261,7 @@ jobs:
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:
Expand All @@ -233,6 +279,7 @@ jobs:
uses: actions/download-artifact@v2
with:
name: ios-release

- name: "Upload iOS app to TestFlight"
uses: apple-actions/upload-testflight-build@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end

0 comments on commit 17043b7

Please sign in to comment.