Skip to content

switch to ubicloud-standard-4-arm #194

switch to ubicloud-standard-4-arm

switch to ubicloud-standard-4-arm #194

name: macos-precompile
on:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
mix_compile:
runs-on: ${{ matrix.pair.os }}
env:
MIX_ENV: prod
OPENCV_VER: "4.10.0"
EVISION_PREFER_PRECOMPILED: "false"
EVISION_GENERATE_LANG: "erlang,elixir"
strategy:
fail-fast: false
matrix:
include:
- pair:
os: macos-12
arch: x86_64
arch_name: x86_64
NIF_VERSION: "2.16"
OTP_VERSION: "25.3"
ELIXIR_VERSION: "1.16.1"
- pair:
os: macos-14
arch: arm64
arch_name: aarch64
NIF_VERSION: "2.16"
OTP_VERSION: "25.3"
ELIXIR_VERSION: "1.16.1"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Erlang and Elixir
run: |
brew install autoconf coreutils curl git openssl wxwidgets asdf ffmpeg eigen
brew link ffmpeg
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"
asdf install erlang ${{ matrix.pair.OTP_VERSION }}
asdf install elixir ${{ matrix.pair.ELIXIR_VERSION }}
asdf global erlang ${{ matrix.pair.OTP_VERSION }}
asdf global elixir ${{ matrix.pair.ELIXIR_VERSION }}
source $(brew --prefix asdf)/libexec/asdf.sh
mix local.hex --force
mix local.rebar --force
- name: Cache mix packages
id: cache-mix-deps
uses: actions/cache@v4
with:
key: deps-${{ hashFiles('mix.lock') }}
path: |
./deps
- name: Get mix deps
if: steps.cache-mix-deps.outputs.cache-hit != 'true'
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
mix deps.get
- name: Cache OpenCV source code
id: cache-opencv
uses: actions/cache@v4
with:
key: opencv-with-contrib-${{ env.OPENCV_VER }}
path: |
./3rd_party
- name: Download OpenCV source code
if: steps.cache-opencv.outputs.cache-hit != 'true'
run: |
bash scripts/download_opencv.sh ${OPENCV_VER} 3rd_party/cache 3rd_party/opencv/
bash scripts/download_opencv_contrib.sh ${OPENCV_VER} 3rd_party/cache 3rd_party/opencv/
- name: Compile OpenCV (without contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=false
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -rf "./_build/${{ env.MIX_ENV }}/lib/evision"
mix compile_opencv
- name: Mix compile (without contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=false
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mkdir -p lib/generated && mkdir -p src/generated
mix compile
- name: Create precompiled library (without contrib modules)
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a lib/generated "${PKG_NAME}/elixir_generated"
cp -a src/generated "${PKG_NAME}/erlang_generated"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- name: Mix compile (without contrib modules) for Gleam (experimental)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=false
export GLEAM_EVISION=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mix compile
unset GLEAM_EVISION
- name: Create precompiled library (without contrib modules)
run: |
export PKG_NAME=gleam_evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a gleam_src "${PKG_NAME}/gleam_generated"
cp -a src/evision_highgui.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_internal_structurise.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_windows_fix.erl "${PKG_NAME}/gleam_generated/"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- name: Compile OpenCV (with contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -rf "./_build/${{ env.MIX_ENV }}/lib/evision"
mix compile_opencv
- name: Mix compile (with contrib modules)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mkdir -p lib/generated && mkdir -p src/generated
mix compile
- name: Create precompiled library (with contrib modules)
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-contrib-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a lib/generated "${PKG_NAME}/elixir_generated"
cp -a src/generated "${PKG_NAME}/erlang_generated"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- name: Mix compile (with contrib modules) for Gleam (experimental)
run: |
source $(brew --prefix asdf)/libexec/asdf.sh
export EVISION_ENABLE_CONTRIB=true
export GLEAM_EVISION=true
export CMAKE_OPENCV_OPTIONS="-D WITH_FFMPEG=OFF"
if [ "${{ matrix.pair.arch }}" = "arm64" ]; then
export CMAKE_OPENCV_OPTIONS="${CMAKE_OPENCV_OPTIONS} -D WITH_IPP=OFF -D CMAKE_OSX_ARCHITECTURES=arm64"
export CMAKE_EVISION_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64"
fi
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.so
rm -rf lib/generated && rm -rf src/generated
mix compile
- name: Create precompiled library (with contrib modules)
run: |
export PKG_NAME=gleam_evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-apple-darwin-contrib-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
mv "${PRIV_DIR}/include" /tmp/include
cp -a "${PRIV_DIR}" "${PKG_NAME}"
cp -a gleam_src "${PKG_NAME}/gleam_generated"
cp -a src/evision_highgui.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_internal_structurise.erl "${PKG_NAME}/gleam_generated/"
cp -a src/evision_windows_fix.erl "${PKG_NAME}/gleam_generated/"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
ls -lah "${PKG_NAME}.tar.gz"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
cd artifacts
sha256sum "${PKG_NAME}.tar.gz" | tee "${PKG_NAME}.tar.gz.sha256"
mv /tmp/include "${PRIV_DIR}/include"
- uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.gz
artifacts/*.sha256