From 19a1e52e0c794772bf83e2dad2f22922398b9cb0 Mon Sep 17 00:00:00 2001 From: Nicolas MARTEAU Date: Wed, 31 Jul 2024 13:56:24 +0200 Subject: [PATCH] ci: manage OSX OS to obtain the .node from github action --- .github/workflows/build.yml | 90 ++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8837baf..8b3f15e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,8 @@ name: Build and Retrieve Compiled Files on: - push: - branches: - - main pull_request: - branches: - - main + types: [opened, reopened, synchronize] jobs: build: @@ -14,29 +10,27 @@ jobs: strategy: matrix: include: - - os: ubuntu-22.04 - platform: linuxmusl-x64 - - os: ubuntu-22.04 - platform: linux-x64 - # - os: macos-11 - # platform: darwin-x64 - - os: windows-latest - platform: win32-x64 - - os: windows-latest - platform: win32-ia32 + # - os: ubuntu-22.04 + # platform: linuxmusl-x64 + # - os: ubuntu-22.04 + # platform: linux-x64 + - os: macos-latest + platform: darwin-x64 + # - os: windows-latest + # platform: win32-x64 + # - os: windows-latest + # platform: win32-ia32 + steps: + - bash: | + . $HOME/.nvm/nvm.sh > /dev/null 2>&1 || true + nvm ls + nvm use v14 + - name: Checkout repository uses: actions/checkout@v2 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Install dependencies - run: npm install - - name: Create a folder for the tarball run: | mkdir release @@ -56,9 +50,9 @@ jobs: docker cp ${{ matrix.PLATFORM }}:/heif-converter/src/build/Release/converter.node ./release/lib/converter.${{ matrix.PLATFORM }}.node - name: Copy .dll files from the container (Windows) + if: contains(matrix.os, 'windows') env: SRC_PATH: /heif-converter/src/build/Release - if: contains(matrix.os, 'windows') run: | docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/heif.dll ./release/lib/heif.dll docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/turbojpeg.dll ./release/lib/turbojpeg.dll @@ -68,9 +62,55 @@ jobs: docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/libpng16.dll ./release/lib/libpng16.dll docker cp ${{ matrix.PLATFORM }}:${{ env.SRC_PATH }}/zlib1.dll ./release/lib/zlib1.dll - - name: Clean up the Docker container + - name: Clean up the Docker container (Windows and Linux) + if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'windows') run: docker container rm ${{ matrix.PLATFORM }} + - name: Configure and Build on OSX + if: contains(matrix.os, 'mac') + run: | + + - name: Install nvm + run: | + brew install nvm + echo 'export NVM_DIR="$HOME/.nvm"' >> $GITHUB_ENV + echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $GITHUB_ENV + echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> $GITHUB_ENV + shell: bash + + - name: "Resolve error 'dyld[]: missing symbol called'" + run: | + arch -x86_64 zsh + nvm use system + nvm cache clear + nvm uninstall 18 + nvm install 18 + nvm use 18 + + - name: Configure and Build on OSX + if: contains(matrix.os, 'mac') + run: | + # Install nasm (useful for vcpkg) + brew install nasm + + # Install python setup tools + pip3 install setuptools + + # Clone vcpkg and install libheif + git clone https://github.com/microsoft/vcpkg.git + ./vcpkg/bootstrap-vcpkg.sh + ./vcpkg/vcpkg install libheif + + # Build project + npm run configure + npm run build + + # Run tests + npm run test + + # Copy .node in the release folder + cp ./src/build/Release/converter.node ./release/lib/converter.${{ matrix.PLATFORM }}.node + - name: Create tarball of the release folder run: | cd ./release