Skip to content

cache otp with arch as well #6

cache otp with arch as well

cache otp with arch as well #6

name: macos-precompile
on:
push:
branches:
- 'precompile-woes'
permissions:
contents: write
jobs:
precompile:
runs-on: macos-12
env:
MIX_ENV: prod
strategy:
matrix:
arch:
- x86_64-apple-darwin
# - arm64-apple-darwin
job:
- {otp: "27.0.1", elixir: "1.17.2"}
- {otp: "25.3.2.13", elixir: "1.16.3"}
name: Mac ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache OTP
uses: actions/cache@v3
id: cache-otp
with:
path: ./cache/otp
key: ${{ runner.os }}-otp-${{ matrix.arch }}-${{ matrix.job.otp }}
- name: Install OTP
run: |
mkdir -p ./cache/otp
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.job.otp }}/otp-${{ matrix.arch }}.tar.gz -o ./cache/otp/otp-v${{ matrix.job.otp }}-${{ matrix.arch }}.tar.gz
cd ./cache/otp
tar -xzf otp-v${{ matrix.job.otp }}-${{ matrix.arch }}.tar.gz
- name: Cache Elixir
id: cache-elixir
uses: actions/cache@v3
with:
path: ./cache/elixir
key: ${{ runner.os }}-elixir-${{ matrix.job.elixir }}-${{ matrix.job.otp }}
- name: Download and Compile Elixir
if: steps.cache-elixir.outputs.cache-hit != 'true'
run: |
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
mkdir -p ./cache/elixir
curl -fSL https://github.com/elixir-lang/elixir/archive/refs/tags/v${{ matrix.job.elixir }}.tar.gz -o ./cache/elixir/elixir-${{ matrix.job.elixir }}.tar.gz
cd ./cache/elixir
tar -xzf elixir-${{ matrix.job.elixir }}.tar.gz
cd elixir-${{ matrix.job.elixir }}
make -j$(sysctl -n hw.ncpu) install
- name: Install Mix and Rebar
run: |
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
mix local.hex --force
mix local.rebar --force
# - name: Create precompiled ${{ matrix.arch }} library
# run: |
# export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
# export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
# mkdir -p ./cache/elixir
# curl -fSL https://github.com/elixir-lang/elixir/archive/refs/tags/v${{ matrix.job.elixir }}.tar.gz -o ./cache/elixir/elixir-${{ matrix.job.elixir }}.tar.gz
# cd ./cache/elixir
# tar -xzf elixir-${{ matrix.job.elixir }}.tar.gz
# cd elixir-${{ matrix.job.elixir }}
# make compile
# make -j$(sysctl -n hw.ncpu) install
# mix local.hex --force
# mix local.rebar --force