Bump dawidd6/action-download-artifact from 16 to 19 #87
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # This workflow is triggered on pull request closure for the 'develop' branch. | |
| # It is responsible for building the Android app, running tests, and uploading artifacts. | |
| # It also manages versioning based on labels applied to the pull request. | |
| # | |
| # The versioning works as follows: | |
| # - If the pull request is merged and has labels 'minor' or 'patch', it will bump the version accordingly with build number. | |
| # For example, if the current version is 1.0.0+5 and the label is 'patch', it will become 1.0.1+6. | |
| # - If the pull request is merged and has no labels, it will bump the build number only. | |
| # For example, if the current version is 1.0.0+5, it will become 1.0.0+6. | |
| # - If the pull request is merged and has the label 'no-build', it will skip the build process. | |
| # | |
| name: develop-workflow | |
| on: | |
| pull_request: | |
| branches: ["develop"] | |
| types: | |
| - closed | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: Version bump type for the develop build | |
| required: true | |
| default: none | |
| type: choice | |
| options: | |
| - none | |
| - patch | |
| - minor | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| preBuild: | |
| name: Prebuild - Version Management | |
| if: ${{ github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'no-build') == false) }} | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: build-group | |
| cancel-in-progress: false | |
| outputs: | |
| version_number: ${{ steps.version_management.outputs.version_number }} | |
| version_part: ${{ steps.version_management.outputs.version_part }} | |
| build_number: ${{ steps.version_management.outputs.build_number }} | |
| steps: | |
| ############################################## | |
| # Checkout Repository | |
| ############################################## | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ############################################## | |
| # Generate GitHub App Token | |
| ############################################## | |
| - name: Generate GitHub App Token | |
| id: generate_token | |
| uses: peter-murray/workflow-application-token-action@v4 | |
| with: | |
| application_id: ${{ secrets.VERSION_BOT_APP_ID }} | |
| application_private_key: ${{ secrets.VERSION_BOT_APP_PRIVATE_KEY }} | |
| ############################################## | |
| # Check Version Labels | |
| ############################################## | |
| - name: Check Version Labels | |
| id: check_labels | |
| if: github.event_name == 'pull_request' | |
| uses: ./.github/actions/check-version-labels | |
| with: | |
| labels: ${{ toJson(github.event.pull_request.labels) }} | |
| allowed_labels: "minor,patch" | |
| no_build_label: "no-build" | |
| ############################################## | |
| # Resolve Bump Type | |
| ############################################## | |
| - name: Resolve Bump Type | |
| id: resolve_bump_type | |
| shell: bash | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| MANUAL_BUMP_TYPE: ${{ inputs.bump_type }} | |
| LABEL_BUMP_TYPE: ${{ steps.check_labels.outputs.bump_type }} | |
| run: | | |
| if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then | |
| echo "bump_type=$MANUAL_BUMP_TYPE" >> "$GITHUB_OUTPUT" | |
| echo "Using manual bump type: $MANUAL_BUMP_TYPE" | |
| else | |
| echo "bump_type=$LABEL_BUMP_TYPE" >> "$GITHUB_OUTPUT" | |
| echo "Using PR label bump type: $LABEL_BUMP_TYPE" | |
| fi | |
| ############################################## | |
| # Version Management | |
| ############################################## | |
| - name: Version Management | |
| id: version_management | |
| uses: ./.github/actions/version-management | |
| with: | |
| github_token: ${{ steps.generate_token.outputs.token }} | |
| pubspec_path: apps/multichoice/pubspec.yaml | |
| branch_name: develop | |
| bump_type: ${{ steps.resolve_bump_type.outputs.bump_type }} | |
| build: | |
| name: Builds Android App | |
| needs: [preBuild] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: read | |
| statuses: write | |
| steps: | |
| ############################################## | |
| # Checkout Repository | |
| ############################################## | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| ############################################## | |
| # Set up Flutter and Java | |
| ############################################## | |
| - name: Set up Flutter and Java | |
| uses: ./.github/actions/setup-flutter-with-java | |
| ############################################## | |
| # Melos Coverage for Core | |
| ############################################## | |
| - name: Melos Coverage for Core | |
| run: melos coverage:core | |
| - name: Upload Coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: packages/core/coverage/lcov.info | |
| fail_ci_if_error: true | |
| ############################################## | |
| # Download and Prepare Android Keystore, Key Properties, Secrets Dart, Google Services | |
| ############################################## | |
| - name: Download Android Keystore File | |
| id: android_keystore | |
| uses: timheuer/base64-to-file@v1.2.4 | |
| with: | |
| fileName: upload-keystore.jks | |
| encodedString: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| - name: Create key.properties File | |
| run: | | |
| echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > key.properties | |
| echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> key.properties | |
| working-directory: apps/multichoice/android/ | |
| - name: Create secrets.dart File | |
| run: | | |
| mkdir auth | |
| echo "String webApiKey = '${{ secrets.WEB_API_KEY }}';" > auth/secrets.dart | |
| echo "String webAppId = '${{ secrets.WEB_APP_ID }}';" >> auth/secrets.dart | |
| echo "String androidApiKey = '${{ secrets.ANDROID_API_KEY }}';" >> auth/secrets.dart | |
| echo "String androidAppId = '${{ secrets.ANDROID_APP_ID }}';" >> auth/secrets.dart | |
| echo "String iosApiKey = '${{ secrets.IOS_API_KEY }}';" >> auth/secrets.dart | |
| echo "String iosAppId = '${{ secrets.IOS_APP_ID }}';" >> auth/secrets.dart | |
| working-directory: apps/multichoice/lib/ | |
| - name: Create and Validate google-services.json file | |
| working-directory: apps/multichoice/android/app/ | |
| env: | |
| ANDROID_APP_ID: ${{ secrets.ANDROID_APP_ID }} | |
| ANDROID_API_KEY: ${{ secrets.ANDROID_API_KEY }} | |
| run: | | |
| set -euo pipefail | |
| printf '%s' "${{ secrets.GOOGLE_SERVICES_JSON_B64 }}" | base64 --decode > google-services.json | |
| python3 - <<'PY' | |
| import json | |
| import os | |
| with open('google-services.json', encoding='utf-8') as f: | |
| config = json.load(f) | |
| package_name = 'co.za.zanderkotze.multichoice' | |
| matching_clients = [ | |
| client for client in config.get('client', []) | |
| if client.get('client_info', {}).get('android_client_info', {}).get('package_name') == package_name | |
| ] | |
| if not matching_clients: | |
| raise SystemExit(f'google-services.json does not contain package {package_name}.') | |
| client = matching_clients[0] | |
| mobilesdk_app_id = client.get('client_info', {}).get('mobilesdk_app_id') | |
| if mobilesdk_app_id != os.environ['ANDROID_APP_ID']: | |
| raise SystemExit( | |
| 'ANDROID_APP_ID secret does not match google-services.json ' | |
| f'({os.environ["ANDROID_APP_ID"]} != {mobilesdk_app_id}).' | |
| ) | |
| api_keys = client.get('api_key', []) | |
| if not api_keys: | |
| raise SystemExit('google-services.json does not contain an Android API key.') | |
| current_api_key = api_keys[0].get('current_key') | |
| if current_api_key != os.environ['ANDROID_API_KEY']: | |
| raise SystemExit( | |
| 'ANDROID_API_KEY secret does not match google-services.json ' | |
| f'({os.environ["ANDROID_API_KEY"]} != {current_api_key}).' | |
| ) | |
| print('google-services.json parsed and validated successfully.') | |
| PY | |
| ############################################## | |
| # Build APK | |
| ############################################## | |
| - name: Build APK | |
| env: | |
| FLUTTER_BUILD_NAME: ${{ needs.preBuild.outputs.version_part }} | |
| FLUTTER_BUILD_NUMBER: ${{ needs.preBuild.outputs.build_number }} | |
| run: flutter build apk --release --build-name=${{ env.FLUTTER_BUILD_NAME }} --build-number=${{ env.FLUTTER_BUILD_NUMBER }} | |
| working-directory: apps/multichoice/ | |
| ############################################## | |
| # Upload APK as Artifact | |
| ############################################## | |
| - name: Upload Android App Bundle | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: "android-release-apk" | |
| path: ./apps/multichoice/build/app/outputs/flutter-apk/app-release.apk | |
| ############################################## | |
| # Build App Bundle | |
| ############################################## | |
| - name: Build App Bundle | |
| env: | |
| FLUTTER_BUILD_NAME: ${{ needs.preBuild.outputs.version_part }} | |
| FLUTTER_BUILD_NUMBER: ${{ needs.preBuild.outputs.build_number }} | |
| run: flutter build appbundle --release --build-name=${{ env.FLUTTER_BUILD_NAME }} --build-number=${{ env.FLUTTER_BUILD_NUMBER }} | |
| working-directory: apps/multichoice/ | |
| ############################################## | |
| # Upload App Bundle as Artifact | |
| ############################################## | |
| - name: Upload Android App Bundle | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: "android-release-appbundle" | |
| path: ./apps/multichoice/build/app/outputs/bundle/release/app-release.aab | |
| ############################################## | |
| # Upload APK to Firebase App Distribution | |
| ############################################## | |
| - name: Upload APK to Firebase App Distribution | |
| uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
| with: | |
| appId: ${{ secrets.APP_ID }} | |
| serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} | |
| groups: testers | |
| file: ./apps/multichoice/build/app/outputs/flutter-apk/app-release.apk | |
| releaseNotesFile: ./CHANGELOG.md | |
| debug: true | |
| ############################################## | |
| # Create New Tag | |
| ############################################## | |
| - name: Create New Tag | |
| uses: ./.github/actions/create-git-tag | |
| with: | |
| version_number: ${{ needs.preBuild.outputs.version_number }} | |
| tag_strategy: "full" | |
| allowed_formats: "both" |