Skip to content

Commit 922c071

Browse files
committed
swap to asdf instead
1 parent afd9536 commit 922c071

File tree

2 files changed

+36
-54
lines changed

2 files changed

+36
-54
lines changed

.github/workflows/macos-precompile.yml

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
precompile:
13-
runs-on: macos-12
13+
runs-on: macos-14
1414
env:
1515
MIX_ENV: prod
1616
strategy:
@@ -19,62 +19,57 @@ jobs:
1919
- x86_64-apple-darwin
2020
- arm64-apple-darwin
2121
job:
22-
- {otp: "27.0.1", elixir: "1.17.2"}
23-
- {otp: "25.3.2.13", elixir: "1.16.3"}
22+
- {otp: "27.0.1", elixir: "1.17.2-otp-27"}
23+
- {otp: "25.3.2.13", elixir: "1.16.3-otp-25"}
2424

2525
name: Mac ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v4
2929

30-
- name: Cache OTP
30+
- name: Install asdf
31+
uses: asdf-vm/actions/setup@v2
32+
33+
- name: Cache asdf
34+
id: asdf-cache
3135
uses: actions/cache@v3
32-
id: cache-otp
3336
with:
34-
path: ./cache/otp
35-
key: ${{ runner.os }}-otp-${{ matrix.arch }}-${{ matrix.job.otp }}
37+
path: ~/.asdf
38+
key: asdf-${{ runner.os }}-build-${{ matrix.job.otp }}-${{ matrix.job.elixir }}
3639

37-
- name: Install OTP
38-
if: steps.cache-otp.outputs.cache-hit != 'true'
40+
- if: ${{ steps.asdf-cache.outputs.cache-hit != 'true' }}
41+
name: Install Erlang & Elixir
42+
env:
43+
ELIXIR_VERSION: ${{ matrix.job.elixir }}
44+
OTP_VERSION: ${{ matrix.job.otp }}
3945
run: |
40-
mkdir -p ./cache/otp
41-
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
42-
cd ./cache/otp
43-
tar -xzf otp-v${{ matrix.job.otp }}-${{ matrix.arch }}.tar.gz
46+
asdf plugin-add erlang
47+
asdf install erlang ${OTP_VERSION}
4448
45-
- name: Cache Elixir
46-
id: cache-elixir
47-
uses: actions/cache@v3
48-
with:
49-
path: ./cache/elixir
50-
key: ${{ runner.os }}-elixir-${{ matrix.arch }}-${{ matrix.job.elixir }}-${{ matrix.job.otp }}
49+
ELIXIR_OTP_VERSION=$(echo $OTP_VERSION | cut -d. -f1)
50+
asdf plugin-add elixir
51+
asdf install elixir ${ELIXIR_VERSION}-otp-${ELIXIR_OTP_VERSION}
5152
52-
- name: Download and Compile Elixir
53-
if: steps.cache-elixir.outputs.cache-hit != 'true'
53+
- name: Setup Erlang & Elixir
54+
env:
55+
ELIXIR_VERSION: ${{ matrix.job.elixir }}
56+
OTP_VERSION: ${{ matrix.job.otp }}
5457
run: |
55-
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
56-
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
57-
mkdir -p ./cache/elixir
58-
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
59-
cd ./cache/elixir
60-
tar -xzf elixir-${{ matrix.job.elixir }}.tar.gz
61-
cd elixir-${{ matrix.job.elixir }}
62-
make -j$(sysctl -n hw.ncpu) install
58+
asdf global erlang ${OTP_VERSION}
59+
ELIXIR_OTP_VERSION=$(echo $OTP_VERSION | cut -d. -f1)
60+
asdf global elixir ${ELIXIR_VERSION}-otp-${ELIXIR_OTP_VERSION}
6361
64-
- name: Install Mix and Rebar
62+
- name: Install hex & rebar
6563
run: |
66-
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
67-
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
6864
mix local.hex --force
6965
mix local.rebar --force
7066
71-
- name: Create precompiled ${{ matrix.arch }} library
67+
- run: mix deps.get
68+
69+
- name: Pre-compile NIF library
7270
run: |
73-
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
74-
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
7571
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
7672
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
77-
mix deps.get
7873
mix elixir_make.precompile
7974
8075
- uses: softprops/action-gh-release@v1

mix.exs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ defmodule Exqlite.MixProject do
1717
make_precompiler_url:
1818
"https://github.com/elixir-sqlite/exqlite/releases/download/v#{@version}/@{artefact_filename}",
1919
make_precompiler_filename: "sqlite3_nif",
20-
make_precompiler_nif_versions: [
21-
versions: &nif_versions/1,
22-
fallback_version: fn opts ->
23-
hd(nif_versions(opts))
24-
end
25-
],
20+
make_precompiler_nif_versions: make_precompiler_nif_versions(),
2621
make_env: Application.get_env(:exqlite, :make_env, %{}),
2722
cc_precompiler: cc_precompiler(),
2823
start_permanent: Mix.env() == :prod,
@@ -136,18 +131,10 @@ defmodule Exqlite.MixProject do
136131
]
137132
end
138133

139-
defp nif_versions(opts) do
140-
IO.inspect(opts)
141-
cond do
142-
String.contains?(opts.target, "windows") ->
143-
["2.17"]
144-
145-
String.contains?(opts.target, "darwin") ->
146-
["2.17"]
147-
148-
true ->
149-
["2.16"]
150-
end
134+
def make_precompiler_nif_versions do
135+
[
136+
versions: ["2.16", "2.17"]
137+
]
151138
end
152139

153140
defp cc_precompiler do

0 commit comments

Comments
 (0)