Skip to content

Commit

Permalink
fix(ci): development version built in release pipeline (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
marfavi authored Dec 9, 2023
1 parent bc0fa26 commit c3a9b21
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 50 deletions.
43 changes: 25 additions & 18 deletions .github/actions/build_android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ inputs:
store_artifacts:
required: false
description: "Store artifact"
build_type:
required: false
default: "dev"
options:
- dev
- prod
signingKeyBase64:
required: true
description: "Android signing key b64"
Expand All @@ -28,10 +22,23 @@ inputs:
keyPassword:
required: true
description: "Android key password"
build_type:
required: true
description: >
Whether to build a development or production version of the app.
A 'development' build connects to the development backend for testing,
while a 'production' build connects to the production backend.
It is an error to specify a build type other than
'development' or 'production'.
runs:
using: "composite"
steps:
- name: Validate build_type
uses: ./.github/actions/verify_build_type
with:
build_type: ${{ inputs.build_type }}

- name: Setup Java
uses: actions/[email protected]
with:
Expand All @@ -41,17 +48,17 @@ runs:
- name: Setup Flutter environment
uses: ./.github/actions/setup_flutter_environment
with:
prod_release: ${{ inputs.prod_release }}
build_type: ${{ inputs.build_type }}

- name: Build apk (dev)
if: ${{ inputs.build_type == 'dev' }}
- name: "[dev] Build Android app (apk)"
if: ${{ inputs.build_type == 'development' }}
run: |
flutter build apk --flavor development --release --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_development.dart
mv build/app/outputs/flutter-apk/app-development-release.apk android.apk
shell: bash

- name: Build appbundle (prod)
if: ${{ inputs.build_type == 'prod' }}
- name: "[prod] Build Android app (app bundle)"
if: ${{ inputs.build_type == 'production' }}
run: |
flutter build appbundle --flavor production --release --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_production.dart
mv build/app/outputs/bundle/productionRelease/app-production-release.aab android.aab
Expand All @@ -68,26 +75,26 @@ runs:
keyStorePassword: ${{ inputs.keyStorePassword }}
keyPassword: ${{ inputs.keyPassword }}

- name: Upload appbundle
if: ${{ !!inputs.store_artifacts && inputs.build_type == 'prod'}}
- name: "[prod] Upload app bundle"
if: ${{ !!inputs.store_artifacts && inputs.build_type == 'production'}}
uses: actions/[email protected]
with:
name: android
path: android.aab
retention-days: 1
if-no-files-found: error

- name: Move apk
if: ${{ !!inputs.store_artifacts && inputs.build_type != 'prod'}}
- name: "[dev] Move apk file"
if: ${{ !!inputs.store_artifacts && inputs.build_type == 'development'}}
run: |
mv ${{steps.sign_app.outputs.signedReleaseFile}} android.apk
shell: bash

- name: Upload apk
if: ${{ !!inputs.store_artifacts && inputs.build_type != 'prod'}}
- name: "[dev] Upload apk"
if: ${{ !!inputs.store_artifacts && inputs.build_type == 'development'}}
uses: actions/[email protected]
with:
name: android
path: android.apk
retention-days: 1
if-no-files-found: error
if-no-files-found: error
33 changes: 20 additions & 13 deletions .github/actions/build_ios/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,24 @@ inputs:
required: true
description: "Store artifact"
build_type:
required: false
default: "dev"
options:
- dev
- prod
required: true
description: >
Whether to build a development or production version of the app.
A 'development' build connects to the development backend for testing,
while a 'production' build connects to the production backend.
It is an error to specify a build type other than
'development' or 'production'.
runs:
using: "composite"
steps:
- name: Install Apple certificate and provisioning profile
if: ${{ inputs.prod_release != 'true' }}
- name: Validate build_type
uses: ./.github/actions/verify_build_type
with:
build_type: ${{ inputs.build_type }}

- name: "[dev] Install Apple certificate and provisioning profile"
if: ${{ inputs.build_type == 'development' }}
run: .github/scripts/setup_certs.sh
env:
APPLE_IOS_SIGNING_CERT: ${{ inputs.apple_ios_signing_cert }}
Expand All @@ -45,15 +52,15 @@ runs:
- name: Setup Flutter environment
uses: ./.github/actions/setup_flutter_environment
with:
prod_release: ${{ inputs.build_type == 'prod' }}
build_type: ${{ inputs.build_type }}

- name: Build iOS (dev)
if: ${{ inputs.build_type != 'prod' }}
- name: "[dev] Build iOS app"
if: ${{ inputs.build_type == 'development' }}
run: .github/scripts/build_ios_dev.sh ${{ inputs.version }} ${{ inputs.build_version }}
shell: bash

- name: Build iOS (prod)
if: ${{ inputs.build_type == 'prod' }}
- name: "[prod] Build iOS app"
if: ${{ inputs.build_type == 'production' }}
run: .github/scripts/build_ios_prod.sh ${{ inputs.version }} ${{ inputs.build_version }}
shell: bash

Expand All @@ -64,4 +71,4 @@ runs:
name: ios
path: build-output/ios
retention-days: 1
if-no-files-found: error
if-no-files-found: error
28 changes: 17 additions & 11 deletions .github/actions/setup_flutter_environment/action.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
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
build_type:
required: true
description: >
Whether to build a development or production version of the app.
A 'development' build connects to the development backend for testing,
while a 'production' build connects to the production backend.
It is an error to specify a build type other than
'development' or 'production'.
runs:
using: "composite"
steps:
- name: Validate build_type
uses: ./.github/actions/verify_build_type
with:
build_type: ${{ inputs.build_type }}

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

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

- name: Replace target URI in Production
if: ${{ inputs.prod_release == 'true' }}
- name: "[prod] Change target backend to production"
if: ${{ inputs.build_type == 'production' }}
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
shell: bash
24 changes: 24 additions & 0 deletions .github/actions/verify_build_type/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Verify build type
description: Verify that the build type is either 'development' or 'production'

inputs:
build_type:
required: true
description: >
Whether to build a development or production version of the app.
A 'development' build connects to the development backend for testing,
while a 'production' build connects to the production backend.
It is an error to specify a build type other than
'development' or 'production'.
runs:
using: "composite"
steps:
- name: Validate build_type
run: |
if [[ "${{ inputs.build_type }}" != "development" && "${{ inputs.build_type }}" != "production" ]]; then
echo "Error: build_type must be 'development' or 'production'"
exit 1
fi
echo "Build type: ${{ inputs.build_type }}"
shell: bash
25 changes: 19 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@ on:
required: true
build_type:
type: string
required: false
default: "dev"
required: true
description: >
Whether to build a development or production version of the app.
A 'development' build connects to the development backend for testing,
while a 'production' build connects to the production backend.
It is an error to specify a build type other than
'development' or 'production'.
jobs:
version:
name: Versioning
runs-on: ubuntu-latest

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

- name: Validate build_type
uses: ./.github/actions/verify_build_type
with:
build_type: ${{ inputs.build_type }}

- name: Determine build version
id: build_version
run: |
Expand Down Expand Up @@ -51,8 +64,8 @@ jobs:
- name: Checkout code
uses: actions/[email protected]

- name: Build iOS app (dev)
if: ${{ inputs.build_type != 'prod' }}
- name: "[dev] Build iOS app"
if: ${{ inputs.build_type == 'development' }}
uses: ./.github/actions/build_ios
with:
version: ${{ needs.version.outputs.version }}
Expand All @@ -64,8 +77,8 @@ jobs:
store_artifacts: ${{ inputs.store_artifacts }}
build_type: ${{ inputs.build_type }}

- name: Build iOS app (prod)
if: ${{ inputs.build_type == 'prod' }}
- name: "[prod] Build iOS app"
if: ${{ inputs.build_type == 'production' }}
uses: ./.github/actions/build_ios
with:
version: ${{ needs.version.outputs.version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: ./.github/workflows/build.yml
with:
store_artifacts: true
build_type: "dev"
build_type: development
tag_name: ${{ github.head_ref }}
secrets: inherit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: ./.github/workflows/build.yml
with:
store_artifacts: true
build_type: "prod"
build_type: production
tag_name: ${{ github.event.release.tag_name }}
secrets: inherit

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

- name: Setup Flutter environment
uses: ./.github/actions/setup_flutter_environment
with:
build_type: development

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

0 comments on commit c3a9b21

Please sign in to comment.