.pypi_build:
    stage: build
    script:
        - python3 --version
        - mkdir build
        - cd build
        - cmake ..
        - make glaxnimate_python_depends_install
        - make glaxnimate_python
    artifacts:
        paths:
            - build/bin/python/build/lib/

#linux:pypi_3.8:
    #image: ubuntu:20.04
    #extends: .pypi_build
    #only:
        #- master
        #- release
        #- tags
        #- pypi

#linux:pypi_3.9:
    #image: ubuntu:21.04
    #extends: .pypi_build
    #only:
        #- master
        #- release
        #- tags
        #- pypi

linux:pypi_3.10:
    image: ubuntu:22.04
    extends: .pypi_build
    only:
        - master
        - release
        - tags
        - pypi
    #before_script:
        #- apt-get update -qq
        #- apt-get install -y python3.10 libpython3.10-dev libpython3.9- python3-pip python3-virtualenv cmake g++ build-essential qtbase5-dev zlib1g-dev qttools5-dev-tools qttools5-dev libpotrace-dev libavformat-dev libswscale-dev libavcodec-dev libavutil-dev libarchive-dev libqt5svg5-dev
        #- update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.10 20
        #- update-alternatives --install /usr/local/bin/python python /usr/bin/python3.10 20
    #script:
        #- python3 --version
        #- mkdir build
        #- cd build
        #- cmake .. -DPython3_INCLUDE_DIRS=/usr/include/python3.10 -DPython3_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython3.10.so -DPython3_EXECUTABLE=/usr/bin/python3.10
        #- make glaxnimate_python_depends_install
        #- make glaxnimate_python

linux:pypi_deploy:
    image: ubuntu:latest
    stage: deploy
    needs:
        - linux:pypi_3.10
    dependencies:
        - linux:pypi_3.10
    script:
        - python3 --version
        - mkdir -p build
        - cd build
        - cmake .. -DVERSION_SUFFIX="git.`date +%Y%m%d%H%M%S`.$CI_COMMIT_BRANCH.$CI_COMMIT_SHORT_SHA"
        - make glaxnimate_python_depends_install
        - ls bin/python/build/lib
        - make glaxnimate_python_wheel
        - python3 -m twine upload bin/python/dist/*.whl --repository-url https://gitlab.com/api/v4/projects/19921167/packages/pypi --verbose
    only:
        - master
        - release
    environment:
        name: Gitlab PyPI

linux:pypi_deploy_tag:
    image: ubuntu:latest
    stage: deploy
    needs:
        - linux:pypi_3.10
    dependencies:
        - linux:pypi_3.10
    script:
        - python3 --version
        - mkdir -p build
        - cd build
        - if [ -z "$CI_COMMIT_TAG" ] ; then version="$(../deploy/pypi_version_tail.sh)"; else version=""; fi
        - cmake .. -DVERSION_SUFFIX="$version"
        - make glaxnimate_python_depends_install
        - ls bin/python/build/lib
        - make glaxnimate_python_wheel
        - make glaxnimate_python_upload
    environment:
        name: PyPI
    only:
        - tags
        - pypi
