mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 00:40:47 +00:00
90 lines
2.3 KiB
YAML
90 lines
2.3 KiB
YAML
name: Cross-Compile Shared Libraries
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
artifact: shared-libraries
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Cross-Compile with xgo
|
|
uses: crazy-max/ghaction-xgo@e22d3c8b089adba750d5a74738b8e95d96f0c991 # v3.1.0
|
|
with:
|
|
xgo_version: latest
|
|
go_version: 1.24.7
|
|
dest: dist
|
|
pkg: sharedlibrary
|
|
prefix: cosmium
|
|
targets: linux/amd64,linux/arm64,windows/amd64,windows/arm64,darwin/amd64,darwin/arm64
|
|
v: true
|
|
buildmode: c-shared
|
|
buildvcs: true
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: shared-libraries
|
|
path: dist/*
|
|
|
|
test:
|
|
needs: build
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
lib_ext: amd64.so
|
|
- os: windows-latest
|
|
lib_ext: amd64.dll
|
|
- os: macos-latest
|
|
lib_ext: arm64.dylib
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Download shared libraries
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: shared-libraries
|
|
path: libs
|
|
|
|
- name: Install MinGW (GCC) on Windows
|
|
if: runner.os == 'Windows'
|
|
run: choco install mingw --no-progress
|
|
|
|
- name: Build test loader (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
mkdir build
|
|
gcc -Wall -o build/test_loader.exe sharedlibrary/tests/*.c
|
|
|
|
- name: Build test loader (Unix)
|
|
if: runner.os != 'Windows'
|
|
run: |
|
|
mkdir build
|
|
gcc -Wall -ldl -o build/test_loader sharedlibrary/tests/*.c
|
|
|
|
- name: Run test (Unix)
|
|
if: runner.os != 'Windows'
|
|
run: |
|
|
LIB=$(ls libs/*${{ matrix.lib_ext }} | head -n 1)
|
|
echo "Testing library: $LIB"
|
|
chmod +x build/test_loader
|
|
./build/test_loader "$LIB"
|
|
|
|
- name: Run test (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
$lib = Get-ChildItem "libs/*${{ matrix.lib_ext }}" | Select-Object -First 1
|
|
Write-Host "Testing library: $($lib.FullName)"
|
|
.\build\test_loader.exe $lib.FullName
|