name: Reusable Build Logic permissions: contents: read packages: write on: workflow_call: inputs: ref: required: true type: string pr_number: required: true type: string defaults: run: shell: bash env: CW_DOCKER_REGISTRY: ghcr.io/cake-tech/cake_wallet CW_DOCKER_USE_CLOUD: "true" jobs: base: runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build base run: ./scripts/android/docker/build.sh --only base bitbox: needs: base runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build bitbox run: ./scripts/android/docker/build.sh --only bitbox mwebd: needs: base runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build mwebd run: ./scripts/android/docker/build.sh --only mwebd reown: needs: base runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build reown run: ./scripts/android/docker/build.sh --only reown zcash: needs: base runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build zcash run: ./scripts/android/docker/build.sh --only zcash torch: needs: base runs-on: puzl-ubuntu-latest timeout-minutes: 360 strategy: matrix: target: - aarch64-linux-android - armv7a-linux-androideabi - x86_64-linux-android steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build torch run: ./scripts/android/docker/build.sh --only torch --target ${{ matrix.target }} torch_merge: needs: torch runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Merge torch run: ./scripts/android/docker/build.sh --only torch --merge monero: needs: base runs-on: puzl-ubuntu-latest timeout-minutes: 360 strategy: matrix: coin: [monero, wownero, zano] target: - aarch64-linux-android - armv7a-linux-androideabi - x86_64-linux-android steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build monero run: ./scripts/android/docker/build.sh --only monero --coin ${{ matrix.coin }} --target ${{ matrix.target }} monero_merge: needs: monero runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Merge monero run: ./scripts/android/docker/build.sh --only monero --merge decred: needs: [base, torch_merge] runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build decred run: ./scripts/android/docker/build.sh --only decred final: needs: [bitbox, mwebd, reown, zcash, torch_merge, monero_merge, decred] runs-on: puzl-ubuntu-latest timeout-minutes: 360 steps: - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build final run: ./scripts/android/docker/build.sh --only final integration-test: needs: final uses: ./.github/workflows/reusable-integration-test.yml with: ref: ${{ inputs.ref }} suite_dir: integration_test/suites test_tier: tier0 slack_notify: true extract_only: true secrets: inherit app: needs: final runs-on: puzl-ubuntu-latest timeout-minutes: 360 container: image: ghcr.io/cake-tech/cake_wallet:debian13-flutter3.41.9-ndkr28-go1.24.1-ruststablenightly env: STORE_PASS: test@cake_wallet KEY_PASS: test@cake_wallet BRANCH_NAME: ${{ github.head_ref || github.ref_name }} volumes: - /var/run/docker.sock:/var/run/docker.sock steps: - name: Fix github actions messing up $HOME... run: "echo HOME=/root | sudo tee -a $GITHUB_ENV" - uses: actions/checkout@v4 if: ${{ env.ACT != 'true' }} with: ref: ${{ inputs.ref }} - name: Docker sock permissions run: sudo chmod 666 /var/run/docker.sock || true - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Get the full commit message run: | FULL_MESSAGE="$(git log -1 --pretty=%B)" echo "message<> $GITHUB_ENV echo "$FULL_MESSAGE" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - name: Add secrets run: | touch cw_bitcoin/lib/.secrets.g.dart touch cw_evm/lib/.secrets.g.dart touch cw_solana/lib/.secrets.g.dart touch cw_core/lib/.secrets.g.dart touch cw_nano/lib/.secrets.g.dart touch cw_tron/lib/.secrets.g.dart echo "const polygonScanApiKey = '${{ secrets.POLYGON_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart echo "const etherScanApiKey = '${{ secrets.ETHER_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart echo "const nowNodesApiKey = '${{ secrets.EVM_NOWNODES_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart echo "const blinkApiKey = '${{ secrets.BLINK_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart echo "const alchemyApiKey = '${{ secrets.ALCHEMY_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart echo "const ankrApiKey = '${{ secrets.ANKR_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart echo "const chainStackApiKey = '${{ secrets.CHAIN_STACK_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart echo "const nano2ApiKey = '${{ secrets.NANO2_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart echo "const nanoNowNodesApiKey = '${{ secrets.NANO_NOW_NODES_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart echo "const tronGridApiKey = '${{ secrets.TRON_GRID_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart echo "const tronNowNodesApiKey = '${{ secrets.TRON_NOW_NODES_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart echo "const breezApiKey = '${{ secrets.BREEZ_API_KEY }}';" >> cw_bitcoin/lib/.secrets.g.dart echo "${{ secrets.MAIN_SECRETS_FILE }}" | base64 --decode > lib/.secrets.g.dart - name: Generate KeyStore run: | ./scripts/android/generate_dev_keystore.sh android/app/key.jks - name: Extract native dependencies run: ./scripts/android/docker/build.sh --extract - name: Execute Build and Setup Commands run: | pushd scripts/android source ./app_env.sh cakewallet export GITHUB_HUH=yeah ./app_config.sh popd - name: Install Flutter dependencies run: | flutter pub get - name: Build generated code run: | ./model_generator.sh - name: Generate key properties run: | dart run tool/generate_android_key_properties.dart keyAlias=testKey storeFile=key.jks storePassword=$STORE_PASS keyPassword=$KEY_PASS - name: Generate localization run: | dart run tool/generate_localization.dart - name: Compile graphics run: | ./compile_graphics.sh - name: Rename app run: | sanitized_branch_name=${BRANCH_NAME#origin/} # Remove 'origin/' prefix if it exists sanitized_branch_name=${sanitized_branch_name:0:16} # Take only the first 16 characters sanitized_branch_name=$(echo "$sanitized_branch_name" | tr '[:upper:]' '[:lower:]') # Convert to lowercase sanitized_branch_name=$(echo "$sanitized_branch_name" | sed 's/[^a-z0-9]//g') # Remove all special characters echo -e "id=com.cakewallet.test_${sanitized_branch_name}\nname=${BRANCH_NAME}" > android/app.properties - name: Replace email address run: | PATTERN1="support@cakewallet.com" PATTERN1REP="dev.testflight.cakewallet@mrcyjanek.net" echo lib/utils/exception_handler.dart \ lib/view_model/support_view_model.dart \ | while IFS= read -r -d '' file; do sed -i.bak \ -e "s|$PATTERN1|$PATTERN1REP|g" \ "$file" done - name: Build run: | export ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION" export ANDROID_NDK="$ANDROID_NDK_HOME" pushd $ANDROID_SDK_ROOT/ndk ln -s 28.2.13676358 25.1.8937393 popd flutter build apk --dart-define=hasDevOptions=true \ --dart-define=CI_COMMIT="$(git rev-parse HEAD)" \ --dart-define=CI_BRANCH="$BRANCH_NAME" \ --release --split-per-abi - name: Rename apk file run: | sanitized_branch_name=$(grep '^id=' android/app.properties | cut -d'=' -f2 | sed 's/com\.cakewallet\.test_//') cd build/app/outputs/flutter-apk mkdir test-apk cp app-arm64-v8a-release.apk test-apk/${sanitized_branch_name}.apk cp app-x86_64-release.apk test-apk/${sanitized_branch_name}_x86.apk - name: Find APK file id: find_apk run: | set -x sanitized_branch_name=$(grep '^id=' android/app.properties | cut -d'=' -f2 | sed 's/com\.cakewallet\.test_//') apk_file=$(ls build/app/outputs/flutter-apk/test-apk/${sanitized_branch_name}.apk || exit 1) echo "APK_FILE=$apk_file" >> $GITHUB_ENV - name: Write BRANCH_NAME to env run: echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV - name: Upload to slack step uses: vaporif/slack-file-upload-action@v1 with: token: ${{ secrets.SLACK_APP_TOKEN }} initial_comment: ${{ env.message }} files: > [ {"file": "${{ env.APK_FILE }}", "filename": "${{ env.BRANCH_NAME }}.apk"} ] channel_id: ${{ secrets.SLACK_APK_CHANNEL }} - name: cleanup run: rm -rf build/app/outputs/flutter-apk/test-apk/ - name: Upload Artifact to github uses: actions/upload-artifact@v4 with: path: ${{ github.workspace }}/build/app/outputs/flutter-apk name: "android apk" - name: 16KB align run: | cd build/app/outputs/flutter-apk for i in arm64-v8a x86_64; do ../../../../scripts/android/check_16kb_align.sh app-$i-release.apk done