-
Notifications
You must be signed in to change notification settings - Fork 3
109 lines (93 loc) · 3.97 KB
/
Copy pathrelease.yml
File metadata and controls
109 lines (93 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Build precompiled NIFs
on:
push:
tags:
- "v*"
jobs:
create_release:
name: Create GitHub release
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "${{ github.ref_name }}" --repo "${{ github.repository }}" --title "${{ github.ref_name }}" --draft
build_release:
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }}${{ matrix.job.variant && format(' ({0})', matrix.job.variant) || '' }}
needs: create_release
runs-on: ${{ matrix.job.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
nif: ["2.15"]
job:
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true }
- { target: x86_64-apple-darwin, os: macos-14, rustflags: "-C target-cpu=x86-64" }
- { target: x86_64-apple-darwin, os: macos-14, rustflags: "-C target-cpu=x86-64-v2", variant: v2 }
- { target: x86_64-apple-darwin, os: macos-14, rustflags: "-C target-cpu=x86-64-v3", variant: v3 }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-cpu=x86-64" }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-cpu=x86-64-v2", variant: v2 }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-cpu=x86-64-v3", variant: v3 }
steps:
- name: Checkout source code
uses: actions/checkout@v6
- name: Extract project version
shell: bash
run: |
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0-precomp
shared-key: ${{ matrix.job.target }}-${{ matrix.nif }}-${{ matrix.job.variant || 'base' }}
- name: Install cross
if: matrix.job.use-cross
shell: bash
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build native library
shell: bash
run: |
if [ -n "${{ matrix.job.rustflags }}" ]; then
export RUSTFLAGS="${{ matrix.job.rustflags }}"
fi
if [ "${{ matrix.job.use-cross }}" = "true" ]; then
RUSTLER_NIF_VERSION=${{ matrix.nif }} cross build --release --target ${{ matrix.job.target }} --package torque_nif
else
RUSTLER_NIF_VERSION=${{ matrix.nif }} cargo build --release --target ${{ matrix.job.target }} --package torque_nif
fi
- name: Package artifact
shell: bash
run: |
TARGET=${{ matrix.job.target }}
VERSION=${{ env.PROJECT_VERSION }}
NIF=${{ matrix.nif }}
if [[ "$TARGET" == *"darwin"* ]]; then
LIB_FILE="target/${TARGET}/release/libtorque_nif.dylib"
else
LIB_FILE="target/${TARGET}/release/libtorque_nif.so"
fi
# RustlerPrecompiled expects the file inside the archive to match this name
VARIANT="${{ matrix.job.variant }}"
NIF_NAME="libtorque_nif-v${VERSION}-nif-${NIF}-${TARGET}"
if [ -n "${VARIANT}" ]; then
NIF_NAME="${NIF_NAME}--${VARIANT}"
fi
NIF_NAME="${NIF_NAME}.so"
cp "${LIB_FILE}" "${NIF_NAME}"
ARCHIVE_NAME="${NIF_NAME}.tar.gz"
tar -czf "${ARCHIVE_NAME}" "${NIF_NAME}"
echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV
- name: Upload to GitHub release
if: startsWith(github.ref, 'refs/tags/')
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.ref_name }}" "${{ env.ARCHIVE_NAME }}" --clobber