-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from lytedev/master
Add RustlerPrecompiled and setup associated GitHub actions and add document for creating releases
- Loading branch information
Showing
8 changed files
with
217 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
name: Build precompiled NIFs | ||
|
||
env: | ||
NIF_DIRECTORY: "native/jsonrs" | ||
SKIP_JSONRS_BUILD: "true" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
|
||
defaults: | ||
run: | ||
working-directory: "./native/jsonrs" | ||
|
||
jobs: | ||
build_release: | ||
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
nif: ["2.16", "2.15", "2.14"] | ||
job: | ||
- target: arm-unknown-linux-gnueabihf | ||
os: ubuntu-20.04 | ||
use-cross: true | ||
- target: aarch64-unknown-linux-gnu | ||
os: ubuntu-20.04 | ||
use-cross: true | ||
- target: aarch64-apple-darwin | ||
os: macos-11 | ||
- target: x86_64-apple-darwin | ||
os: macos-11 | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-20.04 | ||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-20.04 | ||
use-cross: true | ||
- target: x86_64-pc-windows-gnu | ||
os: windows-2019 | ||
- target: x86_64-pc-windows-msvc | ||
os: windows-2019 | ||
|
||
env: | ||
RUSTLER_NIF_VERSION: ${{ matrix.nif }} | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install prerequisites | ||
shell: bash | ||
run: | | ||
case ${{ matrix.job.target }} in | ||
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; | ||
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; | ||
esac | ||
- name: Extract crate information | ||
shell: bash | ||
run: | | ||
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV | ||
# Get the project version from mix.exs | ||
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' ../../mix.exs | head -n1)" >> $GITHUB_ENV | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: ${{ matrix.job.target }} | ||
override: true | ||
profile: minimal | ||
|
||
- name: Show version | ||
shell: bash | ||
run: | | ||
gcc --version || true | ||
rustup -V | ||
rustup toolchain list | ||
rustup default | ||
cargo -V | ||
rustc -V | ||
rustc --print=cfg | ||
- name: Download cross | ||
uses: giantswarm/install-binary-action@v1.0.0 | ||
if: ${{ matrix.job.use-cross }} | ||
with: | ||
binary: "cross" | ||
version: "v0.2.2" | ||
download_url: "https://github.com/cross-rs/cross/releases/download/${version}/cross-x86_64-unknown-linux-gnu.tar.gz" | ||
tarball_binary_path: "${binary}" | ||
smoke_test: "${binary} --version" | ||
|
||
- name: Build lib | ||
shell: bash | ||
run: | | ||
if [ "${{ matrix.job.use-cross }}" == "true" ]; then | ||
cross build --release --target=${{ matrix.job.target }} | ||
else | ||
cargo build --release --target=${{ matrix.job.target }} | ||
fi | ||
- name: Rename lib | ||
id: rename | ||
shell: bash | ||
run: | | ||
LIB_PREFIX="lib" | ||
case ${{ matrix.job.target }} in | ||
*-pc-windows-*) LIB_PREFIX="" ;; | ||
esac; | ||
# Figure out suffix of lib | ||
# See: https://doc.rust-lang.org/reference/linkage.html | ||
LIB_SUFFIX=".so" | ||
case ${{ matrix.job.target }} in | ||
*-apple-darwin) LIB_SUFFIX=".dylib" ;; | ||
*-pc-windows-*) LIB_SUFFIX=".dll" ;; | ||
esac; | ||
CICD_INTERMEDIATES_DIR=$(mktemp -d) | ||
# Setup paths | ||
LIB_DIR="${CICD_INTERMEDIATES_DIR}/released-lib" | ||
mkdir -p "${LIB_DIR}" | ||
LIB_NAME="${LIB_PREFIX}${{ env.PROJECT_NAME }}${LIB_SUFFIX}" | ||
LIB_PATH="${LIB_DIR}/${LIB_NAME}" | ||
# Copy the release build lib to the result location | ||
cp "target/${{ matrix.job.target }}/release/${LIB_NAME}" "${LIB_DIR}" | ||
# Final paths | ||
# In the end we use ".so" for MacOS in the final build | ||
# See: https://www.erlang.org/doc/man/erlang.html#load_nif-2 | ||
LIB_FINAL_SUFFIX="${LIB_SUFFIX}" | ||
case ${{ matrix.job.target }} in | ||
*-apple-darwin) LIB_FINAL_SUFFIX=".so" ;; | ||
esac; | ||
LIB_FINAL_NAME="${LIB_PREFIX}${PROJECT_NAME}-v${PROJECT_VERSION}-nif-${RUSTLER_NIF_VERSION}-${{ matrix.job.target }}${LIB_FINAL_SUFFIX}" | ||
# Copy lib to final name on this directory | ||
cp "${LIB_PATH}" "${LIB_FINAL_NAME}" | ||
tar -cvzf "${LIB_FINAL_NAME}.tar.gz" "${LIB_FINAL_NAME}" | ||
# Passes the path relative to the root of the project. | ||
LIB_FINAL_PATH="${NIF_DIRECTORY}/${LIB_FINAL_NAME}.tar.gz" | ||
# Let subsequent steps know where to find the lib | ||
echo ::set-output name=LIB_FINAL_PATH::${LIB_FINAL_PATH} | ||
echo ::set-output name=LIB_FINAL_NAME::${LIB_FINAL_NAME}.tar.gz | ||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.rename.outputs.LIB_FINAL_NAME }} | ||
path: ${{ steps.rename.outputs.LIB_FINAL_PATH }} | ||
|
||
- name: Publish archives and packages | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
${{ steps.rename.outputs.LIB_FINAL_PATH }} | ||
if: startsWith(github.ref, 'refs/tags/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Publishing Jsonrs | ||
|
||
From: https://hexdocs.pm/rustler_precompiled/precompilation_guide.html#recommended-flow | ||
|
||
- Bump dep version in `mix.exs` | ||
- `git tag v${mix_version}` the git tag must be `v` prepended to the Mix project version | ||
- `git push --tags` | ||
- Wait for the associated GitHub actions to finish | ||
- Run `mix rustler_precompiled.download Jsonrs --all` | ||
- Release the packge to hex.pm `mix hex.publish` (making sure to include the correct files (**untested!**) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%{ | ||
"jsonrs-v0.2.0-nif-2.14-x86_64-pc-windows-gnu.dll.tar.gz" => "sha256:091a1de3b8e91f1d4757429fa25e900a7c4772ee75c5683e8b9baf74b47e3d83", | ||
"jsonrs-v0.2.0-nif-2.14-x86_64-pc-windows-msvc.dll.tar.gz" => "sha256:88c41a8fcda4b4d41e8312773ca36d8caa47716d1547f6789e4b32399f366759", | ||
"jsonrs-v0.2.0-nif-2.15-x86_64-pc-windows-gnu.dll.tar.gz" => "sha256:9e75646ead58b5bab7137ca231268de764691c2d8d9f6294d9b9871443cbcbc9", | ||
"jsonrs-v0.2.0-nif-2.15-x86_64-pc-windows-msvc.dll.tar.gz" => "sha256:53e754d46534570d44675e77c110872f52a9e5a21ef3a83a1ad3c198a139252a", | ||
"jsonrs-v0.2.0-nif-2.16-x86_64-pc-windows-gnu.dll.tar.gz" => "sha256:668e847f5fc4c4033a929add644a4c98bdf207d914306125210754cce8991f54", | ||
"jsonrs-v0.2.0-nif-2.16-x86_64-pc-windows-msvc.dll.tar.gz" => "sha256:68a6ed5eda6e0a3073107495a255670902a0c9bc11e3514950f548cf89913d5a", | ||
"libjsonrs-v0.2.0-nif-2.14-aarch64-apple-darwin.so.tar.gz" => "sha256:203fa811ac4363c4593cff8a78213f31886582ee912491a78ad578b66a6e1694", | ||
"libjsonrs-v0.2.0-nif-2.14-aarch64-unknown-linux-gnu.so.tar.gz" => "sha256:aaaa1e54468bcecbdf8f7dcbad572215b2540dc3f44029cb7ea6b6873b109175", | ||
"libjsonrs-v0.2.0-nif-2.14-arm-unknown-linux-gnueabihf.so.tar.gz" => "sha256:37e2bf004679408990a1896dc80e597403b84864ed6ccdb236acd60c6aa913e9", | ||
"libjsonrs-v0.2.0-nif-2.14-x86_64-apple-darwin.so.tar.gz" => "sha256:123f78da4898e14f6c633d23a87987be7f88b9d9efad4930d32cb6f66efcb984", | ||
"libjsonrs-v0.2.0-nif-2.14-x86_64-unknown-linux-gnu.so.tar.gz" => "sha256:deaf2c62d3520f36022b2b1248543dd708046cbb7020dc2ffbc96de4a12d28f0", | ||
"libjsonrs-v0.2.0-nif-2.14-x86_64-unknown-linux-musl.so.tar.gz" => "sha256:fe988a3a96bf6a0f0994c834c519f1b1adb1a89b2ff8142995f3b1caa8e0ea68", | ||
"libjsonrs-v0.2.0-nif-2.15-aarch64-apple-darwin.so.tar.gz" => "sha256:985586c3f586a85fee57bfee4e8fe1bd9aef8f614d952caf8dd140a6ac7862b5", | ||
"libjsonrs-v0.2.0-nif-2.15-aarch64-unknown-linux-gnu.so.tar.gz" => "sha256:8b33a4ec99610e906b322debae691b05b77860f86c0b850180fbd87e4afa79b4", | ||
"libjsonrs-v0.2.0-nif-2.15-arm-unknown-linux-gnueabihf.so.tar.gz" => "sha256:1b4b12534ccac3029ec6bc548b0cfb1cd269c93450199e43c379b292cb5afa87", | ||
"libjsonrs-v0.2.0-nif-2.15-x86_64-apple-darwin.so.tar.gz" => "sha256:0d7f3bf8dcb334857da0f3da0e53ffa81b961408a11a4e712a7e7e08141da94a", | ||
"libjsonrs-v0.2.0-nif-2.15-x86_64-unknown-linux-gnu.so.tar.gz" => "sha256:55666fc597508e679ddc34928e10e1b4dc891e9dd5976d1804e2f94c80d34626", | ||
"libjsonrs-v0.2.0-nif-2.15-x86_64-unknown-linux-musl.so.tar.gz" => "sha256:b5cc455d816c9212fa64cc72cddd6ec293e4eb53039d467b94e853482407ad80", | ||
"libjsonrs-v0.2.0-nif-2.16-aarch64-apple-darwin.so.tar.gz" => "sha256:4b26386837e9dad99377f7a694a717a4777eae738fce39b61565cd581ec9c782", | ||
"libjsonrs-v0.2.0-nif-2.16-aarch64-unknown-linux-gnu.so.tar.gz" => "sha256:4bf18417dc2948351ae3c371aa087b3ea7e70f206c5aa4b9e4e0c4f30acd82a0", | ||
"libjsonrs-v0.2.0-nif-2.16-arm-unknown-linux-gnueabihf.so.tar.gz" => "sha256:99e6fca2d05ddfaaf4149b2bd78126cd74b6423d9ca3dee7848e9834c35cd291", | ||
"libjsonrs-v0.2.0-nif-2.16-x86_64-apple-darwin.so.tar.gz" => "sha256:e70f0a442b40ac5c3bb2b8e6b1bda010c3f25fa39b0c9826b540cb1e2d6f4ccd", | ||
"libjsonrs-v0.2.0-nif-2.16-x86_64-unknown-linux-gnu.so.tar.gz" => "sha256:51cff72a837ac36dfd46eba0ca1a33239ca78fe40266a0431c1fb4b9005fe711", | ||
"libjsonrs-v0.2.0-nif-2.16-x86_64-unknown-linux-musl.so.tar.gz" => "sha256:7a389221df15c0d040d2536dca7789ea91c7a72c3ce4569d095eecf87097862c", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[build.env] | ||
passthrough = [ | ||
"RUSTLER_NIF_VERSION" | ||
] |