# DO NOT EDIT - GENERATED FROM .github/workflows-in/release.ys

name: release
defaults:
  run:
    shell: bash -e -x {0}
'on':
  workflow_dispatch: null
  push:
    tags:
    - v0.*
    - v1.*
    - v2.*
    branches:
    - master
  pull_request:
    branches:
    - '*'
env:
  PROJ_PKG_NAME: rapidyaml-
  PROJ_PFX_TARGET: ryml-
  PROJ_PFX_CMAKE: RYML_
  CMAKE_FLAGS: -DRYML_TEST_SUITE=OFF
  NUM_JOBS_BUILD: null
jobs:
  gettag:
    if: always()
    continue-on-error: false
    runs-on: ubuntu-latest
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: Variables (from tag)
      if: contains(github.ref, 'tags/v')
      run: |
        set -exo pipefail
        # https://github.community/t/how-to-get-just-the-tag-name/16241/11
        SRC_TAG=${GITHUB_REF#refs/tags/}
        SRC_VERSION=${GITHUB_REF#refs/tags/v}
        SRC_VERSION_BODY=`pwd`/changelog/$SRC_VERSION.md
        if [ ! -f $SRC_VERSION_BODY ] ; then
          echo "version body file was not found: $SRC_VERSION_BODY"
          exit 1
        fi
        cat <<EOF >> vars.sh
        export SRC_TAG=$SRC_TAG
        export SRC_VERSION=$SRC_VERSION
        export SRC_VERSION_BODY=$SRC_VERSION_BODY
        EOF
    - name: Variables (from commit, no tag)
      if: ${{ !contains(github.ref, 'tags/v') }}
      run: |
        set -exo pipefail
        branch_name=${GITHUB_REF#refs/heads/}
        # builds triggered from PRs have the branch_name like this: refs/pull/150/merge
        # so filter to eg pr0150_merge
        branch_name=`echo $branch_name | sed "s:refs/pull/\([0-9]*\)/\(.*\):pr0\1_\2:"`
        # sanitize the branch name; eg merge/foo-bar -> merge_foo_bar
        branch_name=`echo $branch_name | sed 's:[/.-]:_:g'`
        SRC_TAG=$(git describe || git rev-parse --short HEAD)  # eg v0.2.0-110-gda837e0
        SRC_VERSION="${branch_name}-${SRC_TAG}"
        cat <<EOF > vars.sh
        export SRC_TAG=$SRC_TAG
        export SRC_VERSION=$SRC_VERSION
        EOF
    - name: Save vars.sh
      uses: actions/upload-artifact@v4
      with:
        name: vars.sh
        path: ./vars.sh
    - name: Show vars.sh
      run: cat vars.sh
    - name: Source vars.sh
      run: source vars.sh
    - name: Env (common)
      run: |
        source vars.sh
        echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV
        echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV
    - name: Env (from tag)
      if: contains(github.ref, 'tags/v')
      run: |
        source vars.sh
        echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV
    - name: Variables (from commit, no tag)
      if: ${{ !contains(github.ref, 'tags/v') }}
      run: echo 'nothing to do'
    - name: Verify vars.sh
      run: env | grep SRC
  src:
    if: always()
    continue-on-error: false
    needs: gettag
    runs-on: ubuntu-latest
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: Download vars.sh
      uses: actions/download-artifact@v4
      with:
        name: vars.sh
        path: ./
    - name: Show vars.sh
      run: cat vars.sh
    - name: Source vars.sh
      run: source vars.sh
    - name: Env (common)
      run: |
        source vars.sh
        echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV
        echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV
    - name: Env (from tag)
      if: contains(github.ref, 'tags/v')
      run: |
        source vars.sh
        echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV
    - name: Variables (from commit, no tag)
      if: ${{ !contains(github.ref, 'tags/v') }}
      run: echo 'nothing to do'
    - name: Verify vars.sh
      run: env | grep SRC
    - name: Install python 3.9
      uses: actions/setup-python@v5
      with:
        python-version: 3.9
    - name: Install requirements
      run: sudo -E pip install git-archive-all
    - name: Create source packages
      run: |
        pwd
        ls -lFhp
        source vars.sh
        echo SRC_TAG=$SRC_TAG
        echo SRC_VERSION=$SRC_VERSION
        id=${PROJ_PKG_NAME}${SRC_VERSION}
        name=${id}-src
        mkdir -p assets
        git-archive-all --prefix $name assets/$name.tgz
        git-archive-all --prefix $name assets/$name.zip
        python --version
        python tools/amalgamate.py assets/$id.hpp
    - name: Save source artifacts
      uses: actions/upload-artifact@v4
      with:
        name: assets-src
        path: assets/
  cpp:
    if: always()
    continue-on-error: false
    name: cpp/${{matrix.config.os}}/${{matrix.config.gen}}
    needs: gettag
    runs-on: ${{matrix.config.os}}
    env:
      DEV: 'OFF'
      BT: Release
      OS: ${{matrix.config.os}}
      CXX_: ${{matrix.config.cxx}}
      GEN: ${{matrix.config.gen}}
    strategy:
      fail-fast: false
      matrix:
        config:
        - name: Ubuntu 24.04 deb
          sfxg: unix64.deb
          sfxp: ubuntu-24.04.deb
          gen: DEB
          mime: vnd.debian.binary-package
          os: ubuntu-24.04
        - name: Ubuntu 22.04 deb
          sfxg: unix64.deb
          sfxp: ubuntu-22.04.deb
          gen: DEB
          mime: vnd.debian.binary-package
          os: ubuntu-22.04
        - name: Windows VS2022 zip
          sfxg: win64.zip
          sfxp: windows-vs2022.zip
          gen: ZIP
          mime: zip
          os: windows-2022
          cxx: vs2022
        - name: MacOSX sh
          sfxg: apple64.sh
          sfxp: macosx-xcode.sh
          gen: STGZ
          mime: x-sh
          os: macos-latest
          cxx: xcode
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: Download vars.sh
      uses: actions/download-artifact@v4
      with:
        name: vars.sh
        path: ./
    - name: Show vars.sh
      run: cat vars.sh
    - name: Source vars.sh
      run: source vars.sh
    - name: Env (common)
      run: |
        source vars.sh
        echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV
        echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV
    - name: Env (from tag)
      if: contains(github.ref, 'tags/v')
      run: |
        source vars.sh
        echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV
    - name: Variables (from commit, no tag)
      if: ${{ !contains(github.ref, 'tags/v') }}
      run: echo 'nothing to do'
    - name: Verify vars.sh
      run: env | grep SRC
    - name: install requirements
      run: source .github/reqs.sh && c4_install_test_requirements $OS
    - name: show info
      run: source .github/setenv.sh && c4_show_info
    - name: shared64-configure-------------------------------------------------
      run: source .github/setenv.sh && c4_cfg_test shared64
    - name: shared64-build
      run: source .github/setenv.sh && c4_build_target shared64
    - name: shared64-pack
      run: source .github/setenv.sh && c4_package shared64 $GEN
    - name: shared64-normalize
      run: |
        set -x
        source vars.sh
        mkdir -p assets
        asset_src=`ls -1 ./build/shared64/*-${{matrix.config.sfxg}}`
        asset_dst=./assets/${PROJ_PKG_NAME}${SRC_VERSION}-${{matrix.config.sfxp}}
        [ ! -f $asset_src ] && exit 1
        cp -fav $asset_src $asset_dst
    - name: Save artifacts
      uses: actions/upload-artifact@v4
      with:
        name: assets-${{matrix.config.sfxp}}
        path: assets/
  python_src:
    if: always()
    continue-on-error: false
    name: python/src
    runs-on: ubuntu-latest
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: install python 3.9
      uses: actions/setup-python@v5
      with:
        python-version: 3.9
    - name: python version
      run: python --version
    - name: python requirements
      run: pip install -v -r requirements.txt
    - name: package python src
      run: python setup.py sdist --formats=gztar
    - name: Save artifacts
      uses: actions/upload-artifact@v4
      with:
        name: dist-python_src
        path: dist/
  python_wheels:
    if: always()
    continue-on-error: false
    name: ${{matrix.config.name}}
    runs-on: ${{matrix.config.os}}
    env:
      CMAKE_FLAGS: ${{matrix.config.cmakeflags}} -DCMAKE_VERBOSE_MAKEFILES=ON -DRYML_DEV=OFF -DRYML_API_TESTS=OFF -DRYML_API_BENCHMARKS=OFF
      CIBW_BUILD: cp${{matrix.config.cibw_pyv}}-${{matrix.config.cibw_platform}}
      CIBW_ARCHS: ${{matrix.config.cibw_arch}}
      CIBW_BUILD_VERBOSITY: 2
    strategy:
      fail-fast: false
      matrix:
        config:
        - name: python/3.13/manylinux_x86_64
          sfx: python3.13-manylinux_x86_64
          os: ubuntu-24.04
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.13/manylinux_i686
          sfx: python3.13-manylinux_i686
          os: ubuntu-24.04
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.13/manylinux_aarch64
          sfx: python3.13-manylinux_aarch64
          os: ubuntu-24.04-arm
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: aarch64
          cibw_platform: manylinux_aarch64
          vsenvarch: ''
        - name: python/3.13/macosx_x86_64
          sfx: python3.13-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
        - name: python/3.13/macosx_arm64
          sfx: python3.13-macosx_arm64
          os: macos-latest
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: arm64
          cibw_platform: macosx_arm64
          vsenvarch: ''
        - name: python/3.13/macosx_universal2
          sfx: python3.13-macosx_universal2
          os: macos-latest
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: universal2
          cibw_platform: macosx_universal2
          vsenvarch: ''
        - name: python/3.12/manylinux_x86_64
          sfx: python3.12-manylinux_x86_64
          os: ubuntu-24.04
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.12/manylinux_i686
          sfx: python3.12-manylinux_i686
          os: ubuntu-24.04
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.12/manylinux_aarch64
          sfx: python3.12-manylinux_aarch64
          os: ubuntu-24.04-arm
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: aarch64
          cibw_platform: manylinux_aarch64
          vsenvarch: ''
        - name: python/3.12/macosx_x86_64
          sfx: python3.12-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
        - name: python/3.12/macosx_arm64
          sfx: python3.12-macosx_arm64
          os: macos-latest
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: arm64
          cibw_platform: macosx_arm64
          vsenvarch: ''
        - name: python/3.12/macosx_universal2
          sfx: python3.12-macosx_universal2
          os: macos-latest
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: universal2
          cibw_platform: macosx_universal2
          vsenvarch: ''
        - name: python/3.11/manylinux_x86_64
          sfx: python3.11-manylinux_x86_64
          os: ubuntu-24.04
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.11/manylinux_i686
          sfx: python3.11-manylinux_i686
          os: ubuntu-24.04
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.11/manylinux_aarch64
          sfx: python3.11-manylinux_aarch64
          os: ubuntu-24.04-arm
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: aarch64
          cibw_platform: manylinux_aarch64
          vsenvarch: ''
        - name: python/3.11/macosx_x86_64
          sfx: python3.11-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
        - name: python/3.11/macosx_arm64
          sfx: python3.11-macosx_arm64
          os: macos-latest
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: arm64
          cibw_platform: macosx_arm64
          vsenvarch: ''
        - name: python/3.11/macosx_universal2
          sfx: python3.11-macosx_universal2
          os: macos-latest
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: universal2
          cibw_platform: macosx_universal2
          vsenvarch: ''
        - name: python/3.10/manylinux_x86_64
          sfx: python3.10-manylinux_x86_64
          os: ubuntu-24.04
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.10/manylinux_i686
          sfx: python3.10-manylinux_i686
          os: ubuntu-24.04
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.10/manylinux_aarch64
          sfx: python3.10-manylinux_aarch64
          os: ubuntu-24.04-arm
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: aarch64
          cibw_platform: manylinux_aarch64
          vsenvarch: ''
        - name: python/3.10/macosx_x86_64
          sfx: python3.10-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
        - name: python/3.10/macosx_arm64
          sfx: python3.10-macosx_arm64
          os: macos-latest
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: arm64
          cibw_platform: macosx_arm64
          vsenvarch: ''
        - name: python/3.10/macosx_universal2
          sfx: python3.10-macosx_universal2
          os: macos-latest
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: universal2
          cibw_platform: macosx_universal2
          vsenvarch: ''
        - name: python/3.9/manylinux_x86_64
          sfx: python3.9-manylinux_x86_64
          os: ubuntu-24.04
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.9/manylinux_i686
          sfx: python3.9-manylinux_i686
          os: ubuntu-24.04
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.9/manylinux_aarch64
          sfx: python3.9-manylinux_aarch64
          os: ubuntu-24.04-arm
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: aarch64
          cibw_platform: manylinux_aarch64
          vsenvarch: ''
        - name: python/3.9/macosx_x86_64
          sfx: python3.9-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
        - name: python/3.9/macosx_arm64
          sfx: python3.9-macosx_arm64
          os: macos-latest
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: arm64
          cibw_platform: macosx_arm64
          vsenvarch: ''
        - name: python/3.9/macosx_universal2
          sfx: python3.9-macosx_universal2
          os: macos-latest
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: universal2
          cibw_platform: macosx_universal2
          vsenvarch: ''
        - name: python/3.8/manylinux_x86_64
          sfx: python3.8-manylinux_x86_64
          os: ubuntu-24.04
          pythonv: '3.8'
          cibw_pyv: 38
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.8/manylinux_i686
          sfx: python3.8-manylinux_i686
          os: ubuntu-24.04
          pythonv: '3.8'
          cibw_pyv: 38
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.8/manylinux_aarch64
          sfx: python3.8-manylinux_aarch64
          os: ubuntu-24.04-arm
          pythonv: '3.8'
          cibw_pyv: 38
          cibw_arch: aarch64
          cibw_platform: manylinux_aarch64
          vsenvarch: ''
        - name: python/3.8/macosx_x86_64
          sfx: python3.8-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.8'
          cibw_pyv: 38
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
        - name: python/3.7/manylinux_x86_64
          sfx: python3.7-manylinux_x86_64
          os: ubuntu-22.04
          pythonv: '3.7'
          cibw_pyv: 37
          cibw_arch: x86_64
          cibw_platform: manylinux_x86_64
          vsenvarch: ''
        - name: python/3.7/manylinux_i686
          sfx: python3.7-manylinux_i686
          os: ubuntu-22.04
          pythonv: '3.7'
          cibw_pyv: 37
          cibw_arch: i686
          cibw_platform: manylinux_i686
          vsenvarch: ''
        - name: python/3.7/macosx_x86_64
          sfx: python3.7-macosx_x86_64
          os: macos-15-intel
          pythonv: '3.7'
          cibw_pyv: 37
          cibw_arch: x86_64
          cibw_platform: macosx_x86_64
          vsenvarch: ''
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: setup env (non-win)
      run: echo 'nothing to do'
    - name: create wheel
      uses: pypa/cibuildwheel@v2.23
    - name: rename wheelhouse -> dist
      run: mv -fv wheelhouse dist
    - name: Verify artifacts
      run: ls -lFhp dist/
    - name: Save artifacts for publishing to PyPI
      uses: actions/upload-artifact@v4
      with:
        name: dist-${{matrix.config.sfx}}
        path: dist/
    - name: install python ${{matrix.config.pythonv}}
      uses: actions/setup-python@v5
      with:
        python-version: ${{matrix.config.pythonv}}
    - name: confirm python install
      run: |
        python --version
        python -c 'import sys ; import struct ; import platform ; print("python:", sys.version, struct.calcsize("P") * 8, "bits", platform.machine())'
    - name: test with python ${{matrix.config.pythonv}}
      run: |
        set -x
        echo "python ${{matrix.config.pythonv}} ${{matrix.config.py_arch}} ${{matrix.config.cibw_arch}}"
        # skip 32 bit tests, as Python 32 bits are not available in ubuntu
        arch="${{matrix.config.cibw_arch}}"
        if [ "$arch" == "x86" ] || [ "$arch" == "i686" ] ; then
          exit 0
        fi
        python --version
        python -c 'import sys ; import struct ; import platform ; print("python:", sys.version, struct.calcsize("P") * 8, "bits", platform.machine())'
        pip --version
        pip install -v -r requirements.txt
        pip install -v -r api/python/requirements.txt
        for whl in dist/* ; do
          # verify that we can import the wheel files without installing the wheel
          unzip -l $whl
          mkdir -p tmpwhl
          cd tmpwhl
          unzip ../$whl
          ls -lFpAR .
          ( export PYTHONPATH=`pwd`/ryml ; python -c 'import ryml' )
          cd ..
          rm -rf tmpwhl
          # verify that we can install the wheel and then import it
          pip install -v $whl
          pip show -f rapidyaml
          python -c 'import ryml'
          python -c 'import ryml ; print("ryml", ryml.version, ryml.version_tuple)'
          python -c 'import ryml ; tree = ryml.parse_in_arena(b"{foo: bar}") ; assert tree.key(1) == b"foo" ; assert tree.val(1) == b"bar" ; print(str(tree.key(1), "utf8")) ; print(str(tree.val(1), "utf8"))'
          # run the tests
          python -m pytest -vvv api/python/tests
          pip uninstall -y -v rapidyaml
        done
  python_wheels_win:
    if: always()
    continue-on-error: false
    name: ${{matrix.config.name}}
    runs-on: ${{matrix.config.os}}
    env:
      CMAKE_FLAGS: ${{matrix.config.cmakeflags}} -DCMAKE_VERBOSE_MAKEFILES=ON -DRYML_DEV=OFF -DRYML_API_TESTS=OFF -DRYML_API_BENCHMARKS=OFF
      CIBW_BUILD: cp${{matrix.config.cibw_pyv}}-${{matrix.config.cibw_platform}}
      CIBW_ARCHS: ${{matrix.config.cibw_arch}}
      CIBW_BUILD_VERBOSITY: 2
    strategy:
      fail-fast: false
      matrix:
        config:
        - name: python/3.13/win_amd64
          sfx: python3.13-win_amd64
          os: windows-2022
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.13/win32
          sfx: python3.13-win32
          os: windows-2022
          pythonv: '3.13'
          cibw_pyv: 313
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
        - name: python/3.12/win_amd64
          sfx: python3.12-win_amd64
          os: windows-2022
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.12/win32
          sfx: python3.12-win32
          os: windows-2022
          pythonv: '3.12'
          cibw_pyv: 312
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
        - name: python/3.11/win_amd64
          sfx: python3.11-win_amd64
          os: windows-2022
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.11/win32
          sfx: python3.11-win32
          os: windows-2022
          pythonv: '3.11'
          cibw_pyv: 311
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
        - name: python/3.10/win_amd64
          sfx: python3.10-win_amd64
          os: windows-2022
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.10/win32
          sfx: python3.10-win32
          os: windows-2022
          pythonv: '3.10'
          cibw_pyv: 310
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
        - name: python/3.9/win_amd64
          sfx: python3.9-win_amd64
          os: windows-2022
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.9/win32
          sfx: python3.9-win32
          os: windows-2022
          pythonv: '3.9'
          cibw_pyv: 39
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
        - name: python/3.8/win_amd64
          sfx: python3.8-win_amd64
          os: windows-2022
          pythonv: '3.8'
          cibw_pyv: 38
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.8/win32
          sfx: python3.8-win32
          os: windows-2022
          pythonv: '3.8'
          cibw_pyv: 38
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
        - name: python/3.7/win_amd64
          sfx: python3.7-win_amd64
          os: windows-2022
          pythonv: '3.7'
          cibw_pyv: 37
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.6/win_amd64
          sfx: python3.6-win_amd64
          os: windows-2022
          pythonv: '3.6'
          cibw_pyv: 36
          cibw_arch: AMD64
          cibw_platform: win_amd64
          vsenvarch: x64
        - name: python/3.6/win32
          sfx: python3.6-win32
          os: windows-2022
          pythonv: '3.6'
          cibw_pyv: 36
          cibw_arch: x86
          cibw_platform: win32
          vsenvarch: x86
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: setup env (Visual Studio)
      uses: TheMrMilchmann/setup-msvc-dev@v3
      with:
        arch: ${{matrix.config.vsenvarch}}
    - name: create wheel
      uses: pypa/cibuildwheel@v2.23
    - name: rename wheelhouse -> dist
      run: mv -fv wheelhouse dist
    - name: Verify artifacts
      run: ls -lFhp dist/
    - name: Save artifacts for publishing to PyPI
      uses: actions/upload-artifact@v4
      with:
        name: dist-${{matrix.config.sfx}}
        path: dist/
    - name: install python ${{matrix.config.pythonv}}
      uses: actions/setup-python@v5
      with:
        python-version: ${{matrix.config.pythonv}}
    - name: confirm python install
      run: |
        python --version
        python -c 'import sys ; import struct ; import platform ; print("python:", sys.version, struct.calcsize("P") * 8, "bits", platform.machine())'
    - name: test with python ${{matrix.config.pythonv}}
      run: |
        set -x
        echo "python ${{matrix.config.pythonv}} ${{matrix.config.py_arch}} ${{matrix.config.cibw_arch}}"
        # skip 32 bit tests, as Python 32 bits are not available in ubuntu
        arch="${{matrix.config.cibw_arch}}"
        if [ "$arch" == "x86" ] || [ "$arch" == "i686" ] ; then
          exit 0
        fi
        python --version
        python -c 'import sys ; import struct ; import platform ; print("python:", sys.version, struct.calcsize("P") * 8, "bits", platform.machine())'
        pip --version
        pip install -v -r requirements.txt
        pip install -v -r api/python/requirements.txt
        for whl in dist/* ; do
          # verify that we can import the wheel files without installing the wheel
          unzip -l $whl
          mkdir -p tmpwhl
          cd tmpwhl
          unzip ../$whl
          ls -lFpAR .
          ( export PYTHONPATH=`pwd`/ryml ; python -c 'import ryml' )
          cd ..
          rm -rf tmpwhl
          # verify that we can install the wheel and then import it
          pip install -v $whl
          pip show -f rapidyaml
          python -c 'import ryml'
          python -c 'import ryml ; print("ryml", ryml.version, ryml.version_tuple)'
          python -c 'import ryml ; tree = ryml.parse_in_arena(b"{foo: bar}") ; assert tree.key(1) == b"foo" ; assert tree.val(1) == b"bar" ; print(str(tree.key(1), "utf8")) ; print(str(tree.val(1), "utf8"))'
          # run the tests
          python -m pytest -vvv api/python/tests
          pip uninstall -y -v rapidyaml
        done
  merge_artifacts:
    if: always()
    continue-on-error: false
    runs-on: ubuntu-latest
    needs:
    - src
    - cpp
    - python_src
    - python_wheels
    - python_wheels_win
    steps:
    - name: Merge assets artifacts
      uses: actions/upload-artifact/merge@v4
      with:
        name: assets
        pattern: assets-*
        separate-directories: true
        delete-merged: true
    - name: Merge dist artifacts
      uses: actions/upload-artifact/merge@v4
      with:
        name: dist
        pattern: dist-*
        separate-directories: true
        delete-merged: true
  release:
    if: always()
    continue-on-error: false
    runs-on: ubuntu-latest
    needs:
    - merge_artifacts
    steps:
    - name: checkout (action)
      uses: actions/checkout@v4
      with:
        submodules: recursive
        fetch-depth: 0
    - name: Download vars.sh
      uses: actions/download-artifact@v4
      with:
        name: vars.sh
        path: ./
    - name: Show vars.sh
      run: cat vars.sh
    - name: Source vars.sh
      run: source vars.sh
    - name: Env (common)
      run: |
        source vars.sh
        echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV
        echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV
    - name: Env (from tag)
      if: contains(github.ref, 'tags/v')
      run: |
        source vars.sh
        echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV
    - name: Variables (from commit, no tag)
      if: ${{ !contains(github.ref, 'tags/v') }}
      run: echo 'nothing to do'
    - name: Verify vars.sh
      run: env | grep SRC
    - name: Verify existing artifacts
      run: |
        ls -lFhp .
        ls -lFhp assets*/ || echo 'none found'
        ls -lFhp dist*/ || echo 'none found'
    - name: Gather artifacts - ./assets
      uses: actions/download-artifact@v4
      with:
        pattern: assets
    - name: Gather artifacts - ./dist
      uses: actions/download-artifact@v4
      with:
        pattern: dist
    - name: Verify existing artifacts
      run: |
        ls -lFhp .
        ls -lFhp assets*/ || echo 'none found'
        ls -lFhp dist*/ || echo 'none found'
        ( \
          cd assets ; \
          for asset in assets-*/ ; do \
            ls -lFhpA $asset/ ; \
            mv -v $asset/* . ; \
            rmdir $asset ; \
          done ;
        )
        ( \
          cd dist ; \
          for dist in dist-*/ ; do \
            ls -lFhpA $dist/ ; \
            mv -v $dist/* . ; \
            rmdir $dist ; \
          done ; \
        )
        ls -lFhp assets*/ || echo 'none found'
        ls -lFhp dist*/ || echo 'none found'
    - name: Download vars.sh
      uses: actions/download-artifact@v4
      with:
        name: vars.sh
        path: ./
    - name: Show vars.sh
      run: cat vars.sh
    - name: Source vars.sh
      run: source vars.sh
    - name: Env (common)
      run: |
        source vars.sh
        echo "SRC_TAG=$SRC_TAG" >> $GITHUB_ENV
        echo "SRC_VERSION=$SRC_VERSION" >> $GITHUB_ENV
    - name: Env (from tag)
      if: contains(github.ref, 'tags/v')
      run: |
        source vars.sh
        echo "SRC_VERSION_BODY=$SRC_VERSION_BODY" >> $GITHUB_ENV
    - name: Variables (from commit, no tag)
      if: ${{ !contains(github.ref, 'tags/v') }}
      run: echo 'nothing to do'
    - name: Verify vars.sh
      run: env | grep SRC
    - name: Create Github Release
      if: contains(github.ref, 'tags/v')
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
      with:
        tag_name: ${{github.ref}}
        release_name: Release ${{env.SRC_VERSION}}
        body_path: ${{env.SRC_VERSION_BODY}}
        draft: true
        prerelease: ${{contains(github.ref, 'rc')}}
    - name: Upload assets to Github Release
      if: contains(github.ref, 'tags/v')
      uses: dwenegar/upload-release-assets@v1
      env:
        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
      with:
        release_id: ${{steps.create_release.outputs.id}}
        assets_path: ./assets/
    - name: Publish python packages to test PyPI
      uses: pypa/gh-action-pypi-publish@v1.13.0
      with:
        repository-url: https://test.pypi.org/legacy/
        user: __token__
        password: ${{secrets.PYPI_TOKEN_TEST}}
        verbose: true
        skip-existing: true
    - name: Publish python packages to production PyPI
      if: contains(github.ref, 'tags/v')
      uses: pypa/gh-action-pypi-publish@v1.13.0
      with:
        user: __token__
        password: ${{secrets.PYPI_TOKEN}}
        verbose: true
