Skip to content

Commit

Permalink
Fix precompile build workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
warmwaffles committed Sep 14, 2024
1 parent db8216a commit e80c89d
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 120 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/linux-precompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: linux-precompile

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
precompile:
runs-on: ubuntu-20.04
env:
MIX_ENV: prod
strategy:
matrix:
arch:
- x86_64
- aarch64
- riscv64
job:
- {otp: "27", elixir: "1.17"}
- {otp: "25", elixir: "1.16"}

name: Linux ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.job.otp }}
elixir-version: ${{ matrix.job.elixir }}

- name: Install system dependecies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential automake autoconf pkg-config \
bc m4 unzip zip gcc g++
- name: Install x86_64 specific deps
if: matrix.arch == 'x86_64'
run: |
sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu \
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
gcc-s390x-linux-gnu g++-s390x-linux-gnu
- name: Install aarch64 specific deps
if: matrix.arch == 'aarch64'
run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

- name: Install riscv64 specific deps
if: matrix.arch == 'riscv64'
run: sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu

- name: Get musl ${{ matrix.arch }} cross-compilers
run: |
wget "https://musl.cc/${{matrix.arch}}-linux-musl-cross.tgz" -O "${{matrix.arch}}-linux-musl-cross.tgz"
tar -xf "${{matrix.arch}}-linux-musl-cross.tgz"
- name: Create precompiled ${{ matrix.arch }} library
run: |
export PATH="$(pwd)/${{ matrix.arch }}-linux-musl-cross/bin:${PATH}"
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
mix deps.get
mix elixir_make.precompile
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
cache/*.tar.gz
78 changes: 78 additions & 0 deletions .github/workflows/macos-precompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: macos-precompile

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
precompile:
runs-on: macos-14
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: Install asdf
uses: asdf-vm/actions/setup@v2

- name: Cache asdf
id: asdf-cache
uses: actions/cache@v3
with:
path: ~/.asdf
key: asdf-${{ runner.os }}-build-${{ matrix.job.otp }}-${{ matrix.job.elixir }}

- if: ${{ steps.asdf-cache.outputs.cache-hit != 'true' }}
name: Install Erlang & Elixir
env:
ELIXIR_VERSION: ${{ matrix.job.elixir }}
OTP_VERSION: ${{ matrix.job.otp }}
run: |
asdf plugin-add erlang
asdf install erlang ${OTP_VERSION}
ELIXIR_OTP_VERSION=$(echo $OTP_VERSION | cut -d. -f1)
asdf plugin-add elixir
asdf install elixir ${ELIXIR_VERSION}-otp-${ELIXIR_OTP_VERSION}
- name: Setup Erlang & Elixir
env:
ELIXIR_VERSION: ${{ matrix.job.elixir }}
OTP_VERSION: ${{ matrix.job.otp }}
run: |
asdf global erlang ${OTP_VERSION}
ELIXIR_OTP_VERSION=$(echo $OTP_VERSION | cut -d. -f1)
asdf global elixir ${ELIXIR_VERSION}-otp-${ELIXIR_OTP_VERSION}
- name: Install hex & rebar
run: |
mix local.hex --force
mix local.rebar --force
- name: Pre-compile NIF library
run: |
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
mix deps.get
mix elixir_make.precompile
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
cache/*.tar.gz
105 changes: 0 additions & 105 deletions .github/workflows/precompile.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/windows-precompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: windows-precompile

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
precompile:
runs-on: windows-2019
env:
MIX_ENV: prod
strategy:
matrix:
arch:
- x64
job:
- {otp: "27", elixir: "1.17"}
- {otp: "25", elixir: "1.14"}

name: Windows ${{ matrix.arch }} - OTP ${{ matrix.job.otp }} - Elixir ${{ matrix.job.elixir }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.job.otp }}
elixir-version: ${{ matrix.job.elixir }}

- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}

- name: Pre-compile NIF library
shell: bash
run: |
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
mix deps.get
mix elixir_make.precompile
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
cache/*.tar.gz
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ exqlite-*.tar
# Temporary files for example tests
/tmp
*.db

# Let the local developer choose
.tool-versions
2 changes: 0 additions & 2 deletions .tool-versions

This file was deleted.

18 changes: 5 additions & 13 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ defmodule Exqlite.MixProject do
make_precompiler_url:
"https://github.com/elixir-sqlite/exqlite/releases/download/v#{@version}/@{artefact_filename}",
make_precompiler_filename: "sqlite3_nif",
make_precompiler_nif_versions: [
versions: &nif_versions/1,
fallback_version: fn opts ->
hd(nif_versions(opts))
end
],
make_precompiler_nif_versions: make_precompiler_nif_versions(),
make_env: Application.get_env(:exqlite, :make_env, %{}),
cc_precompiler: cc_precompiler(),
start_permanent: Mix.env() == :prod,
Expand Down Expand Up @@ -136,13 +131,10 @@ defmodule Exqlite.MixProject do
]
end

defp nif_versions(opts) do
if String.contains?(opts.target, "windows") or
String.contains?(opts.target, "darwin") do
["2.16"]
else
["2.15"]
end
def make_precompiler_nif_versions do
[
versions: ["2.16", "2.17"]
]
end

defp cc_precompiler do
Expand Down

0 comments on commit e80c89d

Please sign in to comment.