Skip to content

Commit

Permalink
Build universal binary in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Jan 2, 2025
1 parent 0419d50 commit fb02868
Showing 1 changed file with 71 additions and 19 deletions.
90 changes: 71 additions & 19 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ jobs:
matrix:
include:
- os: ubuntu-latest
sdk: ""
profile: static
name: ubuntu
- os: macos-13
name: macos
sdk: "10.11"
profile: release
name: macos-x86_64
- os: macos-latest
sdk: "11.0"
profile: release
name: macos-arm64

runs-on: ${{ matrix.os }}

Expand All @@ -24,32 +32,28 @@ jobs:
uses: actions/checkout@v4

- name: Download older SDK
if: matrix.name == 'macos'
if: matrix.sdk != ''
run: |
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.11.sdk.tar.xz
tar -xvf MacOSX10.11.sdk.tar.xz
sudo mv MacOSX10.11.sdk /Library/Developer/CommandLineTools/SDKs
wget https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX${{matrix.sdk}}.sdk.tar.xz
tar -xvf MacOSX${{matrix.sdk}}.sdk.tar.xz
sudo mv MacOSX${{matrix.sdk}}.sdk /Library/Developer/CommandLineTools/SDKs
echo "MACOSX_DEPLOYMENT_TARGET=10.11" >> $GITHUB_ENV
echo "SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.11.sdk/" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=${{matrix.sdk}}" >> $GITHUB_ENV
echo "SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX${{matrix.sdk}}.sdk/" >> $GITHUB_ENV
- name: Use OCaml ${{ env.OCAML_VERSION }}
uses: ocaml/setup-ocaml@v2
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ env.OCAML_VERSION }}
dune-cache: ${{ matrix.name != 'macos-x86_64' }}

- if: matrix.name == 'macos'
- if: matrix.name == 'macos-x86_64'
run: opam pin -y dune 3.6.0 --no-action

- run: bash -x scripts/install_build_deps.sh

- name: Build macos
if: matrix.name == 'macos'
run: opam exec -- dune subst; opam exec -- dune build

- name: Build ubuntu
if: matrix.name == 'ubuntu'
run: opam exec -- dune subst; opam exec -- dune build --profile static
- name: Build ${{ matrix.name }}
run: opam exec -- dune subst; opam exec -- dune build --profile ${{ matrix.profile }}

- run: mv _build/default/src/stanc/stanc.exe ${{ matrix.name }}-stanc

Expand All @@ -59,6 +63,28 @@ jobs:
name: ${{ matrix.name }}-stanc
path: ${{ matrix.name }}-stanc

build-universal:
needs: build
runs-on: macos-latest

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Run lipo
run: |
ls
lipo -create -output macos-stanc macos-*-stanc
lipo -archs macos-stanc
- name: Upload macos-stanc
uses: actions/upload-artifact@v4
with:
name: macos-stanc
path: macos-stanc

build-cross:
runs-on: ubuntu-latest

Expand All @@ -70,13 +96,14 @@ jobs:
run: sudo apt-get update; sudo apt-get install -y gcc-mingw-w64-x86-64

- name: Use OCaml ${{ env.OCAML_VERSION }}
uses: ocaml/setup-ocaml@v2
uses: ocaml/setup-ocaml@v3
with:
cache-prefix: v1-windows
dune-cache: true
ocaml-compiler: ocaml-windows64.${{ env.OCAML_VERSION }}
opam-repositories: |
windows: http://github.com/ocaml-cross/opam-cross-windows.git
default: https://github.com/ocaml/opam-repository.git
windows: http://github.com/ocaml-cross/opam-cross-windows.git
default: https://github.com/ocaml/opam-repository.git
- run: bash -x scripts/install_build_deps_windows.sh

Expand Down Expand Up @@ -104,3 +131,28 @@ jobs:
with:
name: stanc.js
path: stanc.js

test-builds:
strategy:
matrix:
include:
- os: ubuntu-latest
name: ubuntu
- os: macos-latest
name: macos
- os: macos-13
name: macos
- os: windows-latest
name: windows

runs-on: ${{ matrix.os }}

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.name }}-stanc

- name: Run tests
run: |
./${{ matrix.name }}-stanc --help

0 comments on commit fb02868

Please sign in to comment.