-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (146 loc) · 5.47 KB
/
Copy pathci.yml
File metadata and controls
173 lines (146 loc) · 5.47 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# ── Test & Lint ──────────────────────────────────────────────────────────────
test:
name: Test & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-targets
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Format check
run: cargo fmt --check
# ── Build Matrix ─────────────────────────────────────────────────────────────
build:
name: Build (${{ matrix.target }})
needs: test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use_cross: false
# - os: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# use_cross: true
- os: macos-latest
target: aarch64-apple-darwin
use_cross: false
# x86_64-apple-darwin removed: ort-sys has no prebuilt ONNX Runtime for
# macOS Intel, and Apple Silicon is the only supported Mac target now.
- os: windows-latest
target: x86_64-pc-windows-msvc
use_cross: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config
- name: Install cross
if: matrix.use_cross
uses: taiki-e/install-action@cross
- name: Build release
if: "!matrix.use_cross"
env:
# ONNX Runtime prebuilts (ort-sys download-binaries) are compiled with
# /MD (dynamic CRT). cc-rs defaults to /MT (static CRT) on MSVC, which
# causes LNK2038 RuntimeLibrary mismatches (ort-sys /MD vs esaxx-rs /MT,
# onig_sys /MT, etc.). Force /MD so all cc-rs builds align with ort-sys.
# MSVC uses "last flag wins", so appending /MD overrides cc-rs's /MT.
CFLAGS_x86_64_pc_windows_msvc: ${{ matrix.target == 'x86_64-pc-windows-msvc' && '/MD' || '' }}
CXXFLAGS_x86_64_pc_windows_msvc: ${{ matrix.target == 'x86_64-pc-windows-msvc' && '/MD' || '' }}
run: cargo build --release --target ${{ matrix.target }}
- name: Build release (cross)
if: matrix.use_cross
run: cross build --release --target ${{ matrix.target }}
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: vectorcode-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/vectorcode
target/${{ matrix.target }}/release/vectorcode.exe
retention-days: 30
# ── Release ──────────────────────────────────────────────────────────────────
release:
name: Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display downloaded artifacts
run: find artifacts -type f -ls
- name: Package release assets
run: |
mkdir -p dist
cd artifacts
for dir in vectorcode-*/; do
target="${dir#vectorcode-}"
target="${target%/}"
# Find the binary (with or without .exe)
binary=""
if [ -f "$dir/vectorcode.exe" ]; then
binary="$dir/vectorcode.exe"
elif [ -f "$dir/vectorcode" ]; then
binary="$dir/vectorcode"
else
echo "WARNING: No binary found in $dir, skipping"
continue
fi
# Create tarball
echo "Packaging $target..."
tmpdir=$(mktemp -d)
cp "$binary" "$tmpdir/vectorcode"
chmod +x "$tmpdir/vectorcode"
tar -czf "../dist/vectorcode-${target}.tar.gz" -C "$tmpdir" vectorcode
rm -rf "$tmpdir"
done
cd ../dist
# Generate checksums
sha256sum *.tar.gz > checksums.txt
cat checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.tar.gz
dist/checksums.txt
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}