Skip to content

v0.3.7

v0.3.7 #62

name: macos-precompile
on:
push:
tags:
- 'v*'
- 'precompile-test'
- 'precompile-test-macos'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
precompile:
runs-on: macos-12
env:
TFLITE_BEAM_PREFER_PRECOMPILED: "false"
name: ${{ matrix.pair.arch }}-apple-darwin - OTP ${{ matrix.pair.otp }}
strategy:
fail-fast: false
matrix:
include:
# remember to change the `get_precompiled_nif_version/0` function in the `tflite_beam_precompiled` file
# if upgrade the Erlang/OTP version to 26.x or later
# 2.16 for OTP 24.x and 25.x
# 2.17 for OTP 26.x
- pair:
otp: "25.3.2.9"
arch: x86_64
libedgetpu_library: darwin_x86_64
- pair:
otp: "25.3.2.9"
arch: aarch64
libedgetpu_library: darwin_arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Erlang and Elixir
run: |
TRIPLET=x86_64-apple-darwin
export PATH=$(pwd)/cache/otp/usr/local/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
mkdir -p ./cache/otp
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.pair.otp }}/otp-${TRIPLET}.tar.gz -o ./cache/otp/otp-v${{ matrix.pair.otp }}-${TRIPLET}.tar.gz
cd ./cache/otp
tar -xzf otp-v${{ matrix.pair.otp }}-${TRIPLET}.tar.gz
wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
./rebar3 local install
- name: Create precompiled library
run: |
export PATH="$(pwd)/cache/otp/usr/local/bin:~/.cache/rebar3/bin:${PATH}"
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
export NIF_VERSION="$(erl -noshell -eval "io:format('~ts', [erlang:system_info(nif_version)])." -s erlang halt)"
if [ "${{ matrix.pair.arch }}" = "aarch64" ]; then
export TARGET_ARCH="${{ matrix.pair.arch }}"
export TARGET_OS="apple"
export TARGET_ABI="darwin"
export CPPFLAGS="-arch arm64"
export CMAKE_TFLITE_OPTIONS="-DCMAKE_OSX_ARCHITECTURES=arm64"
export TFLITE_BEAM_CORAL_LIBEDGETPU_LIBRARIES="aarch64"
fi
echo "TFLITE_BEAM_PREFER_PRECOMPILED: ${TFLITE_BEAM_PREFER_PRECOMPILED}"
echo "TARGET_ARCH: ${TARGET_ARCH}"
echo "TARGET_OS: ${TARGET_OS}"
echo "TARGET_ABI: ${TARGET_ABI}"
rebar3 deps
rebar3 compile
export PKG_NAME=tflite_beam-nif-${NIF_VERSION}-${{ matrix.pair.arch }}-apple-darwin-${GITHUB_REF##*/}
mkdir -p "${PKG_NAME}"
cp -a ./priv "${PKG_NAME}"
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}"
rm -rf "${PKG_NAME}"
mkdir -p artifacts
mv "${PKG_NAME}.tar.gz" artifacts
- uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: artifacts/tflite_beam-*.tar.gz