sailfork / t3code-github / .github/ workflows/ mobile-showcase-screenshots.yml

name: Mobile Showcase Screenshots

on:
  workflow_dispatch:
    inputs:
      platform:
        description: Device platforms to capture
        required: true
        default: all
        type: choice
        options:
          - all
          - ios
          - android
      appearance:
        description: System appearances to capture
        required: true
        default: both
        type: choice
        options:
          - both
          - dark
          - light
      theme:
        description: Palette to capture (all multiplies the run by six)
        required: true
        default: t3-code
        type: choice
        options:
          - t3-code
          - t3-chat
          - grove
          - ocean
          - ember
          - iris
          - all

permissions:
  contents: read

env:
  NODE_OPTIONS: --max-old-space-size=8192

jobs:
  ios:
    name: iPhone, iPhone Duo, and iPad 13
    if: inputs.platform == 'all' || inputs.platform == 'ios'
    runs-on: blacksmith-12vcpu-macos-26
    # Capturing every palette multiplies the device matrix by six, and only the
    # one native build is shared between them.
    timeout-minutes: ${{ inputs.theme == 'all' && 300 || 60 }}
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          sparse-checkout: |
            /*
            !/.repos/
          sparse-checkout-cone-mode: false

      - name: Setup Vite+
        uses: voidzero-dev/setup-vp@v1
        with:
          node-version-file: package.json
          cache: true
          run-install: |
            args:
              - --filter=@t3tools/mobile...
              - --filter=@t3tools/scripts...
              - --filter=t3...

      - name: Expose pnpm
        run: |
          pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
          vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
          echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
          "$vp_pnpm_bin/pnpm" --version

      - name: Install AXe
        # Locks the simulator and answers the notification prompt for the
        # agent-activity scene.
        # Homebrew refuses third-party tap formulae until they are trusted;
        # older releases have no trust command and install them as is.
        run: |
          brew tap cameroncooke/axe
          if brew commands | grep -qx trust; then brew trust --formula cameroncooke/axe/axe; fi
          brew install cameroncooke/axe/axe
          axe --version

      - name: Install foldable simulator controls
        run: npm install --global agent-device@0.21.25

      - name: Capture iOS showcase
        run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"

      - name: Validate App Store Connect assets
        run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}" --validate-only

      - name: Upload iOS screenshots
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: app-store-connect-screenshots
          path: artifacts/app-store/screenshots/apple/
          if-no-files-found: warn
          retention-days: 14

  android:
    name: Android phone, 7-inch tablet, and 10-inch tablet
    if: inputs.platform == 'all' || inputs.platform == 'android'
    runs-on: blacksmith-16vcpu-ubuntu-2404
    # Capturing every palette multiplies the device matrix by six, and only the
    # one native build is shared between them.
    timeout-minutes: ${{ inputs.theme == 'all' && 300 || 60 }}
    env:
      T3_SHOWCASE_ANDROID_ABI: x86_64
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          sparse-checkout: |
            /*
            !/.repos/
          sparse-checkout-cone-mode: false

      - name: Setup Vite+
        uses: voidzero-dev/setup-vp@v1
        with:
          node-version-file: package.json
          cache: true
          run-install: |
            args:
              - --filter=@t3tools/mobile...
              - --filter=@t3tools/scripts...
              - --filter=t3...

      - name: Expose pnpm
        run: |
          pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
          vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
          echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
          "$vp_pnpm_bin/pnpm" --version

      - name: Setup Java
        uses: actions/setup-java@v5
        with:
          distribution: temurin
          java-version: 17

      - name: Setup Gradle cache
        uses: gradle/actions/setup-gradle@v5

      - name: Enable KVM
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS="static_node=kvm"' \
            | sudo tee /etc/udev/rules.d/99-kvm4all.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm

      - name: Capture Android showcase
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 36
          target: google_apis
          arch: x86_64
          profile: pixel_7_pro
          avd-name: Pixel_10_Pro
          cores: 8
          ram-size: 4096M
          disable-animations: false
          script: pnpm screenshots:mobile --platform android --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"

      - name: Validate Google Play assets
        run: pnpm screenshots:mobile --platform android --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}" --validate-only

      - name: Upload Android screenshots
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: google-play-screenshots
          path: artifacts/app-store/screenshots/google-play/
          if-no-files-found: warn
          retention-days: 14