Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appbundle #515

Merged
merged 10 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/actions/build_android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Android app
description: Build and upload Android app
inputs:
version:
required: true
description: "App version"
build_version:
required: true
description: "Build version"
store_artifacts:
required: false
description: "Store artifact"
prod_release:
required: true
description: "Is prod release"

runs:
using: "composite"
steps:
- name: Setup Java
uses: actions/[email protected]
with:
distribution: "adopt"
java-version: 17

- name: Setup Flutter environment
uses: ./.github/actions/setup_flutter_environment
with:
prod_release: ${{ inputs.prod_release }}

- name: Build appbundle (dev)
if: ${{ inputs.prod_release != 'true' }}
run: flutter build appbundle --flavor development --release --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_development.dart
shell: bash

- name: Build appbundle (prod)
if: ${{ inputs.prod_release == 'true' }}
run: flutter build appbundle --flavor production --release --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_production.dart
shell: bash

- name: Upload Android build
if: ${{ !!inputs.store_artifacts }}
uses: actions/[email protected]
with:
name: android
path: build/app/outputs/bundle/release
retention-days: 1
if-no-files-found: error
64 changes: 64 additions & 0 deletions .github/actions/build_ios/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build iOS app
description: Build and upload iOS app
inputs:
jonasanker marked this conversation as resolved.
Show resolved Hide resolved
version:
required: true
description: "App version"
build_version:
required: true
description: "Build version"
apple_ios_signing_cert:
required: true
description: "iOS signing certificate"
fremartini marked this conversation as resolved.
Show resolved Hide resolved
apple_ios_signing_cert_pw:
required: true
description: "iOS signing certificate password base 64 encoded"
apple_ios_provisioning_profile:
required: true
description: "Provisioning profile"
apple_keychain_pw:
required: true
description: "Keychain password"
store_artifacts:
required: true
description: "Store artifact"
prod_release:
required: true
description: "Is prod release"

runs:
using: "composite"
steps:
- name: Install Apple certificate and provisioning profile
if: ${{ inputs.prod_release != 'true' }}
run: .github/scripts/setup_certs.sh
env:
APPLE_IOS_SIGNING_CERT: ${{ inputs.apple_ios_signing_cert }}
APPLE_IOS_SIGNING_CERT_PW: ${{ inputs.apple_ios_signing_cert_pw }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ inputs.apple_ios_provisioning_profile }}
APPLE_KEYCHAIN_PW: ${{ inputs.apple_keychain_pw }}
shell: bash

- name: Setup Flutter environment
uses: ./.github/actions/setup_flutter_environment
with:
prod_release: ${{ inputs.prod_release }}

- name: Build iOS (dev)
if: ${{ inputs.prod_release != 'true' }}
run: .github/scripts/build_ios_dev.sh ${{ inputs.version }} ${{ inputs.build_version }}
shell: bash

- name: Build iOS (prod)
if: ${{ inputs.prod_release == 'true' }}
run: .github/scripts/build_ios_prod.sh ${{ inputs.version }} ${{ inputs.build_version }}
shell: bash

- name: Upload iOS build
if: ${{ inputs.store_artifacts }}
uses: actions/[email protected]
with:
name: ios
path: build-output/ios
retention-days: 1
if-no-files-found: error
32 changes: 32 additions & 0 deletions .github/actions/setup_flutter_environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup Flutter environment
description: Setup the Flutter environment
inputs:
prod_release:
required: false
default: 'false'
description: "Is prod release"

env:
FLUTTER_VERSION: 3.13.7

runs:
using: "composite"
steps:
- name: Setup Flutter environment
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"

- name: Download dependencies
run: flutter pub get
shell: bash

- name: Replace target URI in Production
if: ${{ inputs.prod_release == 'true' }}
run: sed -i'' -e 's/.env.develop/.env.production/' lib/env/env.dart
shell: bash

- name: Generate code
run: dart run build_runner build
shell: bash
File renamed without changes.
File renamed without changes.
File renamed without changes.
173 changes: 35 additions & 138 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test
name: Build application
jonasanker marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
Expand All @@ -8,22 +8,20 @@ on:

workflow_call:
inputs:
storeArtifacts:
store_artifacts:
type: boolean
required: false
default: false
prodRelease:
prod_release:
type: boolean
required: false
tagName:
tag_name:
type: string
required: false

env:
FLUTTER_VERSION: 3.13.1
JAVA_VERSION: 17.x
PROD_RELEASE: ${{ inputs.prodRelease || 'false' }}
TAG_NAME: ${{ inputs.tagName || 'dev' }}
PROD_RELEASE: ${{ inputs.prod_release || 'false' }}
TAG_NAME: ${{ inputs.tag_name || 'dev' }}

jobs:
version:
Expand Down Expand Up @@ -55,67 +53,35 @@ jobs:
name: Build iOS App
runs-on: macos-latest
needs: [version]

steps:
- name: Checkout code
uses: actions/[email protected]

- name: Install Apple certificate and provisioning profile (dev)
if: env.PROD_RELEASE != 'true'
run: .github/scripts/setup-certs.sh
env:
APPLE_IOS_SIGNING_CERT: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT }}
APPLE_IOS_SIGNING_CERT_PW: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT_PASSWORD }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_DEVELOPMENT }}
APPLE_KEYCHAIN_PW: ${{ secrets.APPLE_KEYCHAIN_PW }}

