Skip to content

Flutter Branch Workflow #13

Flutter Branch Workflow

Flutter Branch Workflow #13

name: Flutter Branch Workflow
env:
ENVIRONMENT_FILE: .env
on:
workflow_call:
inputs:
ios-build-arguments:
description: "any extra arguments such as using sksl or passing a variable using --dart-define etc. for iOS build"
type: string
required: false
android-build-arguments:
description: "any extra arguments such as using sksl or passing a variable using --dart-define etc. for Android build"
type: string
required: false
publish-to-testflight:
description: "Should publish to Testflight?"
type: boolean
default: true
working-directory:
description: "the directory to run each job of the workflow in"
type: string
default: "."
artifact-name-suffix:
description: "the suffix to add to the artifact name"
type: string
default: ""
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
generate-build-number:
runs-on: [self-hosted]
outputs:
build-number: ${{ steps.build-number-generator.outputs.build-number }}
steps:
- name: Generate Build Number
id: build-number-generator
run: |
build_number=$(date +%s)
echo "build-number=$build_number" >> $GITHUB_OUTPUT
echo "Build Number: $build_number"
name-suffix-generation:
runs-on: [self-hosted]
outputs:
name-suffix: ${{ steps.name-suffix-generator.outputs.name-suffix }}
steps:
- name: Generate Name Suffix
id: name-suffix-generator
shell: bash
run: |
if [[ '${{ inputs.artifact-name-suffix }}' != '' ]]; then
echo "name-suffix=${{ inputs.artifact-name-suffix }}-" >> $GITHUB_OUTPUT
else
echo "name-suffix=" >> $GITHUB_OUTPUT
fi
lint:
runs-on: [self-hosted]
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- uses: QuickBirdEng/actions/checkout-ssh@main
with:
ssh-private-key: ${{ secrets.CI_SSH_PRIVATE_KEY_FOR_GITHUB_PRIVATE_REPOS }}
- uses: QuickBirdEng/actions/setup-flutter@main
with:
working-directory: ${{ inputs.working-directory }}
- run: flutter analyze
test:
runs-on: [self-hosted]
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- uses: QuickBirdEng/actions/checkout-ssh@main
with:
ssh-private-key: ${{ secrets.CI_SSH_PRIVATE_KEY_FOR_GITHUB_PRIVATE_REPOS }}
- uses: QuickBirdEng/actions/setup-flutter@main
with:
working-directory: ${{ inputs.working-directory }}
- run: flutter test --dart-define STAGE=mock
android-publish:
runs-on: [self-hosted, Linux]
needs: [generate-build-number, lint, test]
steps:
- uses: QuickBirdEng/actions/checkout-ssh@main
with:
ssh-private-key: ${{ secrets.CI_SSH_PRIVATE_KEY_FOR_GITHUB_PRIVATE_REPOS }}
- uses: QuickBirdEng/actions/publish-android@main
with:
clean: true
build-number: ${{ needs.generate-build-number.outputs.build-number }}
build-arguments: ${{ inputs.android-build-arguments }}
working-directory: ${{ inputs.working-directory }}
key-store-file-content: ${{ secrets.ANDROID_KEYSTORE_FILE_CONTENT }}
key-store-password: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
signing-key-alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
signing-key-password: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
qbs-maven-username: ${{ secrets.QBS_DEV_MAVEN_USERNAME }}
qbs-maven-password: ${{ secrets.QBS_DEV_MAVEN_PASSWORD }}
upload-key: ${{ secrets.UPLOAD_KEY }}
ios-publish:
runs-on: [self-hosted, macOS]
needs: [generate-build-number, lint, test, name-suffix-generation]
steps:
- uses: QuickBirdEng/actions/checkout-ssh@main
with:
ssh-private-key: ${{ secrets.CI_SSH_PRIVATE_KEY_FOR_GITHUB_PRIVATE_REPOS }}
- uses: QuickBirdEng/actions/setup-ios@main
- uses: QuickBirdEng/actions/flutter-build@main
id: build
with:
build-type: ipa
build-number: ${{ needs.generate-build-number.outputs.build-number }}
build-arguments: --no-codesign ${{ inputs.ios-build-arguments }}
clean: true
working-directory: ${{ inputs.working-directory }}
- uses: QuickBirdEng/actions/publish-ios@main
with:
apple-auth-key-id: ${{ secrets.APPLE_AUTH_KEY_ID }}
apple-auth-key-issuer-id: ${{ secrets.APPLE_AUTH_KEY_ISSUER_ID }}
apple-auth-key-content: ${{ secrets.APPLE_AUTH_KEY_CONTENT }}
apple-auth-key-encoding: "base64"
upload-key: ${{ secrets.UPLOAD_KEY }}
publish-to-testflight: ${{ inputs.publish-to-testflight }}
match-password: ${{ secrets.MATCH_PASSWORD }}
match-repository: ${{ secrets.MATCH_REPO }}
match-apple-id: ${{ secrets.APPLE_ID }}
match-apple-team-id: ${{ secrets.APPLE_TEAM_ID }}
match-keychain-password: ${{ secrets.FASTLANE_KEYCHAIN_PASSWORD }}
build-number: ${{ needs.generate-build-number.outputs.build-number }}
slack-slug: ${{ secrets.SLACK_SLUG }}
working-directory: ${{ inputs.working-directory }}
- name: Compress & Upload Artifact to QB Spaces
uses: QuickBirdEng/actions/compress-and-upload-artifact-qb@main
with:
access-key: ${{ secrets.DO_ACCESS_KEY }}
secret-key: ${{ secrets.DO_SECRET_KEY }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
name-suffix: ${{ needs.name-suffix-generation.outputs.name-suffix }}ios
artifact-path: ${{ steps.build.outputs.artifact-path }}
android-bundle:
runs-on: [self-hosted, Linux]
needs: [generate-build-number, lint, test, name-suffix-generation]
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: QuickBirdEng/actions/checkout-ssh@main
with:
ssh-private-key: ${{ secrets.CI_SSH_PRIVATE_KEY_FOR_GITHUB_PRIVATE_REPOS }}
- uses: QuickBirdEng/actions/setup-android@main
with:
key-store-file-content: ${{ secrets.ANDROID_KEYSTORE_FILE_CONTENT }}
key-store-password: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
signing-key-alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
signing-key-password: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
qbs-maven-username: ${{ secrets.QBS_DEV_MAVEN_USERNAME }}
qbs-maven-password: ${{ secrets.QBS_DEV_MAVEN_PASSWORD }}
- uses: QuickBirdEng/actions/flutter-build@main
id: flutter-build
with:
clean: true
build-type: appbundle
build-number: ${{ needs.generate-build-number.outputs.build-number }}
build-arguments: ${{ inputs.android-build-arguments }}
working-directory: ${{ inputs.working-directory }}
- name: Compress & Upload Artifact to QB Spaces
uses: QuickBirdEng/actions/compress-and-upload-artifact-qb@main
with:
access-key: ${{ secrets.DO_ACCESS_KEY }}
secret-key: ${{ secrets.DO_SECRET_KEY }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
name-suffix: ${{ needs.name-suffix-generation.outputs.name-suffix }}android
artifact-path: ${{ steps.flutter-build.outputs.artifact-path }}