Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fremartini committed Oct 13, 2023
1 parent b18b921 commit 005dcd2
Show file tree
Hide file tree
Showing 11 changed files with 465 additions and 287 deletions.
55 changes: 55 additions & 0 deletions .github/actions/build_android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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"

runs:
using: "composite"
steps:
- name: Setup Flutter environment
uses: ./.github/actions/setup_flutter_environment

- name: Replace target URI in Production
if: github.ref_name == 'production'
run: sed -i 's/.env.develop/.env.production/' lib/env/env.dart
shell: bash

- name: Generate code
run: dart run build_runner build
shell: bash

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

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

- name: Upload Android build (dev)
if: ${{ !!inputs.store_artifacts && github.ref_name != 'production'}}
uses: actions/[email protected]
with:
name: android
path: build/app/outputs/flutter-apk
retention-days: 1
if-no-files-found: error

- name: Upload Android build (prod)
if: ${{ !!inputs.store_artifacts && github.ref_name == 'production'}}
uses: actions/[email protected]
with:
name: android
path: build/app/outputs/bundle/release
retention-days: 1
if-no-files-found: error
119 changes: 119 additions & 0 deletions .github/actions/build_ios/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build iOS app
description: Build and upload iOS app
inputs:
version:
required: true
description: "App version"
build_version:
required: true
description: "Build version"
apple_ios_signing_cert_dev:
required: true
description: "iOS signing certificate"
apple_ios_signing_cert_pw_dev:
required: true
description: "iOS signing certificate password"
apple_ios_provisioning_profile_dev:
required: true
description: "Provisioning profile"
apple_ios_signing_cert_prod:
required: true
description: "TODO"
apple_ios_signing_cert_pw_prod:
required: true
description: "TODO"
apple_ios_provisioning_profile_prod:
required: true
description: "TODO"
apple_keychain_pw:
required: true
description: "Keychain password"
store_artifacts:
required: false
description: "Store artifact"

runs:
using: "composite"
steps:
- name: Install Apple certificate and provisioning profile (dev)
if: github.ref_name != 'production'
run: .github/scripts/setup-certs.command
env:
APPLE_IOS_SIGNING_CERT: ${{ inputs.apple_ios_signing_cert_dev }}
APPLE_IOS_SIGNING_CERT_PW: ${{ inputs.apple_ios_signing_cert_pw_dev }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ inputs.apple_ios_provisioning_profile_dev }}
APPLE_KEYCHAIN_PW: ${{ inputs.apple_keychain_pw }}
shell: bash

- name: Install Apple certificate and provisioning profile (prod)
if: github.ref_name == 'production'
run: .github/scripts/setup-certs.command
env:
APPLE_IOS_SIGNING_CERT: ${{ inputs.apple_ios_signing_cert_prod }}
APPLE_IOS_SIGNING_CERT_PW: ${{ inputs.apple_ios_signing_cert_pw_prod }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ inputs.apple_ios_provisioning_profile_prod }}
APPLE_KEYCHAIN_PW: ${{ inputs.apple_keychain_pw }}
shell: bash

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

- name: Set URI (prod)
if: github.ref_name == 'production'
run: sed -i '' 's/.env.develop/.env.production/' lib/env/env.dart
shell: bash

- name: Generate code
run: dart run build_runner build
shell: bash

- name: Build iOS (dev)
if: github.ref_name != 'production'
run: flutter build ios --flavor development --release --no-codesign --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_development.dart
shell: bash

- name: Build iOS (prod)
if: github.ref_name == 'production'
run: flutter build ios --flavor production --release --no-codesign --build-name ${{ inputs.version }} --build-number ${{ inputs.build_version }} --target lib/main_production.dart
shell: bash

- name: Build resolve Swift dependencies (dev)
if: github.ref_name != 'production'
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development
shell: bash

- name: Build resolve Swift dependencies (prod)
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production
if: github.ref_name == 'production'
shell: bash

- name: Build xArchive (dev)
if: github.ref_name != 'production'
run: |
xcodebuild -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="development" clean archive CODE_SIGN_IDENTITY="iPhone Developer"
shell: bash

- name: Build xArchive (prod)
if: github.ref_name == 'production'
run: |
xcodebuild -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="githubactions-prod" clean archive CODE_SIGN_IDENTITY="Apple Distribution"
shell: bash

- name: Export ipa (dev)
if: github.ref_name != 'production'
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.dev.plist
shell: bash

