Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
pull_request:

jobs:
test:
name: Build and test
runs-on: ubuntu-latest
env:
MIX_ENV: test
LIBWBXML_FORCE_BUILD: true

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Elixir and Erlang
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Install native dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libexpat1-dev

- name: Install dependencies
run: mix deps.get

- name: Run tests
run: mix test --warnings-as-errors

- name: Check formatting
run: mix format --check-formatted
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
push:
tags:
- v*

jobs:
release-linux:
name: Release linux
runs-on: ubuntu-latest

env:
MIX_ENV: prod

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Elixir and Erlang
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Install system dependecies
run: |
sudo apt-get update
sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip \
libexpat1-dev

- name: Install dependencies
run: mix deps.get

- name: Create precompiled library
run: |
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
mix elixir_make.precompile

- name: Publish release artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: cache/*.tar.gz

release-macos:
name: Release macos
runs-on: macos-latest

env:
MIX_ENV: prod

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up Elixir and Erlang
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Install dependencies
run: mix deps.get

- name: Create precompiled library
run: |
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
mix elixir_make.precompile

- name: Publish release artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: cache/*.tar.gz
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
elixir 1.19.4-otp-28
erlang 28.3
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ The upstream `libwbxml` sources are vendored in `vendor/libwbxml/` and currently
pinned to `libwbxml-0.11.10` (`e58b1f19f11dbadff53e5b486b8c4b16639a656a`). See
`vendor/libwbxml/VENDORED_VERSION` for the pinned source metadata.

When release artifacts are available, `libwbxml` will prefer downloading a
precompiled NIF for the current target. Set `LIBWBXML_FORCE_BUILD=true` to skip
artifact download and force a local build from the vendored sources.

## Compiler task

* `mix compile` - builds native artefacts through `elixir_make`
* `mix clean` - removes artefacts and the native build directory
* `MIX_ENV=prod mix elixir_make.precompile` - builds release tarballs for the
configured targets

The task runs automatically when the dependency is compiled; you almost never
need to invoke it manually.
Expand All @@ -45,6 +51,19 @@ does **not** attempt to validate the *semantics* of the C library itself - we
trust the upstream test-suite for that - only that our build & FFI plumbing
is correct.

## Release workflow

Create and push a version tag to trigger the release pipeline:

```sh
git tag vX.Y.Z
git push origin vX.Y.Z
```

Pushing a `v*` tag automatically runs `.github/workflows/release.yml`, which
builds the precompiled artifacts, creates or updates the corresponding GitHub
Release, and uploads the generated tarballs.

## License

MIT for the Elixir wrapper. libwbxml itself is LGPL-2.1.
21 changes: 15 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
defmodule Libwbxml.MixProject do
use Mix.Project

@version "0.1.0"
@source_url "https://github.com/Jump-App/libwbxml"

def project do
[
app: :libwbxml,
version: "0.1.0",
elixir: "~> 1.18",
version: @version,
elixir: "~> 1.19",
elixirc_paths: ["lib"],
start_permanent: Mix.env() == :prod,
compilers: [:elixir_make] ++ Mix.compilers(),
make_clean: ["clean"],
make_force_build: System.get_env("LIBWBXML_FORCE_BUILD") == "true",
make_precompiler: {:nif, CCPrecompiler},
make_precompiler_filename: "wbxml_nif",
make_precompiler_url: "#{@source_url}/releases/download/v#{@version}/@{artefact_filename}",
package: package(),
deps: deps()
]
end

defp deps do
[
{:elixir_make, "~> 0.9.0", runtime: false}
{:elixir_make, "~> 0.9.0", runtime: false},
{:cc_precompiler, "~> 0.1", runtime: false}
]
end

defp package do
[
files: [
"lib",
"vendor",
"native",
"vendor",
"Makefile",
"mix.exs"
"mix.exs",
"README.md"
],
maintainers: ["Carson Call"],
maintainers: ["Jump AI"],
licenses: ["MIT"]
]
end
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%{
"cc_precompiler": {:hex, :cc_precompiler, "0.1.11", "8c844d0b9fb98a3edea067f94f616b3f6b29b959b6b3bf25fee94ffe34364768", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3427232caf0835f94680e5bcf082408a70b48ad68a5f5c0b02a3bea9f3a075b9"},
"elixir_cmake": {:hex, :elixir_cmake, "0.8.0", "675a8d0b401096dee01dd5b1108e86e5f399db01c3e34edc0f92034bf38d8764", [:mix], [], "hexpm", "afd87e2ed89dc02eb3efc4e9025a0b79c8322bea8a5f6d9abc6063ca696a67f8"},
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
}
Loading