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@acf46aa99b919eb9ef6bba89dfd13bafa680667f # v3.2.0 with: xgo_version: latest go_version: 1.25.1 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