- name: Export ipa (prod)
if: github.ref_name == 'production'
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.prod.plist
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
18 changes: 18 additions & 0 deletions .github/actions/setup_flutter_environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Setup Flutter environment
description: Setup the Flutter environment

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
61 changes: 61 additions & 0 deletions .github/actions/upload_android/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Upload Android app
description: Upload Android app
inputs:
firebase_android_app_id:
required: true
description: "Firebase Android app id"
firebase_token:
required: true
description: "Firebase token"
android_signing_key:
required: true
description: "Android signing key"
android_key_alias:
required: true
description: "Android key alias"
android_keystore_password:
required: true
description: "Android keystore password"
android_Key_password:
required: true
description: "Android key password"
playstore_service_account:
required: true
description: "Playstore service account json"

runs:
using: "composite"
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: android

- name: Firebase App Distribution
uses: ./.github/actions/upload_to_firebase
with:
firebase_app_id: ${{ inputs.firebase_android_app_id }}
firebase_token: ${{ inputs.firebase_token }}
file: app-development-release.apk
if: github.ref_name != 'production'

- name: Sign Android appbundle
uses: r0adkll/sign-android-release@v1
id: sign_app
with:
releaseDirectory: .
signingKeyBase64: ${{ inputs.android_signing_key }}
alias: ${{ inputs.android_key_alias }}
keyStorePassword: ${{ inputs.android_keystore_password }}
keyPassword: ${{ inputs.android_key_password }}
if: github.ref_name == 'production'

- name: Upload to Google Play Store
uses: r0adkll/[email protected]
with:
serviceAccountJsonPlainText: ${{ inputs.playstore_service_account }}
packageName: dk.analog.digitalclipcard
releaseFiles: ${{ steps.sign_app.outputs.signedReleaseFile }}
track: internal
status: draft
if: github.ref_name == 'production'
40 changes: 40 additions & 0 deletions .github/actions/upload_ios/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Upload iOS app
description: Upload iOS app
inputs:
app_store_connect_username:
required: true
description: "App Store Connect username"
app_store_connect_password:
required: true
description: "App Store Connect password"
firebase_ios_app_id:
required: true
description: "Firebase iOS app id"
firebase_token:
required: true
description: "Firebase token"

runs:
using: "composite"
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: ios

- name: Upload to Firebase App Distribution
uses: ./.github/actions/upload_to_firebase
with:
firebase_app_id: ${{ inputs.firebase_ios_app_id }}
firebase_token: ${{ inputs.firebase_token }}
file: Analog.ipa
if: github.ref_name != 'production'

- name: Upload to App Store Connect
env:
APP_STORE_CONNECT_USERNAME: ${{ inputs.app_store_connect_username }}
APP_STORE_CONNECT_PASSWORD: ${{ inputs.app_store_connect_password }}
run: |
xcrun altool --upload-app -t ios -f "Analog.ipa" -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD"
shell: bash
if: github.ref_name == 'production'
23 changes: 23 additions & 0 deletions .github/actions/upload_to_firebase/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Upload to Firebase
description: Upload a file to Firebase App Distribution
inputs:
firebase_app_id:
required: true
description: "Firebase app id"
firebase_token:
required: true
description: "Firebase token"
file:
required: true
description: "File to upload"

runs:
using: "composite"
steps:
- name: Upload to Firebase App Distribution
uses: wzieba/[email protected]
with:
appId: ${{ inputs.firebase_ios_app_id }}
token: ${{ inputs.firebase_token }}
groups: analogio-devs
file: ${{ inputs.file }}
49 changes: 49 additions & 0 deletions .github/actions/versioning/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Version
description: Determine version

outputs:
version:
description: "Version (2.x.x)"
value: ${{ steps.versioning.outputs.version }}
version_tag:
description: "Version tag (v2.x.x)"
value: ${{ steps.versioning.outputs.version_tag }}
build_version:
description: "Build version (7xx)"
value: ${{ steps.build_version.outputs.build_no }}

runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Determine versioning
uses: paulhatch/[email protected]
id: versioning
with:
tag_prefix: "v"
major_pattern: "(MAJOR)"
minor_pattern: "(MINOR)"
format: "${major}.${minor}.${patch}"
bump_each_commit: false

- name: Determine build version
id: build_version
run: |
BUILD_NO=$((${{ github.run_number }} + 100))
echo "::set-output name=build_no::$BUILD_NO"
shell: bash

- name: Print versioning
run: |
echo "Version: $VERSION"
echo "Version Tag: $VERSION_TAG"
echo "Run No: $BUILD_NO"
env:
VERSION: ${{ steps.versioning.outputs.version }}
VERSION_TAG: ${{ steps.versioning.outputs.version_tag }}
BUILD_NO: ${{ steps.build_version.outputs.build_no }}
shell: bash
Loading

0 comments on commit 005dcd2

Please sign in to comment.