|
1 | 1 | name: Build precompiled NIFs
|
2 | 2 |
|
3 |
| -env: |
4 |
| - NIF_DIRECTORY: "native/ex_tokenizers" |
5 |
| - |
6 | 3 | on:
|
7 | 4 | push:
|
8 | 5 | branches:
|
9 | 6 | - main
|
10 | 7 | paths:
|
11 | 8 | # Just run on main branch if "native" path changed. Tags will always run.
|
12 | 9 | - "native/**"
|
| 10 | + # Also run in case there is any changes to this file. |
| 11 | + - ".github/workflows/release.yml" |
13 | 12 | tags:
|
14 | 13 | - "*"
|
15 | 14 |
|
16 |
| -defaults: |
17 |
| - run: |
18 |
| - # Sets the working dir for "run" scripts. |
19 |
| - # Note that this won't change the directory for actions (tasks with "uses"). |
20 |
| - working-directory: "./native/ex_tokenizers" |
21 |
| - |
22 | 15 | jobs:
|
23 | 16 | build_release:
|
24 |
| - name: NIF ${{ matrix.job.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) |
| 17 | + name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) |
25 | 18 | runs-on: ${{ matrix.job.os }}
|
26 | 19 | strategy:
|
27 | 20 | fail-fast: false
|
28 | 21 | matrix:
|
| 22 | + nif: ["2.15", "2.16", "2.14"] |
29 | 23 | job:
|
30 |
| - # NIF version 2.16 |
31 |
| - - { |
32 |
| - target: arm-unknown-linux-gnueabihf, |
33 |
| - os: ubuntu-20.04, |
34 |
| - nif: "2.16", |
35 |
| - use-cross: true, |
36 |
| - } |
37 |
| - - { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.16", use-cross: true } |
38 |
| - - { target: aarch64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.16", use-cross: true } |
39 |
| - - { target: aarch64-apple-darwin, os: macos-11, nif: "2.16" } |
40 |
| - - { target: riscv64gc-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.16", use-cross: true } |
41 |
| - - { target: x86_64-apple-darwin, os: macos-11, nif: "2.16" } |
42 |
| - - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.16" } |
43 |
| - - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.16", use-cross: true } |
44 |
| - - { target: x86_64-pc-windows-gnu, os: windows-2019, nif: "2.16" } |
45 |
| - - { target: x86_64-pc-windows-msvc, os: windows-2019, nif: "2.16" } |
46 |
| - # NIF version 2.15 |
47 |
| - - { |
48 |
| - target: arm-unknown-linux-gnueabihf, |
49 |
| - os: ubuntu-20.04, |
50 |
| - nif: "2.15", |
51 |
| - use-cross: true, |
52 |
| - } |
53 |
| - - { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.15", use-cross: true } |
54 |
| - - { target: aarch64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.15", use-cross: true } |
55 |
| - - { target: aarch64-apple-darwin, os: macos-11, nif: "2.15" } |
56 |
| - - { target: riscv64gc-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.15", use-cross: true } |
57 |
| - - { target: x86_64-apple-darwin, os: macos-11, nif: "2.15" } |
58 |
| - - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.15" } |
59 |
| - - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.15", use-cross: true } |
60 |
| - - { target: x86_64-pc-windows-gnu, os: windows-2019, nif: "2.15" } |
61 |
| - - { target: x86_64-pc-windows-msvc, os: windows-2019, nif: "2.15" } |
62 |
| - # NIF version 2.14 |
63 |
| - - { |
64 |
| - target: arm-unknown-linux-gnueabihf, |
65 |
| - os: ubuntu-20.04, |
66 |
| - nif: "2.14", |
67 |
| - use-cross: true, |
68 |
| - } |
69 |
| - - { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.14", use-cross: true } |
70 |
| - - { target: aarch64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.14", use-cross: true } |
71 |
| - - { target: aarch64-apple-darwin, os: macos-11, nif: "2.14" } |
72 |
| - - { target: riscv64gc-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.14", use-cross: true } |
73 |
| - - { target: x86_64-apple-darwin, os: macos-11, nif: "2.14" } |
74 |
| - - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.14" } |
75 |
| - - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.14", use-cross: true } |
76 |
| - - { target: x86_64-pc-windows-gnu, os: windows-2019, nif: "2.14" } |
77 |
| - - { target: x86_64-pc-windows-msvc, os: windows-2019, nif: "2.14" } |
| 24 | + - { target: aarch64-apple-darwin, os: macos-11 } |
| 25 | + - { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, use-cross: true } |
| 26 | + - { target: aarch64-unknown-linux-musl, os: ubuntu-20.04, use-cross: true } |
| 27 | + - { target: arm-unknown-linux-gnueabihf, os: ubuntu-20.04, use-cross: true } |
| 28 | + - { target: riscv64gc-unknown-linux-gnu, os: ubuntu-20.04, use-cross: true } |
| 29 | + - { target: x86_64-apple-darwin, os: macos-11 } |
| 30 | + - { target: x86_64-pc-windows-gnu, os: windows-2019 } |
| 31 | + - { target: x86_64-pc-windows-msvc, os: windows-2019 } |
| 32 | + - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 } |
| 33 | + - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, use-cross: true } |
78 | 34 |
|
79 |
| - env: |
80 |
| - RUSTLER_NIF_VERSION: ${{ matrix.job.nif }} |
81 | 35 | steps:
|
82 | 36 | - name: Checkout source code
|
83 |
| - uses: actions/checkout@v2 |
| 37 | + uses: actions/checkout@v3 |
84 | 38 |
|
85 | 39 | - name: Extract crate information
|
86 | 40 | shell: bash
|
87 | 41 | run: |
|
88 |
| - echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV |
89 | 42 | # Get the project version from mix.exs
|
90 |
| - echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' ../../mix.exs | head -n1)" >> $GITHUB_ENV |
| 43 | + echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV |
91 | 44 |
|
92 | 45 | - name: Install Rust toolchain
|
93 |
| - uses: actions-rs/toolchain@v1 |
| 46 | + uses: dtolnay/rust-toolchain@stable |
94 | 47 | with:
|
95 |
| - toolchain: stable |
96 | 48 | target: ${{ matrix.job.target }}
|
97 |
| - override: true |
98 |
| - profile: minimal |
99 |
| - |
100 |
| - - name: Show version information (Rust, cargo, GCC) |
101 |
| - shell: bash |
102 |
| - run: | |
103 |
| - gcc --version || true |
104 |
| - rustup -V |
105 |
| - rustup toolchain list |
106 |
| - rustup default |
107 |
| - cargo -V |
108 |
| - rustc -V |
109 |
| - rustc --print=cfg |
110 | 49 |
|
111 |
| - - name: Download cross from GitHub releases |
112 |
| - uses: giantswarm/[email protected] |
113 |
| - if: ${{ matrix.job.use-cross }} |
| 50 | + - name: Build the project |
| 51 | + id: build-crate |
| 52 | + |
114 | 53 | with:
|
115 |
| - binary: "cross" |
116 |
| - version: "v0.2.4" |
117 |
| - download_url: "https://github.com/cross-rs/cross/releases/download/${version}/cross-x86_64-unknown-linux-gnu.tar.gz" |
118 |
| - tarball_binary_path: "${binary}" |
119 |
| - smoke_test: "${binary} --version" |
120 |
| - |
121 |
| - - name: Build |
122 |
| - shell: bash |
123 |
| - run: | |
124 |
| - if [ "${{ matrix.job.use-cross }}" == "true" ]; then |
125 |
| - cross build --release --target=${{ matrix.job.target }} |
126 |
| - else |
127 |
| - cargo build --release --target=${{ matrix.job.target }} |
128 |
| - fi |
129 |
| -
|
130 |
| - - name: Rename lib to the final name |
131 |
| - id: rename |
132 |
| - shell: bash |
133 |
| - run: | |
134 |
| - LIB_PREFIX="lib" |
135 |
| - case ${{ matrix.job.target }} in |
136 |
| - *-pc-windows-*) LIB_PREFIX="" ;; |
137 |
| - esac; |
138 |
| -
|
139 |
| - # Figure out suffix of lib |
140 |
| - # See: https://doc.rust-lang.org/reference/linkage.html |
141 |
| - LIB_SUFFIX=".so" |
142 |
| - case ${{ matrix.job.target }} in |
143 |
| - *-apple-darwin) LIB_SUFFIX=".dylib" ;; |
144 |
| - *-pc-windows-*) LIB_SUFFIX=".dll" ;; |
145 |
| - esac; |
146 |
| -
|
147 |
| - CICD_INTERMEDIATES_DIR=$(mktemp -d) |
148 |
| -
|
149 |
| - # Setup paths |
150 |
| - LIB_DIR="${CICD_INTERMEDIATES_DIR}/released-lib" |
151 |
| - mkdir -p "${LIB_DIR}" |
152 |
| - LIB_NAME="${LIB_PREFIX}${{ env.PROJECT_NAME }}${LIB_SUFFIX}" |
153 |
| - LIB_PATH="${LIB_DIR}/${LIB_NAME}" |
154 |
| -
|
155 |
| - # Copy the release build lib to the result location |
156 |
| - cp "target/${{ matrix.job.target }}/release/${LIB_NAME}" "${LIB_DIR}" |
157 |
| -
|
158 |
| - # Final paths |
159 |
| - # In the end we use ".so" for MacOS in the final build |
160 |
| - # See: https://www.erlang.org/doc/man/erlang.html#load_nif-2 |
161 |
| - LIB_FINAL_SUFFIX="${LIB_SUFFIX}" |
162 |
| - case ${{ matrix.job.target }} in |
163 |
| - *-apple-darwin) LIB_FINAL_SUFFIX=".so" ;; |
164 |
| - esac; |
165 |
| -
|
166 |
| - LIB_FINAL_NAME="${LIB_PREFIX}${PROJECT_NAME}-v${PROJECT_VERSION}-nif-${RUSTLER_NIF_VERSION}-${{ matrix.job.target }}${LIB_FINAL_SUFFIX}" |
167 |
| -
|
168 |
| - # Copy lib to final name on this directory |
169 |
| - cp "${LIB_PATH}" "${LIB_FINAL_NAME}" |
170 |
| -
|
171 |
| - tar -cvzf "${LIB_FINAL_NAME}.tar.gz" "${LIB_FINAL_NAME}" |
172 |
| -
|
173 |
| - # Passes the path relative to the root of the project. |
174 |
| - LIB_FINAL_PATH="${NIF_DIRECTORY}/${LIB_FINAL_NAME}.tar.gz" |
175 |
| -
|
176 |
| - # Let subsequent steps know where to find the lib |
177 |
| - echo ::set-output name=LIB_FINAL_PATH::${LIB_FINAL_PATH} |
178 |
| - echo ::set-output name=LIB_FINAL_NAME::${LIB_FINAL_NAME}.tar.gz |
| 54 | + nif-version: ${{ matrix.nif }} |
| 55 | + project-dir: "native/ex_tokenizers" |
| 56 | + project-name: ex_tokenizers |
| 57 | + project-version: ${{ env.PROJECT_VERSION }} |
| 58 | + target: ${{ matrix.job.target }} |
| 59 | + use-cross: ${{ matrix.job.use-cross }} |
179 | 60 |
|
180 |
| - - name: "Artifact upload" |
181 |
| - uses: actions/upload-artifact@v2 |
| 61 | + - name: Artifact upload |
| 62 | + uses: actions/upload-artifact@v3 |
182 | 63 | with:
|
183 |
| - name: ${{ steps.rename.outputs.LIB_FINAL_NAME }} |
184 |
| - path: ${{ steps.rename.outputs.LIB_FINAL_PATH }} |
| 64 | + name: ${{ steps.build-crate.outputs.file-name }} |
| 65 | + path: ${{ steps.build-crate.outputs.file-path }} |
185 | 66 |
|
186 | 67 | - name: Publish archives and packages
|
187 | 68 | uses: softprops/action-gh-release@v1
|
188 | 69 | with:
|
189 | 70 | files: |
|
190 |
| - ${{ steps.rename.outputs.LIB_FINAL_PATH }} |
| 71 | + ${{ steps.build-crate.outputs.file-path }} |
191 | 72 | if: startsWith(github.ref, 'refs/tags/')
|
0 commit comments