misc: add support for ios simulator platform (#2) #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: libpupdmd | |
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 "PUPDMD_VERSION_MAJOR\s+[0-9]+" src/pupdmd.h | grep -Eo "[0-9]+") | |
VERSION_MINOR=$(grep -Eo "PUPDMD_VERSION_MINOR\s+[0-9]+" src/pupdmd.h | grep -Eo "[0-9]+") | |
VERSION_PATCH=$(grep -Eo "PUPDMD_VERSION_PATCH\s+[0-9]+" src/pupdmd.h | grep -Eo "[0-9]+") | |
TAG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" | |
echo "${TAG}" | |
echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
build: | |
name: Build libpupdmd-${{ 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: ios-simulator | |
arch: arm64 | |
- os: macos-latest | |
platform: tvos | |
arch: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- if: (matrix.os == 'windows-latest') | |
name: Add msbuild to path (win runner) | |
uses: microsoft/setup-msbuild@v2 | |
- if: (matrix.os == 'macos-latest') | |
name: Add autoconf, automake, and libtool (mac runner) | |
run: | | |
brew install autoconf automake libtool | |
- if: (!(matrix.platform == 'linux' && matrix.arch == 'aarch64')) | |
name: Build libpupdmd-${{ matrix.platform }}-${{ matrix.arch }} | |
run: | | |
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 libpupdmd-${{ 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 | |
NUM_PROCS=$(nproc) | |
cmake -DCMAKE_BUILD_TYPE=Release -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build | |
cmake --build build -- -j${NUM_PROCS} | |
build/pupdmd_test | |
- if: (!(matrix.arch == 'arm64' || matrix.arch == 'arm64-v8a' || matrix.arch == 'aarch64' || matrix.platform == 'win')) | |
name: pupdmd_test | |
run: build/pupdmd_test | |
- name: Prepare artifacts | |
id: artifacts | |
run: | | |
mkdir tmp | |
if [[ "${{ matrix.platform }}" == "win" ]]; then | |
ARTIFACT_PATH="tmp" | |
if [[ "${{ matrix.arch }}" == "x64" ]]; then | |
cp build/Release/*64.lib tmp | |
cp build/Release/*64.dll tmp | |
else | |
cp build/Release/*.lib tmp | |
cp build/Release/*.dll tmp | |
fi | |
cp build/Release/pupdmd_static.lib tmp | |
cp build/Release/pupdmd_test_s.exe tmp | |
cp build/Release/pupdmd_test.exe tmp | |
cp -r test tmp/ | |
else | |
ARTIFACT_PATH="libpupdmd-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz" | |
if [[ "${{ matrix.platform }}" == "macos" ]]; then | |
cp build/libpupdmd.a tmp | |
cp -a build/*.dylib tmp | |
cp build/pupdmd_test_s tmp | |
cp build/pupdmd_test tmp | |
elif [[ "${{ matrix.platform }}" == "linux" ]]; then | |
cp build/libpupdmd.a tmp | |
cp -a build/*.{so,so.*} tmp | |
cp build/pupdmd_test_s tmp | |
cp build/pupdmd_test tmp | |
elif [[ "${{ matrix.platform }}" == "ios" || "${{ matrix.platform }}" == "ios-simulator" || "${{ matrix.platform }}" == "tvos" ]]; then | |
cp build/libpupdmd.a tmp | |
cp -a build/*.dylib tmp | |
elif [[ "${{ matrix.platform }}" == "android" ]]; then | |
cp build/libpupdmd.a tmp | |
cp build/libpupdmd.so tmp | |
fi | |
cp -r test tmp/ | |
cd tmp | |
tar -czvf ../${ARTIFACT_PATH} * | |
fi | |
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libpupdmd-${{ 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 libpupdmd-macos | |
steps: | |
- uses: actions/download-artifact@v4 | |
- name: Unpack artifacts | |
run: | | |
cd libpupdmd-${{ needs.version.outputs.tag }}-macos-x64 | |
tar -xzvf libpupdmd-${{ needs.version.outputs.tag }}-macos-x64.tar.gz | |
cd .. | |
cd libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64 | |
tar -xzvf libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz | |
- name: Combine macos architectures | |
run: | | |
mkdir tmp | |
find "libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64" -name "*.dylib" | while read -r file; do | |
if [ ! -L "$file" ]; then | |
filename=$(basename "$file") | |
lipo -create -output "tmp/$filename" \ | |
"libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64/$filename" \ | |
"libpupdmd-${{ needs.version.outputs.tag }}-macos-x64/$filename" | |
fi | |
done | |
for filename in pupdmd_test_s pupdmd_test; do | |
lipo -create -output "tmp/$filename" \ | |
"libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64/$filename" \ | |
"libpupdmd-${{ needs.version.outputs.tag }}-macos-x64/$filename" | |
done | |
cp -r libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64/test tmp | |
- name: Prepare artifacts | |
run: | | |
cd tmp | |
tar -czvf ../libpupdmd-${{ needs.version.outputs.tag }}-macos.tar.gz * | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libpupdmd-${{ needs.version.outputs.tag }}-macos | |
path: libpupdmd-${{ needs.version.outputs.tag }}-macos.tar.gz | |
- name: Package | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
zip -r libpupdmd-${{ needs.version.outputs.tag }}-win-x64.zip libpupdmd-${{ needs.version.outputs.tag }}-win-x64 | |
zip -r libpupdmd-${{ needs.version.outputs.tag }}-win-x86.zip libpupdmd-${{ needs.version.outputs.tag }}-win-x86 | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
files: | | |
libpupdmd-${{ needs.version.outputs.tag }}-win-x64.zip | |
libpupdmd-${{ needs.version.outputs.tag }}-win-x86.zip | |
libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64/libpupdmd-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-macos-x64/libpupdmd-${{ needs.version.outputs.tag }}-macos-x64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-macos.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-linux-x64/libpupdmd-${{ needs.version.outputs.tag }}-linux-x64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-linux-aarch64/libpupdmd-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-ios-arm64/libpupdmd-${{ needs.version.outputs.tag }}-ios-arm64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-ios-simulator-arm64/libpupdmd-${{ needs.version.outputs.tag }}-ios-simulator-arm64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-tvos-arm64/libpupdmd-${{ needs.version.outputs.tag }}-tvos-arm64.tar.gz | |
libpupdmd-${{ needs.version.outputs.tag }}-android-arm64-v8a/libpupdmd-${{ needs.version.outputs.tag }}-android-arm64-v8a.tar.gz |