Added workflow for CI/CD
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
name: Analyze and test
|
||||
|
||||
jobs:
|
||||
analyze-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
modules:
|
||||
- default
|
||||
- core
|
||||
- model
|
||||
- contact
|
||||
- forward
|
||||
- rule_filter
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: "3.0.5"
|
||||
channel: "stable"
|
||||
cache: true
|
||||
cache-key: "deps-${{ hashFiles('pubspec.lock') }}"
|
||||
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
|
||||
|
||||
- name: Run prebuild
|
||||
run: bash prebuild.sh
|
||||
|
||||
- name: Analyze
|
||||
uses: zgosalvez/github-actions-analyze-dart@v1
|
||||
with:
|
||||
analysis-options-file: "placeholder"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
if [[ "${{ matrix.modules }}" == "default" ]]; then
|
||||
flutter test -r json > test-report-${{ matrix.modules }}.json
|
||||
else
|
||||
flutter test -r json ${{ matrix.modules }} > test-report-${{ matrix.modules }}.json
|
||||
fi
|
||||
|
||||
- name: Upload test reports
|
||||
if: success() || failure() # Always upload report
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-reports
|
||||
path: test-report*.json
|
||||
|
||||
report:
|
||||
runs-on: ubuntu-latest
|
||||
if: success() || failure() # Always upload report
|
||||
needs:
|
||||
- analyze-test
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: test-reports
|
||||
|
||||
- uses: dorny/test-reporter@v1
|
||||
with:
|
||||
name: Flutter Tests
|
||||
path: "*.json"
|
||||
reporter: flutter-json
|
||||
only-summary: "true"
|
||||
@@ -0,0 +1,94 @@
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- ".github/**"
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
analyze-test:
|
||||
name: Analyze and test
|
||||
uses: ./.github/workflows/analyze-test.yaml
|
||||
|
||||
build-app:
|
||||
name: Build app
|
||||
needs:
|
||||
- analyze-test
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- android
|
||||
- ios
|
||||
environment: dev
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: "3.0.5"
|
||||
channel: "stable"
|
||||
cache: true
|
||||
cache-key: deps-${{ hashFiles('pubspec.lock') }} # optional, change this to force refresh cache
|
||||
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
|
||||
|
||||
- name: Setup Android environment
|
||||
if: matrix.os == 'android'
|
||||
env:
|
||||
# GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
|
||||
PLAY_STORE_UPLOAD_KEY_BASE64: ${{ secrets.PLAY_STORE_UPLOAD_KEY_BASE64 }}
|
||||
PLAY_STORE_KEY_INFO_BASE64: ${{ secrets.PLAY_STORE_KEY_INFO_BASE64 }}
|
||||
run: |
|
||||
# echo "$GOOGLE_SERVICES_JSON" > app/google-services.json
|
||||
echo "$PLAY_STORE_UPLOAD_KEY_BASE64" | base64 --decode --output app/keystore.jks
|
||||
echo "$PLAY_STORE_KEY_INFO_BASE64" | base64 --decode --output key.properties
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Setup Java
|
||||
if: matrix.os == 'android'
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "11"
|
||||
|
||||
- name: Setup iOS environment
|
||||
if: matrix.os == 'ios'
|
||||
env:
|
||||
# GOOGLE_SERVICES_PLIST: ${{ secrets.GOOGLE_SERVICES_PLIST }}
|
||||
CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }}
|
||||
PROVISION_PROFILE_BASE64: ${{ secrets.PROVISION_PROFILE_BASE64 }}
|
||||
SHAREEXT_PROVISION_PROFILE_BASE64: ${{ secrets.SHAREEXT_PROVISION_PROFILE_BASE64 }}
|
||||
run: |
|
||||
# echo -n "$GOOGLE_SERVICES_PLIST" > Runner/GoogleService-Info.plist
|
||||
echo -n "$CERTIFICATE_BASE64" | base64 --decode --output cert.p12
|
||||
echo -n "$PROVISION_PROFILE_BASE64" | base64 --decode --output buildpp.mobileprovision
|
||||
echo -n "$SHAREEXT_PROVISION_PROFILE_BASE64" | base64 --decode --output shareextpp.mobileprovision
|
||||
flutter pub get && pod install
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Setup Fastlane
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: "ruby"
|
||||
bundler-cache: true
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Run prebuild
|
||||
run: bash prebuild.sh
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
|
||||
run: bundle exec fastlane dev
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: tmail-dev-pr-${{ github.event.pull_request.number }}
|
||||
path: |
|
||||
build/app/outputs/flutter-apk/app-release.apk
|
||||
ios/Runner.ipa
|
||||
@@ -0,0 +1,94 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "release"
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
name: Release
|
||||
|
||||
jobs:
|
||||
analyze-test:
|
||||
name: Analyze and test
|
||||
uses: ./.github/workflows/analyze-test.yaml
|
||||
|
||||
release:
|
||||
name: Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
needs:
|
||||
- analyze-test
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- android
|
||||
- ios
|
||||
environment: prod
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: "release"
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: "3.0.5"
|
||||
channel: "stable"
|
||||
cache: true
|
||||
cache-key: deps-${{ hashFiles('pubspec.lock') }} # optional, change this to force refresh cache
|
||||
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
|
||||
|
||||
- name: Setup Android environment
|
||||
if: matrix.os == 'android'
|
||||
env:
|
||||
PLAY_STORE_UPLOAD_KEY_BASE64: ${{ secrets.PLAY_STORE_UPLOAD_KEY_BASE64 }}
|
||||
PLAY_STORE_KEY_INFO_BASE64: ${{ secrets.PLAY_STORE_KEY_INFO_BASE64 }}
|
||||
run: |
|
||||
echo "$PLAY_STORE_UPLOAD_KEY_BASE64" | base64 --decode --output app/keystore.jks
|
||||
echo "$PLAY_STORE_KEY_INFO_BASE64" | base64 --decode --output key.properties
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Setup Java
|
||||
if: matrix.os == 'android'
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "11"
|
||||
|
||||
- name: Setup iOS environment
|
||||
if: matrix.os == 'ios'
|
||||
env:
|
||||
CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }}
|
||||
PROVISION_PROFILE_BASE64: ${{ secrets.PROVISION_PROFILE_BASE64 }}
|
||||
SHAREEXT_PROVISION_PROFILE_BASE64: ${{ secrets.SHAREEXT_PROVISION_PROFILE_BASE64 }}
|
||||
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
|
||||
run: |
|
||||
echo -n "$CERTIFICATE_BASE64" | base64 --decode --output cert.p12
|
||||
echo -n "$PROVISION_PROFILE_BASE64" | base64 --decode --output buildpp.mobileprovision
|
||||
echo -n "$SHAREEXT_PROVISION_PROFILE_BASE64" | base64 --decode --output shareextpp.mobileprovision
|
||||
echo -n "$APPLE_API_KEY_BASE64" | base64 --decode --output apiKey.p8
|
||||
flutter pub get && pod install
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Setup Fastlane
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: "ruby"
|
||||
bundler-cache: true
|
||||
working-directory: ${{ matrix.os }}
|
||||
|
||||
- name: Run prebuild
|
||||
run: bash prebuild.sh
|
||||
|
||||
- name: Build and deploy
|
||||
env:
|
||||
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
|
||||
FASTLANE_USER: ${{ secrets.APPLE_ID }}
|
||||
PLAY_STORE_CONFIG_JSON: ${{ secrets.PLAY_STORE_CONFIG_JSON }}
|
||||
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
|
||||
APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }}
|
||||
run: bundle exec fastlane release
|
||||
working-directory: ${{ matrix.os }}
|
||||
Reference in New Issue
Block a user