Skip to content

Commit e80c89d

Browse files
committed
Fix precompile build workflows
1 parent db8216a commit e80c89d

File tree

7 files changed

+212
-120
lines changed

7 files changed

+212
-120
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: linux-precompile
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
precompile:
13+
runs-on: ubuntu-20.04
14+
env:
15+
MIX_ENV: prod
16+
strategy:
17+
matrix:
18+
arch:
19+
- x86_64
20+
- aarch64
21+
- riscv64
22+
job:
23+
- {otp: "27", elixir: "1.17"}
24+
- {otp: "25", elixir: "1.16"}
25+
26+
name: Linux ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- uses: erlef/setup-beam@v1
32+
with:
33+
otp-version: ${{ matrix.job.otp }}
34+
elixir-version: ${{ matrix.job.elixir }}
35+
36+
- name: Install system dependecies
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y \
40+
build-essential automake autoconf pkg-config \
41+
bc m4 unzip zip gcc g++
42+
43+
- name: Install x86_64 specific deps
44+
if: matrix.arch == 'x86_64'
45+
run: |
46+
sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu \
47+
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
48+
gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
49+
gcc-s390x-linux-gnu g++-s390x-linux-gnu
50+
51+
- name: Install aarch64 specific deps
52+
if: matrix.arch == 'aarch64'
53+
run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
54+
55+
- name: Install riscv64 specific deps
56+
if: matrix.arch == 'riscv64'
57+
run: sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
58+
59+
- name: Get musl ${{ matrix.arch }} cross-compilers
60+
run: |
61+
wget "https://musl.cc/${{matrix.arch}}-linux-musl-cross.tgz" -O "${{matrix.arch}}-linux-musl-cross.tgz"
62+
tar -xf "${{matrix.arch}}-linux-musl-cross.tgz"
63+
64+
- name: Create precompiled ${{ matrix.arch }} library
65+
run: |
66+
export PATH="$(pwd)/${{ matrix.arch }}-linux-musl-cross/bin:${PATH}"
67+
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
68+
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
69+
mix deps.get
70+
mix elixir_make.precompile
71+
72+
- uses: softprops/action-gh-release@v1
73+
if: startsWith(github.ref, 'refs/tags/')
74+
with:
75+
files: |
76+
cache/*.tar.gz
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: macos-precompile
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
precompile:
13+
runs-on: macos-14
14+
env:
15+
MIX_ENV: prod
16+
strategy:
17+
matrix:
18+
arch:
19+
- x86_64-apple-darwin
20+
- arm64-apple-darwin
21+
job:
22+
- {otp: "27.0.1", elixir: "1.17.2"}
23+
- {otp: "25.3.2.13", elixir: "1.16.3"}
24+
25+
name: Mac ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Install asdf
31+
uses: asdf-vm/actions/setup@v2
32+
33+
- name: Cache asdf
34+
id: asdf-cache
35+
uses: actions/cache@v3
36+
with:
37+
path: ~/.asdf
38+
key: asdf-${{ runner.os }}-build-${{ matrix.job.otp }}-${{ matrix.job.elixir }}
39+
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 }}
45+
run: |
46+
asdf plugin-add erlang
47+
asdf install erlang ${OTP_VERSION}
48+
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}
52+
53+
- name: Setup Erlang & Elixir
54+
env:
55+
ELIXIR_VERSION: ${{ matrix.job.elixir }}
56+
OTP_VERSION: ${{ matrix.job.otp }}
57+
run: |
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}
61+
62+
- name: Install hex & rebar
63+
run: |
64+
mix local.hex --force
65+
mix local.rebar --force
66+
67+
- name: Pre-compile NIF library
68+
run: |
69+
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
70+
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
71+
mix deps.get
72+
mix elixir_make.precompile
73+
74+
- uses: softprops/action-gh-release@v1
75+
if: startsWith(github.ref, 'refs/tags/')
76+
with:
77+
files: |
78+
cache/*.tar.gz

.github/workflows/precompile.yml

Lines changed: 0 additions & 105 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: windows-precompile
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
precompile:
13+
runs-on: windows-2019
14+
env:
15+
MIX_ENV: prod
16+
strategy:
17+
matrix:
18+
arch:
19+
- x64
20+
job:
21+
- {otp: "27", elixir: "1.17"}
22+
- {otp: "25", elixir: "1.14"}
23+
24+
name: Windows ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- uses: erlef/setup-beam@v1
30+
with:
31+
otp-version: ${{ matrix.job.otp }}
32+
elixir-version: ${{ matrix.job.elixir }}
33+
34+
- uses: ilammy/msvc-dev-cmd@v1
35+
with:
36+
arch: ${{ matrix.arch }}
37+
38+
- name: Pre-compile NIF library
39+
shell: bash
40+
run: |
41+
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
42+
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
43+
mix deps.get
44+
mix elixir_make.precompile
45+
46+
- uses: softprops/action-gh-release@v1
47+
if: startsWith(github.ref, 'refs/tags/')
48+
with:
49+
files: |
50+
cache/*.tar.gz

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ exqlite-*.tar
2020
# Temporary files for example tests
2121
/tmp
2222
*.db
23+
24+
# Let the local developer choose
25+
.tool-versions

.tool-versions

Lines changed: 0 additions & 2 deletions
This file was deleted.

mix.exs

Lines changed: 5 additions & 13 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,13 +131,10 @@ defmodule Exqlite.MixProject do
136131
]
137132
end
138133

139-
defp nif_versions(opts) do
140-
if String.contains?(opts.target, "windows") or
141-
String.contains?(opts.target, "darwin") do
142-
["2.16"]
143-
else
144-
["2.15"]
145-
end
134+
def make_precompiler_nif_versions do
135+
[
136+
versions: ["2.16", "2.17"]
137+
]
146138
end
147139

148140
defp cc_precompiler do

0 commit comments

Comments
 (0)