Skip to content

Commit 89fdcd5

Browse files
committed
Update github ci and bump version|
1 parent 904fdf8 commit 89fdcd5

File tree

2 files changed

+25
-98
lines changed

2 files changed

+25
-98
lines changed
Lines changed: 24 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,67 @@
11
name: Build precompiled NIFs
22

3-
env:
4-
NIF_DIRECTORY: "native/excoding"
5-
63
on:
74
push:
85
tags:
96
- '*'
107

11-
defaults:
12-
run:
13-
# Sets the working dir for "run" scripts.
14-
# Note that this won't change the directory for actions (tasks with "uses").
15-
working-directory: "./native/excoding"
16-
178
jobs:
189
build_release:
1910
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
2011
runs-on: ${{ matrix.job.os }}
2112
strategy:
2213
fail-fast: false
2314
matrix:
24-
nif: ["2.16", "2.15", "2.14"]
15+
nif: ["2.16", "2.15"]
2516
job:
2617
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
2718
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
19+
- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
20+
- { target: riscv64gc-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
2821
- { target: aarch64-apple-darwin , os: macos-11 }
2922
- { target: x86_64-apple-darwin , os: macos-11 }
3023
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
3124
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
3225
- { target: x86_64-pc-windows-gnu , os: windows-2019 }
3326
- { target: x86_64-pc-windows-msvc , os: windows-2019 }
3427

35-
env:
36-
RUSTLER_NIF_VERSION: ${{ matrix.nif }}
3728
steps:
3829
- name: Checkout source code
39-
uses: actions/checkout@v2
30+
uses: actions/checkout@v3
4031

41-
- name: Install prerequisites
42-
shell: bash
43-
run: |
44-
case ${{ matrix.job.target }} in
45-
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
46-
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
47-
esac
48-
- name: Extract crate information
32+
- name: Extract project version
4933
shell: bash
5034
run: |
51-
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
5235
# Get the project version from mix.exs
53-
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' ../../mix.exs | head -n1)" >> $GITHUB_ENV
36+
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
37+
5438
- name: Install Rust toolchain
55-
uses: actions-rs/toolchain@v1
39+
uses: dtolnay/rust-toolchain@stable
5640
with:
5741
toolchain: stable
5842
target: ${{ matrix.job.target }}
59-
override: true
60-
profile: minimal
6143

62-
- name: Show version information (Rust, cargo, GCC)
63-
shell: bash
64-
run: |
65-
gcc --version || true
66-
rustup -V
67-
rustup toolchain list
68-
rustup default
69-
cargo -V
70-
rustc -V
71-
rustc --print=cfg
72-
- name: Download cross from GitHub releases
73-
uses: giantswarm/install-binary-action@v1.0.0
74-
if: ${{ matrix.job.use-cross }}
44+
- name: Build the project
45+
id: build-crate
46+
uses: philss/rustler-precompiled-action@v1.0.0
7547
with:
76-
binary: "cross"
77-
version: "v0.2.2"
78-
download_url: "https://github.com/cross-rs/cross/releases/download/${version}/cross-x86_64-unknown-linux-gnu.tar.gz"
79-
tarball_binary_path: "${binary}"
80-
smoke_test: "${binary} --version"
48+
project-name: example
49+
project-version: ${{ env.PROJECT_VERSION }}
50+
target: ${{ matrix.job.target }}
51+
nif-version: ${{ matrix.nif }}
52+
use-cross: ${{ matrix.job.use-cross }}
53+
project-dir: "native/example"
8154

82-
- name: Build
83-
shell: bash
84-
run: |
85-
if [ "${{ matrix.job.use-cross }}" == "true" ]; then
86-
cross build --release --target=${{ matrix.job.target }}
87-
else
88-
cargo build --release --target=${{ matrix.job.target }}
89-
fi
90-
- name: Rename lib to the final name
91-
id: rename
92-
shell: bash
93-
run: |
94-
LIB_PREFIX="lib"
95-
case ${{ matrix.job.target }} in
96-
*-pc-windows-*) LIB_PREFIX="" ;;
97-
esac;
98-
# Figure out suffix of lib
99-
# See: https://doc.rust-lang.org/reference/linkage.html
100-
LIB_SUFFIX=".so"
101-
case ${{ matrix.job.target }} in
102-
*-apple-darwin) LIB_SUFFIX=".dylib" ;;
103-
*-pc-windows-*) LIB_SUFFIX=".dll" ;;
104-
esac;
105-
CICD_INTERMEDIATES_DIR=$(mktemp -d)
106-
# Setup paths
107-
LIB_DIR="${CICD_INTERMEDIATES_DIR}/released-lib"
108-
mkdir -p "${LIB_DIR}"
109-
LIB_NAME="${LIB_PREFIX}${{ env.PROJECT_NAME }}${LIB_SUFFIX}"
110-
LIB_PATH="${LIB_DIR}/${LIB_NAME}"
111-
# Copy the release build lib to the result location
112-
cp "target/${{ matrix.job.target }}/release/${LIB_NAME}" "${LIB_DIR}"
113-
# Final paths
114-
# In the end we use ".so" for MacOS in the final build
115-
# See: https://www.erlang.org/doc/man/erlang.html#load_nif-2
116-
LIB_FINAL_SUFFIX="${LIB_SUFFIX}"
117-
case ${{ matrix.job.target }} in
118-
*-apple-darwin) LIB_FINAL_SUFFIX=".so" ;;
119-
esac;
120-
LIB_FINAL_NAME="${LIB_PREFIX}${PROJECT_NAME}-v${PROJECT_VERSION}-nif-${RUSTLER_NIF_VERSION}-${{ matrix.job.target }}${LIB_FINAL_SUFFIX}"
121-
# Copy lib to final name on this directory
122-
cp "${LIB_PATH}" "${LIB_FINAL_NAME}"
123-
tar -cvzf "${LIB_FINAL_NAME}.tar.gz" "${LIB_FINAL_NAME}"
124-
# Passes the path relative to the root of the project.
125-
LIB_FINAL_PATH="${NIF_DIRECTORY}/${LIB_FINAL_NAME}.tar.gz"
126-
# Let subsequent steps know where to find the lib
127-
echo ::set-output name=LIB_FINAL_PATH::${LIB_FINAL_PATH}
128-
echo ::set-output name=LIB_FINAL_NAME::${LIB_FINAL_NAME}.tar.gz
129-
- name: "Artifact upload"
130-
uses: actions/upload-artifact@v2
55+
- name: Artifact upload
56+
uses: actions/upload-artifact@v3
13157
with:
132-
name: ${{ steps.rename.outputs.LIB_FINAL_NAME }}
133-
path: ${{ steps.rename.outputs.LIB_FINAL_PATH }}
58+
name: ${{ steps.build-crate.outputs.file-name }}
59+
path: ${{ steps.build-crate.outputs.file-path }}
13460

13561
- name: Publish archives and packages
13662
uses: softprops/action-gh-release@v1
13763
with:
13864
files: |
139-
${{ steps.rename.outputs.LIB_FINAL_PATH }}
140-
if: startsWith(github.ref, 'refs/tags/')
65+
${{ steps.build-crate.outputs.file-path }}
66+
if: startsWith(github.ref, 'refs/tags/')
67+

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Excoding.MixProject do
22
use Mix.Project
33

4-
@version "0.1.2"
4+
@version "0.1.3"
55

66
def project do
77
[

0 commit comments

Comments
 (0)