name: github-actions
on: [push, pull_request]
jobs:
  windows-2019-dynamicLink:
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v4
      - name: HDF5 install
        run: |
          Invoke-WebRequest https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/bin/hdf5-1.12.0-Std-win10_64-vs16.zip -OutFile ${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16.zip
          Expand-Archive ${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16.zip -DestinationPath ${{ runner.temp }}
          msiexec.exe /i "${{ runner.temp }}\hdf\HDF5-1.12.0-win64.msi" /qn INSTALL_ROOT=${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16
      - name: Minizip DLL install
        run: |
          git clone https://github.com/F2I-Consulting/Minizip.git ${{ runner.temp }}/Minizip
          cd ${{ runner.temp }}
          mkdir minizip-build
          cd minizip-build
          cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DZLIB_ROOT=${{ runner.temp }}/hdf5-1.12.0-Std-win10_64-vs16 -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/minizip-install ${{ runner.temp }}/Minizip
          cmake --build . --config Release -j2
          cmake --build . --config Release --target INSTALL
      - name: Boost install
        run: |
          (New-Object System.Net.WebClient).DownloadFile("https://boostorg.jfrog.io/artifactory/main/release/1.86.0/binaries/boost_1_86_0-msvc-14.2-64.exe", "${{ runner.temp }}\boost.exe")
          Start-Process -Wait -FilePath "${{ runner.temp }}\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=${{ runner.temp }}\boost-install"
      - name: CMake build and install
        run: |
          cd ${{ github.workspace }}/..
          mkdir build
          cd build
          cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DHDF5_ROOT=${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16 -DMINIZIP_ROOT=${{ runner.temp }}/minizip-install -DZLIB_ROOT=${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16 -DSZIP_LIBRARY_RELEASE=${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16/lib/szip.lib -DBoost_INCLUDE_DIR=${{ runner.temp }}\boost-install -DWITH_EXAMPLE=TRUE -DWITH_RESQML2_2=TRUE -DWITH_TEST=TRUE -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install ${{ github.workspace }}
          cmake --build . --config Release -j2
          cmake --build . --config Release --target INSTALL
      - name: Copy hdf5 dll
        run: |
          Copy-Item ${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16\bin\hdf5.dll -Destination ${{ github.workspace }}\..\build\Release
          Copy-Item ${{ runner.temp }}\hdf5-1.12.0-Std-win10_64-vs16\bin\zlib.dll -Destination ${{ github.workspace }}\..\build\Release
      - name: Run Unit tests
        run: |
          ${{ github.workspace }}\..\build\Release\unitTest
      - name: Run Cpp example
        run: |
          ${{ github.workspace }}\..\build\Release\example.exe
      - uses: actions/upload-artifact@v4
        with:
          name: windows-2019
          path: ${{ runner.temp }}/fesapi-install
  windows-2019-staticLink-cs:
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v4
      - name: zlib install
        run: |
          Invoke-WebRequest https://zlib.net/current/zlib.tar.gz -OutFile ${{ runner.temp }}\zlib.tar.gz
          cd ${{ runner.temp }}
          tar -xzf ${{ runner.temp }}\zlib.tar.gz
          mkdir zlib-build
          cd zlib-build
          cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/zlib-install ${{ runner.temp }}/zlib-1.3.1
          cmake --build . --config Release -j2
          cmake --build . --config Release --target INSTALL
      - name: Minizip static lib install
        run: |
          git clone https://github.com/F2I-Consulting/Minizip.git ${{ runner.temp }}/Minizip
          cd ${{ runner.temp }}
          mkdir minizip-build
          cd minizip-build
          cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DBUILD_SHARED_LIBS=FALSE -DZLIB_ROOT=${{ runner.temp }}/zlib-install -DZLIB_USE_STATIC_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/minizip-install ${{ runner.temp }}/Minizip
          cmake --build . --config Release -j2
          cmake --build . --config Release --target INSTALL
      - name: HDF5 install
        run: |
          Invoke-WebRequest https://support.hdfgroup.org/releases/hdf5/v1_14/v1_14_5/downloads/hdf5-1.14.5.zip -OutFile ${{ runner.temp }}\hdf5-1.14.5.zip
          cd ${{ runner.temp }}
          Expand-Archive ${{ runner.temp }}\hdf5-1.14.5.zip -DestinationPath ${{ runner.temp }}
          mkdir hdf5-build
          cd hdf5-build
          cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DZLIB_INCLUDE_DIR:PATH=${{ runner.temp }}/zlib-install/include -DZLIB_LIBRARY:PATH=${{ runner.temp }}/zlib-install/lib/zlibstatic.lib -DHDF5_BUILD_FORTRAN:BOOL=OFF -DHDF5_BUILD_JAVA:BOOL=OFF -DHDF5_ENABLE_PARALLEL:BOOL=OFF -DHDF5_BUILD_CPP_LIB:BOOL=OFF -DHDF5_BUILD_HL_LIB:BOOL=OFF -DHDF5_BUILD_EXAMPLES:BOOL=OFF -DHDF5_BUILD_GENERATORS:BOOL=OFF -DHDF5_BUILD_TOOLS:BOOL=OFF -DHDF5_BUILD_UTILS:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/hdf5-install ${{ runner.temp }}/hdf5-1.14.5
          cmake --build . --config Release -j2
          cmake --build . --config Release --target INSTALL
      - name: Boost install
        run: |
          (New-Object System.Net.WebClient).DownloadFile("https://boostorg.jfrog.io/artifactory/main/release/1.86.0/binaries/boost_1_86_0-msvc-14.2-64.exe", "${{ runner.temp }}\boost.exe")
          Start-Process -Wait -FilePath "${{ runner.temp }}\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=${{ runner.temp }}\boost-install"
      - name: Swig install
        run: |
          (New-Object System.Net.WebClient).DownloadFile("http://prdownloads.sourceforge.net/swig/swigwin-4.3.0.zip", "${{ runner.temp }}\swigwin-4.3.0.zip")
          7z x ${{ runner.temp }}\swigwin-4.3.0.zip -o${{ runner.temp }}
      - name: CMake build and install
        run: |
          cd ${{ github.workspace }}/..
          mkdir build
          cd build
          cmake -G"Visual Studio 16 2019" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DHDF5_ROOT=${{ runner.temp }}/hdf5-install -DHDF5_USE_STATIC_LIBRARIES=TRUE -DMINIZIP_ROOT=${{ runner.temp }}/minizip-install -DZLIB_ROOT=${{ runner.temp }}/zlib-install -DZLIB_USE_STATIC_LIBS=TRUE -DBoost_INCLUDE_DIR=${{ runner.temp }}/boost-install -DWITH_EXAMPLE=TRUE -DWITH_RESQML2_2=TRUE -DWITH_DOTNET_WRAPPING=TRUE -DSWIG_EXECUTABLE=${{ runner.temp }}/swigwin-4.3.0/swig.exe -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install ${{ github.workspace }}
          cmake --build . --config Release -j2
          cmake --build . --config Release --target INSTALL
      - name: Add msbuild to PATH
        uses: microsoft/setup-msbuild@v2
        with:
          msbuild-architecture: x64
      - name: Build the C# example
        run: msbuild ${{ github.workspace }}/cs/example/example.sln -t:rebuild /p:Configuration=Release /p:Platform="x64"
      - name: Run Cpp example
        run: |
          ${{ github.workspace }}\..\build\Release\example.exe
      - name: Copy all dlls for C#
        run: |
          Copy-Item ${{ github.workspace }}\..\build\Release\*.dll -Destination ${{ github.workspace }}\cs\example\bin\x64\Release
      - name: Run C# example
        run: |
          ${{ github.workspace }}\cs\example\bin\x64\Release\example.exe
  ubuntu-20-java11:
    runs-on: ubuntu-20.04
    strategy:
      fail-fast: false  # 'false' means Don't stop matrix workflows even if some matrix failed.
      matrix:
        include: [
          { xcc_name: 'gcc 9',      xcc_pkg: gcc-9,       cc: gcc-9,      cxx: g++-9 },
          { xcc_name: 'gcc 10',     xcc_pkg: gcc-10,      cc: gcc-10,     cxx: g++-10 },
          { xcc_name: 'clang 9',    xcc_pkg: clang-9,     cc: clang-9,    cxx: clang++-9 },
          { xcc_name: 'clang 10',   xcc_pkg: clang-10,    cc: clang-10,   cxx: clang++-10 },
          { xcc_name: 'clang 11',   xcc_pkg: clang-11,    cc: clang-11,   cxx: clang++-11 },
          # { xcc_name: 'clang 12',   xcc_pkg: clang-12,    cc: clang,   cxx: clang++ },
        ]
    env:
      XCC: $${{ matrix.xcc_name }}
      CC: ${{ matrix.cc }}
      CXX: ${{ matrix.cxx }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin' # See 'Supported distributions' for available options
          java-version: '11'
      - name: APT install
        run: |
          sudo apt update
          sudo apt install -y ${{ matrix.xcc_pkg }} libminizip-dev libboost-all-dev
# Build HDF5 instead of downloading the package because the package is not built with -fPIC causing relocation issue.
      - name: HDF5 build and install
        run: |
          cd ${{ runner.temp }}
          wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.gz
          tar -xzf hdf5-1.12.2.tar.gz
          cd hdf5-1.12.2
          mkdir build
          cd build
          cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DHDF5_BUILD_TOOLS:BOOL=OFF -DHDF5_BUILD_EXAMPLES:BOOL=OFF -DHDF5_BUILD_CPP_LIB:BOOL=OFF -DHDF5_BUILD_HL_LIB:BOOL=OFF -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DCMAKE_INSTALL_PREFIX:STRING=${{ runner.temp }}/install-hdf5-1.12.2 ..
          cmake --build . --config Release
          make -j4
          make install
      - name: CMake build and install
        run: |
          cd ..
          mkdir build
          cd build
          cmake -DHDF5_ROOT=${{ runner.temp }}/install-hdf5-1.12.2 -DHDF5_USE_STATIC_LIBRARIES=TRUE -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA_WRAPPING=TRUE ${{ github.workspace }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install
          cmake --build . -j2
          cmake --install .
      - name: Run java example
        run: |
          cd ${{ github.workspace }}/java/src
          javac -cp `find ${{ runner.temp }}/fesapi-install -name fesapiJava*.jar` com/f2i_consulting/example/FesapiJavaExample.java
          java -Djava.library.path=${{ runner.temp }}/fesapi-install/lib -cp `find ${{ runner.temp }}/fesapi-install -name fesapiJava*.jar`:. com.f2i_consulting.example.FesapiJavaExample
      - uses: actions/upload-artifact@v4
        with:
          name: ubuntu-20.04-${{ matrix.cxx }}
          path: ${{ runner.temp }}/fesapi-install
  build_wheels_windows:
    name: Build wheels on windows-latest
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - name: Stub `setup.py` check
        # It will be generated during CMake run
        # https://github.com/pypa/cibuildwheel/issues/1139
        run: touch python/setup.py
      - name: Build wheels
        uses: pypa/cibuildwheel@v2.21.3
        env:
          CIBW_BUILD: cp38-win_amd64 cp39-win_amd64 cp310-win_amd64 cp311-win_amd64 cp312-win_amd64 cp313-win_amd64
          CIBW_ARCHS: auto64
          CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
          CIBW_BEFORE_ALL: >
            %VCPKG_INSTALLATION_ROOT%\vcpkg install boost-uuid minizip hdf5[zlib] &&
            cd ${{ runner.temp }} &&
            mkdir fesapi-build &&
            cd fesapi-build &&
            cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%\scripts\buildsystems\vcpkg.cmake -G"Visual Studio 17 2022" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DWITH_PYTHON_WRAPPING=TRUE -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install ${{ github.workspace }} &&
            cmake --build . --config Release -j2 &&
            cmake --build . --config Release --target INSTALL &&
            pip install delvewheel
          CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
            delvewheel repair --add-path ${{ runner.temp }}\fesapi-build\Release --namespace-pkg fesapi -w {dest_dir} {wheel}
          CIBW_TEST_COMMAND: python ${{github.workspace}}\python\example\example.py
        with:
          package-dir: ./python
          output-dir: wheelhouse
      - uses: actions/upload-artifact@v4
        with:
          name: cibw-wheels-windows
          path: ./wheelhouse/*.whl
  build_wheels_linux:
    name: Build wheels on ubuntu-latest
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Stub `setup.py` check
        # It will be generated during CMake run
        # https://github.com/pypa/cibuildwheel/issues/1139
        run: touch python/setup.py
      - name: Build wheels
        uses: pypa/cibuildwheel@v2.21.3
        env:
          CIBW_BUILD: cp38-manylinux_* cp39-manylinux_* cp310-manylinux_* cp311-manylinux_* cp312-manylinux_* cp313-manylinux_*
          CIBW_ARCHS: auto64
          CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
          CIBW_BEFORE_ALL: >
            yum install -y wget gcc-c++ boost-devel &&
            yum search epel-release &&
            yum info epel-release &&
            yum install -y epel-release &&
            yum --enablerepo=epel install -y minizip1.2-devel hdf5-devel cmake3 &&
            mkdir build &&
            cd build &&
            cmake3 -DCMAKE_BUILD_TYPE=Release -DWITH_PYTHON_WRAPPING=TRUE -DCMAKE_INSTALL_PREFIX:STRING=/fesapi-install {project} &&
            cmake3 --build . -j2 --config Release &&
            cmake3 --install .
          CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
            export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/fesapi-install/lib64 &&
            auditwheel repair -w {dest_dir} {wheel}
          CIBW_TEST_COMMAND: python {project}/python/example/example.py
        with:
          package-dir: ./python
          output-dir: wheelhouse
      - uses: actions/upload-artifact@v4
        with:
          name: cibw-wheels-manylinux_2_28
          path: ./wheelhouse/*.whl
  build_wheels_mac:
    name: Build wheels on macos-14
    runs-on: macos-14
    steps:
      - uses: actions/checkout@v4
      - name: Stub `setup.py` check
        # It will be generated during CMake run
        # https://github.com/pypa/cibuildwheel/issues/1139
        run: touch python/setup.py
      - name: Build wheels
        uses: pypa/cibuildwheel@v2.21.3
        env:
          CIBW_BUILD: cp38-macosx_* cp39-macosx_* cp310-macosx_* cp311-macosx_* cp312-macosx_* cp313-macosx_*
          CIBW_ARCHS: auto64
          CIBW_BEFORE_ALL: >
            brew install boost swig &&
            git clone https://github.com/F2I-Consulting/Minizip.git ${{ github.workspace }}/../minizip &&
            cd ${{ github.workspace }}/.. &&
            mkdir minizip-build &&
            cd minizip-build &&
            cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/../minizip-install ${{ github.workspace }}/../minizip &&
            cmake --build . -j2 --config Release &&
            cmake --install . &&
            cd ${{ github.workspace }}/.. &&
            wget https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.5/hdf5-1.14.5.tar.gz &&
            tar xf hdf5-1.14.5.tar.gz &&
            mkdir hdf5-build &&
            cd hdf5-build &&
            cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DHDF5_BUILD_TOOLS:BOOL=OFF -DHDF5_BUILD_EXAMPLES:BOOL=OFF -DHDF5_BUILD_CPP_LIB:BOOL=OFF -DHDF5_BUILD_HL_LIB:BOOL=OFF -DCMAKE_INSTALL_PREFIX:STRING=${{ github.workspace }}/../hdf5-install ../hdf5-1.14.5 &&
            cmake --build . -j2 --config Release &&
            cmake --install . &&
            mkdir ${{ github.workspace }}/../build &&
            cd ${{ github.workspace }}/../build &&
            cmake -DCMAKE_BUILD_TYPE=Release -DMINIZIP_ROOT=${{ github.workspace }}/../minizip-install -DHDF5_ROOT=${{ github.workspace }}/../hdf5-install -DHDF5_USE_STATIC_LIBRARIES=TRUE -DWITH_PYTHON_WRAPPING=TRUE -DCMAKE_INSTALL_PREFIX:STRING=${{ github.workspace }}/../fesapi-install ${{ github.workspace }} &&
            cmake --build . -j2 --config Release &&
            cmake --install .
          # See https://cibuildwheel.pypa.io/en/stable/faq/#macos-passing-dyld_library_path-to-delocate
          CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
            DYLD_LIBRARY_PATH=${{ github.workspace }}/../fesapi-install/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
          CIBW_TEST_COMMAND: python ${{ github.workspace }}/python/example/example.py
        with:
          package-dir: ./python
          output-dir: wheelhouse
      - uses: actions/upload-artifact@v4
        with:
          name: cibw-wheels-macosx_arm64
          path: ./wheelhouse/*.whl
  ubuntu-20-mpi:
    runs-on: ubuntu-20.04    
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: APT install
        run: |
          sudo apt update
          sudo apt install -y libhdf5-mpi-dev libminizip-dev libboost-all-dev
      - name: Setup MPI
        uses: mpi4py/setup-mpi@v1
      - name: CMake build and install
        run: |
          cd ${{ runner.temp }}
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=mpic++ -DCMAKE_C_COMPILER=mpicc -DHDF5_PREFER_PARALLEL:BOOL=TRUE -DWITH_EXAMPLE:BOOL=TRUE -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install ${{ github.workspace }}
          cmake --build . -j2
          cmake --install .
      - name: Run example
        run: mpiexec -n 2 ${{ runner.temp }}/fesapi-install/example
  ubuntu-latest-valgrind-unitTest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: APT install
        run: |
          sudo apt update
          sudo apt install -y libhdf5-dev libminizip-dev libboost-all-dev valgrind
      - name: CMake build and install
        run: |
          cd ..
          mkdir build
          cd build
          cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_EXAMPLE=TRUE -DWITH_RESQML2_2=TRUE -DWITH_TEST=TRUE -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install ${{ github.workspace }}
          cmake --build . -j2 --config Debug
          cmake --install .
      - name: Run Valgrind on example
        run: |
          valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all ${{ github.workspace }}/../build/example/exampled
      - name: Run Unit tests
        run: |
          ${{ github.workspace }}/../build/test/unitTest
  webassembly:
    if: false
    runs-on: ubuntu-20.04    
    steps:
      - uses: mymindstorm/setup-emsdk@v11
      - uses: actions/checkout@v4
      - name: Verify
        run: emcc -v
      - name: "Set environmental variables"
        run: |
          echo "WASM_INSTALL_DIR=${{ github.workspace }}/install" >> $GITHUB_ENV
          echo "WASM_LIB_DIR=${{ github.workspace }}/install/lib" >> $GITHUB_ENV
          echo "WASM_INCLUDE_DIR=${{ github.workspace }}/install/include" >> $GITHUB_ENV
      - name: HDF5 install
        env:          
          HDF5_DOWNLOAD_URL: https://github.com/HDFGroup/hdf5/archive/refs/tags/hdf5-1_12_1.tar.gz
        run: |
          wget ${{ env.HDF5_DOWNLOAD_URL }} -O hdf5_src.tgz           
          tar -xvzf hdf5_src.tgz 
          mkdir -p hdf5_build
          cd hdf5_build
          LDFLAGS="-s NODERAWFS=1 -s USE_ZLIB=1" emcmake cmake ../hdf5-hdf5-1_12_1 \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=${{ env.WASM_INSTALL_DIR }} \
            -DH5_HAVE_GETPWUID=0 \
            -DH5_HAVE_SIGNAL=0 \
            -DBUILD_SHARED_LIBS=0 \
            -DBUILD_STATIC_LIBS=1 \
            -DBUILD_TESTING=0 \
            -DHDF5_BUILD_EXAMPLES=0 \
            -DHDF5_BUILD_TOOLS=0 \
            -DHDF5_ENABLE_Z_LIB_SUPPORT=1
          emmake make -j8 install
      - name: Minizip install
        run: |
          git clone https://github.com/F2I-Consulting/Minizip.git
          mkdir -p minizip_build
          cd minizip_build
          LDFLAGS="-s USE_ZLIB=1" emcmake cmake ../Minizip \
            -DCMAKE_INSTALL_PREFIX=${{ env.WASM_INSTALL_DIR }}
          emmake make -j8 install
      - name: CMake build 
        env:
          FESAPI_BUILD_DIR: fesapi_build
        run: |
          cd ${{ github.workspace }}
          # see https://sourceforge.net/p/gsoap2/bugs/1301/
          #wget https://gist.github.com/untereiner/3af2e52fbd135235457d2a707d5480d4/raw/7f7e0706b3421593c4c617b9703e5a90e30bfa51/gsoap_wasm.patch
          #git apply gsoap_wasm.patch
          mkdir -p fesapi_build
          cd fesapi_build
          LDFLAGS="-s USE_ZLIB=1 -s USE_BOOST_HEADERS=1" emcmake cmake ../ \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=${{ env.WASM_INSTALL_DIR }} \
            -DWITH_LOCAL_HDF5=ON \
            -DHDF5_INCLUDE_DIRS=${{ env.WASM_INCLUDE_DIR }} \
            -DHDF5_LIBRARIES=${{ env.WASM_LIB_DIR }}/libhdf5.a \
            -DMINIZIP_INCLUDE_DIR=${{ env.WASM_INCLUDE_DIR }} \
            -DMINIZIP_LIBRARY_RELEASE=${{ env.WASM_LIB_DIR }}/libminizip.a \
            -DWITH_EXAMPLE=0 \
            -DWITH_RESQML2_2=1 \
            -DWITH_TEST=0 \
            -DWITH_WASM_WRAPPING=1
          emmake make -j8 fesapi-wasm
          emmake make -j8 fesapi-wasm-node
      - name: 'Upload Artifact'
        uses: actions/upload-artifact@v3
        with:
          name: fesapi-mjs
          path: |
            ${{ github.workspace }}/webassembly/dist/esm/fesapi.mjs
            ${{ github.workspace }}/webassembly/dist/esm/fesapi.wasm
      # Setup .npmrc file to publish to npm
      #- name: 'Setup node'
      #  uses: actions/setup-node@v3
      #  with:
      #    node-version: '16.x'
      #    registry-url: 'https://registry.npmjs.org'
      #    cache-dependency-path: ${{ github.workspace }}/webassembly/package-lock.json
      #- name: Configure NPM
      #  working-directory: ${{ github.workspace }}/webassembly/
      #  run: |
      #    echo "//npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}" >> .npmrc
      #    echo "always-auth: true" >> .npmrc
      #  env:
      #    NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
      #- run: npm ci
      #  working-directory: ${{ github.workspace }}/webassembly/
      #- run: npm publish --access public
      #  working-directory: ${{ github.workspace }}/webassembly/
      #  env:
      #    NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}