{% render "scripts/helper/templates/copyright-liquid.yml" %}

{% if platforms == "all" -%}
  {% assign platforms = "linux-x64,linux-arm64,linux-arm,darwin-x64,darwin-arm64,win32-x64" -%}
{% endif -%}
{% assign platforms = platforms | split: "," -%}

name: 'Deep clean xPack {{ APP_NAME }}'

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'The semver of the release'
        required: false
        default: 'current'

jobs:
{% for platform in platforms -%}
{% if platform == "linux-x64" or platform == "win32-x64" or platform == "linux-ia32" or platform == "win32-ia32" %}
  linux-x64:
    name: 'Linux Intel - {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} clean'
    timeout-minutes: 5760 # 4 days
    runs-on: [self-hosted, linux, x64]
    steps:
      - name: 'Machine'
        run: uname -a

      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true

      - name: 'Clean working area'
        run: rm -rf ~/Work/{{ APP_LC_NAME }}-{% raw %}${{ github.event.inputs.version }}{% endraw %}*
{% break -%}
{% endif -%}
{% endfor %}

{% for platform in platforms -%}
{% if platform == "linux-arm" %}
  linux-arm:
    name: 'Linux Arm 32 - {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} clean'
    timeout-minutes: 2880 # 2 days
    runs-on: [self-hosted, linux, arm, xbbla32]
    steps:
      - name: 'Machine'
        run: uname -a

      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true

      - name: 'Clean working area'
        run: rm -rf ~/Work/{{ APP_LC_NAME }}-{% raw %}${{ github.event.inputs.version }}{% endraw %}*
{% break -%}
{% endif -%}
{% endfor %}

{% for platform in platforms -%}
{% if platform == "linux-arm64" %}
  linux-arm64:
    name: 'Linux Arm 64 - {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} clean'
    timeout-minutes: 2880 # 2 days
    runs-on: [self-hosted, linux, arm64, xbbla64]
    steps:
      - name: 'Machine'
        run: uname -a

      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true

      - name: 'Clean working area'
        run: rm -rf ~/Work/{{ APP_LC_NAME }}-{% raw %}${{ github.event.inputs.version }}{% endraw %}*
{% break -%}
{% endif -%}
{% endfor %}

{% for platform in platforms -%}
{% if platform == "darwin-x64" %}
  macos-x64:
    name: 'macOS Intel - {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} clean'
    timeout-minutes: 2880 # 2 days
{% if MACOS_INTEL_VERSION %}
    runs-on: [self-hosted, macos, intel, {{ MACOS_INTEL_VERSION }}]
{% else %}
    runs-on: [self-hosted, macos, intel]
{% endif %}
    steps:
      - name: 'Machine'
        run: uname -a

      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true

      - name: 'Clean working area'
        run: rm -rf ~/Work/{{ APP_LC_NAME }}-{% raw %}${{ github.event.inputs.version }}{% endraw %}*
{% break -%}
{% endif -%}
{% endfor %}

{% for platform in platforms -%}
{% if platform == "darwin-arm64" %}
  macos-arm64:
    name: 'macOS Arm - {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} clean'
    timeout-minutes: 2880 # 2 days
{% if MACOS_ARM_VERSION %}
    runs-on: [self-hosted, macos, apple, {{ MACOS_ARM_VERSION }}]
{% else %}
    runs-on: [self-hosted, macos, apple]
{% endif %}
    defaults:
      run:
        shell: "/usr/bin/arch -arch arm64e /bin/bash -l {0}"

    steps:
      - name: 'Machine'
        run: uname -a

      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true

      - name: 'Clean working area'
        run: rm -rf ~/Work/{{ APP_LC_NAME }}-{% raw %}${{ github.event.inputs.version }}{% endraw %}*
{% break -%}
{% endif -%}
{% endfor %}

