Build binaries #81
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: Build binaries | |
on: | |
workflow_dispatch: {} | |
env: | |
OCAML_VERSION: 4.14.1 | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
sdk: "" | |
name: ubuntu | |
- os: macos-13 | |
sdk: "10.11" | |
name: macos-x86_64 | |
- os: macos-latest | |
sdk: "11.0" | |
name: macos-arm64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download older SDK | |
if: matrix.sdk != '' | |
run: | | |
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=${{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@v3 | |
with: | |
ocaml-compiler: ${{ env.OCAML_VERSION }} | |
dune-cache: ${{ matrix.name != 'macos-x86_64' }} | |
- 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 != 'ubuntu' | |
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 | |
- run: mv _build/default/src/stanc/stanc.exe ${{ matrix.name }}-stanc | |
- name: Upload ${{ matrix.name }} stanc | |
uses: actions/upload-artifact@v4 | |
with: | |
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 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install cross-compiler | |
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@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 | |
- run: bash -x scripts/install_build_deps_windows.sh | |
- name: Build | |
run: | | |
opam exec -- dune subst | |
opam exec -- dune build -x windows | |
- run: mv _build/default.windows/src/stanc/stanc.exe windows-stanc | |
- name: Upload Windows stanc | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-stanc | |
path: windows-stanc | |
- run: bash -x scripts/install_js_deps.sh | |
- run: opam exec -- dune build --profile release src/stancjs | |
- run: mv _build/default/src/stancjs/stancjs.bc.js stanc.js | |
- name: Upload stanc.js | |
uses: actions/upload-artifact@v4 | |
with: | |
name: stanc.js | |
path: stanc.js |