Skip to content

switch to ubicloud-standard-4-arm #184

switch to ubicloud-standard-4-arm

switch to ubicloud-standard-4-arm #184

name: windows-precompile
on:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
mix_compile:
runs-on: windows-latest
env:
MIX_ENV: prod
OPENCV_VER: "4.10.0"
ELIXIR_VERSION: "1.15.4"
EVISION_PREFER_PRECOMPILED: "false"
EVISION_GENERATE_LANG: "erlang,elixir"
MAKE: "nmake"
strategy:
fail-fast: false
matrix:
include:
- pair:
arch: arm64
arch_name: aarch64
msbuild_platform: ARM64
vcvarsall: amd64_arm64
OTP_VERSION: "25"
NIF_VERSION: "2.16"
CMAKE_GENERATOR_TYPE: "Visual Studio 17 2022"
CMAKE_TOOLCHAIN_FILE: "cc_toolchain/aarch64-windows-msvc.cmake"
- pair:
arch: x64
arch_name: x86_64
msbuild_platform: x64
vcvarsall: x64
OTP_VERSION: "25"
NIF_VERSION: "2.16"
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.pair.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.pair.vcvarsall }}
- name: Cache mix packages
id: cache-mix-deps
uses: actions/cache@v4
with:
key: deps-${{ hashFiles('mix.lock') }}-${{ matrix.pair.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}
path: |
./deps
- name: Get mix deps
if: steps.cache-mix-deps.outputs.cache-hit != 'true'
shell: bash
run: |
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'
shell: bash
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: Mix compile (without contrib modules)
shell: bash
run: |
export EVISION_ENABLE_CONTRIB=false
if [ "${{ matrix.pair.vcvarsall }}" = "amd64_arm64" ]; then
export CMAKE_GENERATOR_TYPE="${{ matrix.pair.CMAKE_GENERATOR_TYPE }}"
export CMAKE_TOOLCHAIN_FILE="$(pwd)/${{ matrix.pair.CMAKE_TOOLCHAIN_FILE }}"
export MSBUILD_PLATFORM="${{ matrix.pair.msbuild_platform }}"
fi
rm -f Makefile
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.dll
mix compile
- name: Create precompiled library (without contrib modules)
shell: bash
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-windows-msvc-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
export TMP_INCLUDE_DIR="$(pwd)/include"
mv "${PRIV_DIR}/include" "${TMP_INCLUDE_DIR}"
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_DIR}" "${PRIV_DIR}/include"
- name: Mix compile (without contrib modules) for Gleam (experimental)
shell: bash
run: |
export EVISION_ENABLE_CONTRIB=false
export GLEAM_EVISION=true
if [ "${{ matrix.pair.vcvarsall }}" = "amd64_arm64" ]; then
export CMAKE_GENERATOR_TYPE="${{ matrix.pair.CMAKE_GENERATOR_TYPE }}"
export CMAKE_TOOLCHAIN_FILE="$(pwd)/${{ matrix.pair.CMAKE_TOOLCHAIN_FILE }}"
export MSBUILD_PLATFORM="${{ matrix.pair.msbuild_platform }}"
fi
rm -f Makefile
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.dll
mix compile
- name: Create precompiled library (without contrib modules) for Gleam (experimental)
shell: bash
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-windows-msvc-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
export TMP_INCLUDE_DIR="$(pwd)/include"
mv "${PRIV_DIR}/include" "${TMP_INCLUDE_DIR}"
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_DIR}" "${PRIV_DIR}/include"
- name: Mix compile (with contrib modules)
shell: bash
run: |
export EVISION_ENABLE_CONTRIB=true
if [ "${{ matrix.pair.vcvarsall }}" = "amd64_arm64" ]; then
export CMAKE_GENERATOR_TYPE="${{ matrix.pair.CMAKE_GENERATOR_TYPE }}"
export CMAKE_TOOLCHAIN_FILE="$(pwd)/${{ matrix.pair.CMAKE_TOOLCHAIN_FILE }}"
export MSBUILD_PLATFORM="${{ matrix.pair.msbuild_platform }}"
fi
rm -f Makefile
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.dll
mix compile
- name: Create precompiled library (with contrib modules)
shell: bash
run: |
export PKG_NAME=evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-windows-msvc-contrib-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
export TMP_INCLUDE_DIR="$(pwd)/include"
mv "${PRIV_DIR}/include" "${TMP_INCLUDE_DIR}"
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_DIR}" "${PRIV_DIR}/include"
- name: Mix compile (with contrib modules) for Gleam (experimental)
shell: bash
run: |
export EVISION_ENABLE_CONTRIB=true
export GLEAM_EVISION=true
if [ "${{ matrix.pair.vcvarsall }}" = "amd64_arm64" ]; then
export CMAKE_GENERATOR_TYPE="${{ matrix.pair.CMAKE_GENERATOR_TYPE }}"
export CMAKE_TOOLCHAIN_FILE="$(pwd)/${{ matrix.pair.CMAKE_TOOLCHAIN_FILE }}"
export MSBUILD_PLATFORM="${{ matrix.pair.msbuild_platform }}"
fi
rm -f Makefile
rm -f _build/${{ env.MIX_ENV }}/lib/evision/priv/evision.dll
mix compile
- name: Create precompiled library (with contrib modules) for Gleam (experimental)
shell: bash
run: |
export PKG_NAME=gleam_evision-nif_${{ matrix.pair.NIF_VERSION }}-${{ matrix.pair.arch_name }}-windows-msvc-contrib-${GITHUB_REF##*/v}
mkdir -p "${PKG_NAME}"
export PRIV_DIR="$(pwd)/_build/${MIX_ENV}/lib/evision/priv"
export TMP_INCLUDE_DIR="$(pwd)/include"
mv "${PRIV_DIR}/include" "${TMP_INCLUDE_DIR}"
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_DIR}" "${PRIV_DIR}/include"
- uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.gz
artifacts/*.sha256