Skip to content

Threading

Threading #9

Workflow file for this run

name: libdmdutil
on:
push:
pull_request:
defaults:
run:
shell: bash
jobs:
version:
name: Detect version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: version
run: |
VERSION_MAJOR=$(grep -Eo "DMDUTIL_VERSION_MAJOR\s+[0-9]+" include/DMDUtil/DMDUtil.h | grep -Eo "[0-9]+")
VERSION_MINOR=$(grep -Eo "DMDUTIL_VERSION_MINOR\s+[0-9]+" include/DMDUtil/DMDUtil.h | grep -Eo "[0-9]+")
VERSION_PATCH=$(grep -Eo "DMDUTIL_VERSION_PATCH\s+[0-9]+" include/DMDUtil/DMDUtil.h | grep -Eo "[0-9]+")
TAG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
echo "${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: Build libdmdutil-${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
needs: [ version ]
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: win
arch: x64
- os: windows-latest
platform: win
arch: x86
- os: macos-latest
platform: macos
arch: arm64
- os: macos-latest
platform: macos
arch: x64
- os: ubuntu-latest
platform: linux
arch: x64
- os: ubuntu-latest
platform: linux
arch: aarch64
- os: ubuntu-latest
platform: android
arch: arm64-v8a
- os: macos-latest
platform: ios
arch: arm64
- os: macos-latest
platform: tvos
arch: arm64
steps:
- uses: actions/checkout@v4
- if: (matrix.platform == 'win')
name: Add msbuild to path (win runner)
uses: microsoft/setup-msbuild@v2
- if: (matrix.platform == 'macos')
name: Add autoconf and automake (mac runner)
run: |
brew install autoconf automake
- if: (!(matrix.platform == 'linux' && matrix.arch == 'aarch64'))
name: Build libdmdutil-${{ matrix.platform }}-${{ matrix.arch }}
run: |
./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh
if [[ "${{ matrix.platform }}" == "win" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
else
cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
fi
cmake --build build --config Release
else
if [[ "$(uname)" == "Darwin" ]]; then
NUM_PROCS=$(sysctl -n hw.ncpu)
else
NUM_PROCS=$(nproc)
fi
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
cmake --build build -- -j${NUM_PROCS}
fi
- if: (matrix.platform == 'linux' && matrix.arch == 'aarch64')
name: Build libdmdutil-${{ matrix.platform }}-${{ matrix.arch }} (arm runner)
uses: pguyot/arm-runner-action@v2
with:
base_image: raspios_lite_arm64:latest
image_additional_mb: 4096
cpu: cortex-a53
cpu_info: cpuinfo/raspberrypi_zero2_w_arm64
bind_mount_repository: true
commands: |
apt-get update -y --allow-releaseinfo-change
apt-get install --no-install-recommends -y pkg-config cmake autoconf automake libtool
./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh
NUM_PROCS=$(nproc)
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
cmake --build build -- -j${NUM_PROCS}
- name: Prepare artifacts
id: artifacts
run: |
mkdir tmp
if [[ "${{ matrix.platform }}" == "win" ]]; then
ARTIFACT_PATH="tmp"
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cp build/Release/dmdutil64.lib tmp
cp build/Release/dmdutil64.dll tmp
cp build/Release/zedmd64.lib tmp
cp build/Release/zedmd64.dll tmp
cp build/Release/serum64.lib tmp
cp build/Release/serum64.dll tmp
cp build/Release/libserialport64.lib tmp
cp build/Release/libserialport64.dll tmp
else
cp build/Release/dmdutil.lib tmp
cp build/Release/dmdutil.dll tmp
cp build/Release/zedmd.lib tmp
cp build/Release/zedmd.dll tmp
cp build/Release/serum.lib tmp
cp build/Release/serum.dll tmp
cp build/Release/libserialport.lib tmp
cp build/Release/libserialport.dll tmp
fi
cp build/Release/dmdutil_static.lib tmp
cp build/Release/dmdutil_test_s.exe tmp
cp build/Release/dmdutil_test.exe tmp
else
ARTIFACT_PATH="libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz"
if [[ "${{ matrix.platform }}" == "macos" ]]; then
cp build/libdmdutil.a tmp
cp build/libdmdutil.*.dylib tmp
cp build/libzedmd.*.dylib tmp
cp build/libserum.*.dylib tmp
cp build/libserialport.dylib tmp
cp build/dmdutil_test_s tmp
cp build/dmdutil_test tmp
elif [[ "${{ matrix.platform }}" == "linux" ]]; then
cp build/libdmdutil.a tmp
cp build/libdmdutil.so.* tmp
cp build/libzedmd.so.* tmp
cp build/libserum.so.* tmp
cp build/libserialport.so.* tmp
cp build/dmdutil_test_s tmp
cp build/dmdutil_test tmp
elif [[ "${{ matrix.platform }}" == "ios" || "${{ matrix.platform }}" == "tvos" ]]; then
cp build/libdmdutil.a tmp
cp build/libdmdutil.*.dylib tmp
elif [[ "${{ matrix.platform }}" == "android" ]]; then
cp build/libdmdutil.a tmp
cp build/libdmdutil.so tmp
fi
cd tmp
tar -czvf ../${ARTIFACT_PATH} *
fi
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ${{ steps.artifacts.outputs.artifact_path }}
post-build:
runs-on: macos-latest
needs: [ version, build ]
name: Build libdmdutil-macos
steps:
- uses: actions/download-artifact@v4
- name: Unpack artifacts
run: |
cd libdmdutil-${{ needs.version.outputs.tag }}-macos-x64
tar -xzvf libdmdutil-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
cd ..
cd libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64
tar -xzvf libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
- name: Combine macos architectures
run: |
mkdir tmp
lipo -create -output tmp/libdmdutil-${{ needs.version.outputs.tag }}.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/libdmdutil.${{ needs.version.outputs.tag }}.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/libdmdutil.${{ needs.version.outputs.tag }}.dylib
lipo -create -output tmp/libzedmd.0.5.0.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/libzedmd.0.5.0.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/libzedmd.0.5.0.dylib
lipo -create -output tmp/libserum.1.6.2.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/libserum.1.6.2.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/libserum.1.6.2.dylib
lipo -create -output tmp/libserialport.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/libserialport.dylib \
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/libserialport.dylib
lipo -create -output tmp/dmdutil_test \
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/dmdutil_test \
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/dmdutil_test
lipo -create -output tmp/dmdutil_test_s \
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/dmdutil_test_s \
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/dmdutil_test_s
- name: Prepare artifacts
run: |
cd tmp
tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz *
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libdmdutil-${{ needs.version.outputs.tag }}-macos
path: libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz
- name: Package
if: startsWith(github.ref, 'refs/tags/')
run: |
zip -r libdmdutil-${{ needs.version.outputs.tag }}-win-x64.zip libdmdutil-${{ needs.version.outputs.tag }}-win-x64
zip -r libdmdutil-${{ needs.version.outputs.tag }}-win-x86.zip libdmdutil-${{ needs.version.outputs.tag }}-win-x86
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
libdmdutil-${{ needs.version.outputs.tag }}-win-x64.zip
libdmdutil-${{ needs.version.outputs.tag }}-win-x86.zip
libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64/libdmdutil-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-macos-x64/libdmdutil-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-linux-x64/libdmdutil-${{ needs.version.outputs.tag }}-linux-x64.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-linux-aarch64/libdmdutil-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-ios-arm64/libdmdutil-${{ needs.version.outputs.tag }}-ios-arm64.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-tvos-arm64/libdmdutil-${{ needs.version.outputs.tag }}-tvos-arm64.tar.gz
libdmdutil-${{ needs.version.outputs.tag }}-android-arm64-v8a/libdmdutil-${{ needs.version.outputs.tag }}-android-arm64-v8a.tar.gz