|
| 1 | +# This workflow builds a macOS DMG for distributing Macaulay2. |
| 2 | +# It runs on both Intel (x86_64) and Apple Silicon (arm64) runners. |
| 3 | +# |
| 4 | +# The resulting DMG presents a Macaulay2-VERSION directory alongside a |
| 5 | +# shortcut to /Applications so users can drag it there. After installation, |
| 6 | +# users add /Applications/Macaulay2-VERSION/bin to their PATH. |
| 7 | + |
| 8 | +name: Build macOS DMG |
| 9 | + |
| 10 | +on: |
| 11 | + workflow_dispatch: |
| 12 | + push: |
| 13 | + tags: |
| 14 | + - 'release-*' |
| 15 | + |
| 16 | +defaults: |
| 17 | + run: |
| 18 | + working-directory: M2/BUILD/dmg |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-dmg: |
| 22 | + name: Build DMG (${{ matrix.arch }}) |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - os: macos-14 |
| 29 | + arch: arm64 |
| 30 | + deployment_target: "14.0" |
| 31 | + - os: macos-15-intel |
| 32 | + arch: x86_64 |
| 33 | + deployment_target: "15.0" |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v6 |
| 37 | + |
| 38 | +# ---------------------- |
| 39 | +# Install Homebrew dependencies |
| 40 | +# ---------------------- |
| 41 | + |
| 42 | + - name: Install requirements |
| 43 | + run: | |
| 44 | + brew config |
| 45 | + brew update |
| 46 | + brew tap macaulay2/tap |
| 47 | + # Build tools |
| 48 | + brew install automake bison dylibbundler ccache ctags llvm make yasm googletest r |
| 49 | + brew install texinfo || true |
| 50 | + # M2 library dependencies |
| 51 | + brew install \ |
| 52 | + bdw-gc boost eigen fplll jansson libffi tbb \ |
| 53 | + macaulay2/tap/factory fflas-ffpack flint frobby givaro \ |
| 54 | + mpfi mpsolve ntl \ |
| 55 | + memtailor mathic mathicgb |
| 56 | + brew link macaulay2/tap/factory --force |
| 57 | + # External programs bundled into the DMG |
| 58 | + brew install 4ti2 cohomcalg csdp gfan lrs msolve nauty normaliz topcom |
| 59 | +
|
| 60 | +# ---------------------- |
| 61 | +# Set up build environment |
| 62 | +# ---------------------- |
| 63 | + |
| 64 | + - name: Prepare build environment |
| 65 | + run: | |
| 66 | + echo "$(brew --prefix ccache)/libexec" >> $GITHUB_PATH |
| 67 | + echo "$(brew --prefix make)/libexec/gnubin" >> $GITHUB_PATH |
| 68 | + echo "$(brew --prefix libtool)/libexec/gnubin" >> $GITHUB_PATH |
| 69 | + echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH |
| 70 | + echo "CPPFLAGS=-I$(brew --prefix)/include -I$(brew --prefix libomp)/include -I$(brew --prefix readline)/include" >> $GITHUB_ENV |
| 71 | + echo "LDFLAGS=-L$(brew --prefix)/lib -L$(brew --prefix libomp)/lib -L$(brew --prefix readline)/lib" >> $GITHUB_ENV |
| 72 | + M2_VERSION=$(cat ../../VERSION) |
| 73 | + echo "M2_VERSION=$M2_VERSION" >> $GITHUB_ENV |
| 74 | + echo "PKG_NAME=Macaulay2-$M2_VERSION" >> $GITHUB_ENV |
| 75 | +
|
| 76 | +# ---------------------- |
| 77 | +# Download external programs not available on Homebrew |
| 78 | +# ---------------------- |
| 79 | + |
| 80 | + - name: Download external programs |
| 81 | + run: | |
| 82 | + # phcpack (universal binary) |
| 83 | + curl -fsSL https://github.com/janverschelde/PHCpack/releases/download/v2.4.92/macphc \ |
| 84 | + -o "$RUNNER_TEMP/phc" |
| 85 | + chmod +x "$RUNNER_TEMP/phc" |
| 86 | +
|
| 87 | + # bertini (arm64 only) |
| 88 | + if [ "${{ matrix.arch }}" = "arm64" ]; then |
| 89 | + curl -fsSL https://bertini.nd.edu/BertiniApple_v1.7.tar.gz \ |
| 90 | + | tar -xz -C "$RUNNER_TEMP" |
| 91 | + cp "$RUNNER_TEMP/BertiniApple_v1.7/bertini" "$RUNNER_TEMP/bertini" |
| 92 | + chmod +x "$RUNNER_TEMP/bertini" |
| 93 | + fi |
| 94 | +
|
| 95 | +# ---------------------- |
| 96 | +# Build Macaulay2 and create DMG |
| 97 | +# ---------------------- |
| 98 | + |
| 99 | + - name: Build and package Macaulay2 |
| 100 | + env: |
| 101 | + WORKSPACE: ${{ github.workspace }} |
| 102 | + ARCH: ${{ matrix.arch }} |
| 103 | + DEPLOYMENT_TARGET: ${{ matrix.deployment_target }} |
| 104 | + run: make all |
| 105 | + |
| 106 | +# ---------------------- |
| 107 | +# Test the DMG |
| 108 | +# ---------------------- |
| 109 | + |
| 110 | + - name: Install DMG |
| 111 | + env: |
| 112 | + WORKSPACE: ${{ github.workspace }} |
| 113 | + ARCH: ${{ matrix.arch }} |
| 114 | + run: make install-dmg |
| 115 | + |
| 116 | + - name: Run basic tests |
| 117 | + env: |
| 118 | + WORKSPACE: ${{ github.workspace }} |
| 119 | + ARCH: ${{ matrix.arch }} |
| 120 | + run: make run-basic-tests |
| 121 | + |
| 122 | + - name: Run core tests |
| 123 | + env: |
| 124 | + WORKSPACE: ${{ github.workspace }} |
| 125 | + ARCH: ${{ matrix.arch }} |
| 126 | + run: make run-core-tests |
| 127 | + |
| 128 | + - name: Run package tests |
| 129 | + # x86_64 runners are too slow and time out on --check 3 |
| 130 | + if: matrix.arch == 'arm64' |
| 131 | + env: |
| 132 | + WORKSPACE: ${{ github.workspace }} |
| 133 | + ARCH: ${{ matrix.arch }} |
| 134 | + run: make run-package-tests |
| 135 | + |
| 136 | +# ---------------------- |
| 137 | +# Upload artifacts |
| 138 | +# ---------------------- |
| 139 | + |
| 140 | + - name: Upload build logs |
| 141 | + if: always() |
| 142 | + uses: actions/upload-artifact@v7 |
| 143 | + with: |
| 144 | + name: ${{ env.PKG_NAME }}-${{ matrix.arch }}-logs |
| 145 | + path: | |
| 146 | + M2/BUILD/build/config.log |
| 147 | + M2/BUILD/build/include/* |
| 148 | + M2/BUILD/build/libraries/*/build/*/config.log |
| 149 | +
|
| 150 | + - name: Upload DMG |
| 151 | + if: success() |
| 152 | + uses: actions/upload-artifact@v7 |
| 153 | + with: |
| 154 | + name: ${{ env.PKG_NAME }}-${{ matrix.arch }}-macOS |
| 155 | + path: "*.dmg" |
| 156 | + retention-days: 7 |
0 commit comments