- name: Install Apple certificate and provisioning profile (prod)
if: env.PROD_RELEASE== 'true'
run: .github/scripts/setup-certs.sh
env:
APPLE_IOS_SIGNING_CERT: ${{ secrets.APPLE_IOS_SIGNING_CERT_PROD }}
APPLE_IOS_SIGNING_CERT_PW: ${{ secrets.APPLE_IOS_SIGNING_CERT_PW }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_PROD }}
APPLE_KEYCHAIN_PW: ${{ secrets.APPLE_KEYCHAIN_PW }}

- name: Setup Java
uses: actions/[email protected]
- name: Build iOS app (dev)
if: ${{ env.PROD_RELEASE != 'true' }}
uses: ./.github/actions/build_ios
with:
distribution: "adopt"
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Flutter environment
uses: subosito/[email protected]
version: ${{ needs.version.outputs.version }}
build_version: ${{ needs.version.outputs.build_version }}
apple_ios_signing_cert: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT }}
apple_ios_signing_cert_pw: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT_PASSWORD }}
apple_ios_provisioning_profile: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_DEVELOPMENT }}
apple_keychain_pw: ${{ secrets.APPLE_KEYCHAIN_PW }}
store_artifacts: ${{ inputs.store_artifacts }}
prod_release: ${{ env.PROD_RELEASE }}

- name: Build iOS app (prod)
if: ${{ env.PROD_RELEASE == 'true' }}
uses: ./.github/actions/build_ios
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"

- name: Download dependencies
run: flutter pub get

- name: Set URI (prod)
if: env.PROD_RELEASE == 'true'
run: sed -i '' 's/.env.develop/.env.production/' lib/env/env.dart

- name: Generate code
run: dart run build_runner build

- name: Create Development build
if: env.PROD_RELEASE != 'true'
run: .github/scripts/build-dev.sh ${{ needs.version.outputs.version }} ${{ needs.version.outputs.build_version }}

- name: Create Production build
if: env.PROD_RELEASE == 'true'
run: .github/scripts/build-prod.sh ${{ needs.version.outputs.version }} ${{ needs.version.outputs.build_version }}

- name: Upload iOS build
if: ${{ inputs.storeArtifacts }}
uses: actions/[email protected]
with:
name: ios
path: build-output/ios
retention-days: 1
if-no-files-found: error
version: ${{ needs.version.outputs.version }}
build_version: ${{ needs.version.outputs.build_version }}
apple_ios_signing_cert: ${{ secrets.APPLE_IOS_SIGNING_CERT_PROD }}
apple_ios_signing_cert_pw: ${{ secrets.APPLE_IOS_SIGNING_CERT_PW }}
apple_ios_provisioning_profile: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_PROD }}
apple_keychain_pw: ${{ secrets.APPLE_KEYCHAIN_PW }}
store_artifacts: ${{ inputs.store_artifacts }}
prod_release: ${{ env.PROD_RELEASE }}

build_android:
name: Build Android App
Expand All @@ -125,79 +91,10 @@ jobs:
- name: Checkout code
uses: actions/[email protected]

- name: Setup Java
uses: actions/[email protected]
with:
distribution: "adopt"
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Flutter environment
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"

- name: Download dependencies
run: flutter pub get

- name: Set URI (prod)
if: env.PROD_RELEASE == 'true'
run: sed -i 's/.env.develop/.env.production/' lib/env/env.dart

- name: Generate code
run: dart run build_runner build

- name: Build appbundle (dev)
if: env.PROD_RELEASE != 'true'
run: flutter build apk --flavor development --release --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_development.dart

- name: Build appbundle (prod)
if: env.PROD_RELEASE== 'true'
run: flutter build apk --flavor production --release --dart-define=IS_PROD=true --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_production.dart

- name: Upload Android build
if: ${{ inputs.storeArtifacts }}
uses: actions/[email protected]
with:
name: android
path: build/app/outputs/flutter-apk
retention-days: 1
if-no-files-found: error

test:
name: Test Flutter app
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/[email protected]

- name: Setup Flutter environment
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"

- name: Download dependencies
run: flutter pub get

- name: Generate code
run: dart run build_runner build

- name: Check formatting
run: dart format --set-exit-if-changed lib/

- name: Static Analysis
run: flutter analyze

- name: Run Code Metrics
run: dart run dart_code_metrics:metrics --reporter=github lib

- name: Run tests
run: flutter test --coverage

- name: Upload test report to Codecov
uses: codecov/[email protected]
- name: Build Android app
uses: ./.github/actions/build_android
with:
flags: unittests
file: coverage/lcov.info
version: ${{ needs.version.outputs.version }}
build_version: ${{ needs.version.outputs.build_version }}
store_artifacts: ${{ inputs.store_artifacts }}
prod_release: ${{ env.PROD_RELEASE }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# This is v2.0 of this workflow file
on:
push:
branches:
- main
branches: [ main ]
pull_request_target:
types: [opened, synchronize, reopened]

Expand All @@ -15,7 +14,7 @@ jobs:
codesee:
runs-on: ubuntu-latest
continue-on-error: true
name: Analyze the repo with CodeSee
name: Analyze repository
steps:
- uses: Codesee-io/codesee-action@v2
with:
Expand Down
Loading