-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (89 loc) · 3.29 KB
/
release.yml
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
name: Create Release and Upload Artifacts
on:
push:
tags:
- "v*"
jobs:
build_and_release:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
feature: [lua54, lua53, lua52, lua51, luajit]
arch: [x86_64, aarch64]
exclude:
- os: windows-latest
arch: aarch64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.arch }}-${{ matrix.os == 'ubuntu-latest' && 'unknown-linux-gnu' || matrix.os == 'macos-latest' && 'apple-darwin' || 'pc-windows-msvc' }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build
shell: bash
run: |
if [ "${{ matrix.arch }}" == "aarch64" ]; then
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --release --features ${{ matrix.feature }} --target aarch64-unknown-linux-gnu
else
cargo build --release --features ${{ matrix.feature }} --target aarch64-apple-darwin
fi
else
cargo build --release --features ${{ matrix.feature }}
fi
- name: Prepare artifact
shell: bash
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
OS="linux"
EXT="so"
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
OS="macOS"
EXT="dylib"
else
OS="windows"
EXT="dll"
fi
ARCH="${{ matrix.arch == 'x86_64' && 'x86_64' || 'arm64' }}"
mkdir -p artifacts
if [ "${{ matrix.arch }}" == "aarch64" ]; then
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
cp target/aarch64-unknown-linux-gnu/release/libtiktoken_core.$EXT artifacts/tiktoken_core-$OS-$ARCH-${{ matrix.feature }}.$EXT
else
cp target/aarch64-apple-darwin/release/libtiktoken_core.$EXT artifacts/tiktoken_core-$OS-$ARCH-${{ matrix.feature }}.$EXT
fi
else
if [ "${{ matrix.os }}" == "windows-latest" ]; then
cp target/release/tiktoken_core.$EXT artifacts/tiktoken_core-$OS-$ARCH-${{ matrix.feature }}.$EXT
else
cp target/release/libtiktoken_core.$EXT artifacts/tiktoken_core-$OS-$ARCH-${{ matrix.feature }}.$EXT
fi
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: tiktoken_core-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.feature }}
path: artifacts/*
release:
needs: build_and_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/**/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}