name: build wheel linux aarch64

on:
  pull_request_target:
    types:
      - closed
    branches:
      - 'main'

jobs:
  cibuildwheel:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python_version: ['3.7', '3.8', '3.9', '3.10', '3.11']
        cibw_skip: ['*musllinux*', '*manylinux*']
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Setup Python
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python_version }}

    - name: Set up QEMU
      uses: docker/setup-qemu-action@v2

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v2

    - name: Create wheels linux aarch64
      run: |
        PYTHON_VERSION=${{ matrix.python_version }}
        CIBW_BUILD="cp${PYTHON_VERSION//.}-*"
        export CIBW_BUILD
        export CIBW_SKIP=${{ matrix.cibw_skip }}
        pip install cibuildwheel
        python -m cibuildwheel --platform linux --archs aarch64 --output-dir ./out

    - name: Upload artifact
      uses: actions/upload-artifact@v2
      with:
        name: wheels
        path: ./out
