GitHub Actions: add FreeBSD support for .NET workflow

This commit is contained in:
Syping 2025-11-16 18:31:54 +01:00
parent 728a3dff6c
commit af37275bad

View file

@ -2,9 +2,68 @@ name: .NET
on: push on: push
env: env:
BUILD_TYPE: Release BUILD_TYPE: Release
FREEBSD_DEPLOYMENT_TARGET: "13.2"
OSX_DEPLOYMENT_TARGET: "11.0" OSX_DEPLOYMENT_TARGET: "11.0"
jobs: jobs:
FreeBSD:
runs-on: ${{matrix.runner}}
container:
image: almalinux:8
strategy:
matrix:
arch: [arm64, x64]
include:
- arch: arm64
runner: ubuntu-24.04-arm
image-arch: arm64
triplet-arch: aarch64
- arch: x64
runner: ubuntu-24.04
image-arch: amd64
triplet-arch: x86_64
steps:
- name: Cloning
uses: actions/checkout@v5
- name: Install packages
run: dnf install -y bsdtar clang cmake lld wget
- name: Install FreeBSD sysroot
run: |
mkdir -p /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}
cat > /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/toolchain.cmake << 'EOF'
set(CMAKE_SYSTEM_NAME FreeBSD)
set(CMAKE_SYSTEM_VERSION ${{env.FREEBSD_DEPLOYMENT_TARGET}})
set(CMAKE_SYSTEM_PROCESSOR ${{matrix.triplet-arch}})
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-pc-freebsd${CMAKE_SYSTEM_VERSION})
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-pc-freebsd${CMAKE_SYSTEM_VERSION})
set(CMAKE_SYSROOT /opt/freebsd/${CMAKE_SYSTEM_PROCESSOR}-pc-freebsd${CMAKE_SYSTEM_VERSION}/sysroot)
set(CMAKE_EXE_LINKER_FLAGS_INIT -fuse-ld=lld)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
EOF
mkdir -p /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/sysroot
wget -q https://www.syping.de/freebsd-${{env.FREEBSD_DEPLOYMENT_TARGET}}/${{matrix.image-arch}}/base.txz
bsdtar xfJ base.txz -C /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/sysroot
rm -f base.txz
- name: Configure CMake
run: cmake -B "build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_UNICODE=iconv -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/toolchain.cmake
- name: Build
run: cmake --build "build/shared" --config ${{env.BUILD_TYPE}}
- name: Install
run: cmake --install "build/shared" --config ${{env.BUILD_TYPE}} --prefix "install/shared/"
- name: Preparing for Upload
run: |
mkdir "artifacts"
cp "install/shared/lib/libragephoto.so" "artifacts/"
- name: Upload
uses: actions/upload-artifact@v5
with:
name: FreeBSD ${{matrix.arch}}
path: ${{github.workspace}}/artifacts/
Linux: Linux:
runs-on: ${{matrix.runner}} runs-on: ${{matrix.runner}}
container: container:
@ -36,8 +95,7 @@ jobs:
- name: Preparing for Upload - name: Preparing for Upload
run: | run: |
mkdir "artifacts" mkdir "artifacts"
cp "install/shared/${{matrix.libdir}}/libragephoto.so" \ cp "install/shared/${{matrix.libdir}}/libragephoto.so" "artifacts/"
"artifacts/"
- name: Upload - name: Upload
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5
with: with:
@ -67,8 +125,7 @@ jobs:
- name: Preparing for Upload - name: Preparing for Upload
run: | run: |
mkdir "artifacts" mkdir "artifacts"
cp "install/shared/lib/libragephoto.dylib" \ cp "install/shared/lib/libragephoto.dylib" "artifacts/"
"artifacts/"
- name: Upload - name: Upload
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5
with: with:
@ -109,11 +166,21 @@ jobs:
name: Windows ${{matrix.arch}} name: Windows ${{matrix.arch}}
path: ${{github.workspace}}/artifacts/ path: ${{github.workspace}}/artifacts/
Release: Release:
needs: [Linux, macOS, Windows] needs: [FreeBSD, Linux, macOS, Windows]
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Cloning - name: Cloning
uses: actions/checkout@v5 uses: actions/checkout@v5
- name: Download FreeBSD arm64 Artifacts
uses: actions/download-artifact@v6
with:
name: FreeBSD arm64
path: ${{github.workspace}}/src/dotnet/runtimes/freebsd-arm64/native
- name: Download FreeBSD x64 Artifacts
uses: actions/download-artifact@v6
with:
name: FreeBSD x64
path: ${{github.workspace}}/src/dotnet/runtimes/freebsd-x64/native
- name: Download Linux arm64 glibc Artifacts - name: Download Linux arm64 glibc Artifacts
uses: actions/download-artifact@v6 uses: actions/download-artifact@v6
with: with: