# SPDX-FileCopyrightText: 2022 yuzu Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later

name: 'yuzu verify'

on:
  # workflow_call:
    # inputs:
      # from_ci:
        # type: boolean
        # required: false
        # default: true
  workflow_dispatch:

jobs:
  codespell:
    permissions: write-all
    needs: check
    uses: ./.github/workflows/codespell.yml
    if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }}
    secrets: inherit
  format:
    name: 'verify format'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: false
      - name: set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
      - name: 'Verify Formatting'
        run: bash -ex ./.ci/scripts/format/script.sh
  earelease:
    runs-on: ubuntu-latest
    needs: format
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
          fetch-depth: 0
      - name: set up JDK 17
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
            ~/.ccache
          key: ${{ runner.os }}-android-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-android-
      - name: Query tag name
        uses: olegtarasov/get-tag@v2.1.2
        id: tagName
      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y ccache apksigner glslang-dev glslang-tools
      - name: Build
        run: ./.ci/scripts/android/build.sh
      - name: Copy and sign artifacts
        env:
          EA_PLAY_ANDROID_KEYSTORE_B64: ${{ secrets.PLAY_ANDROID_KEYSTORE_B64 }}
          PLAY_ANDROID_KEY_ALIAS: ${{ secrets.PLAY_ANDROID_KEY_ALIAS }}
          PLAY_ANDROID_KEYSTORE_PASS: ${{ secrets.PLAY_ANDROID_KEYSTORE_PASS }}
          EA_SERVICE_ACCOUNT_KEY_B64: ${{ secrets.EA_SERVICE_ACCOUNT_KEY_B64 }}
        run: ./.ci/scripts/android/upload.sh
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: earelease
          path: artifacts/
