-
Notifications
You must be signed in to change notification settings - Fork 11
315 lines (274 loc) · 10.4 KB
/
Copy pathrelease.yml
File metadata and controls
315 lines (274 loc) · 10.4 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: Release
run-name: "Release ${{ inputs.version }}${{ inputs.dry_run && ' (dry run)' || '' }}"
on:
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. v0.1.0)"
required: true
type: string
dry_run:
description: "Dry run (skip push/publish)"
required: false
type: boolean
default: false
permissions:
contents: write
packages: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
validate:
name: "Validate ${{ inputs.version }}"
runs-on: ubuntu-latest
steps:
- name: Verify tag exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if ! gh api repos/${{ github.repository }}/git/ref/tags/${{ inputs.version }} &>/dev/null; then
echo "Error: Tag ${{ inputs.version }} does not exist. Run Promote Release first."
exit 1
fi
build:
name: "Build ${{ matrix.target }} (${{ inputs.version }})"
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install cross-compilation dependencies (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo dpkg --add-architecture arm64
# Pin all existing sources to amd64 only
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list 2>/dev/null || true
sudo sed -i 's/^Types: deb$/Types: deb\nArchitectures: amd64/' /etc/apt/sources.list.d/*.sources 2>/dev/null || true
# Add arm64 sources (only ports.ubuntu.com carries arm64)
CODENAME=$(lsb_release -cs)
cat <<EOF | sudo tee /etc/apt/sources.list.d/arm64.list
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME} main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-security main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ ${CODENAME}-backports main restricted universe multiverse
EOF
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libssl-dev:arm64 libsqlite3-dev:arm64
# llama-cpp-sys-4's build script passes the Rust triple as the cmake compiler
# name (aarch64-unknown-linux-gnu-gcc), but Ubuntu ships aarch64-linux-gnu-gcc.
sudo ln -sf /usr/bin/aarch64-linux-gnu-gcc /usr/local/bin/aarch64-unknown-linux-gnu-gcc
sudo ln -sf /usr/bin/aarch64-linux-gnu-g++ /usr/local/bin/aarch64-unknown-linux-gnu-g++
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: brew install protobuf
- name: Free up disk space (Linux)
if: runner.os == 'Linux'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Install Rust
run: |
rustup toolchain install stable
rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} -p skardi-cli
- name: Package binary (Unix)
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../skardi-${{ matrix.target }}.tar.gz skardi
cd ../../..
shasum -a 256 skardi-${{ matrix.target }}.tar.gz > skardi-${{ matrix.target }}.tar.gz.sha256
- name: Upload artifact
if: ${{ !inputs.dry_run }}
uses: actions/upload-artifact@v4
with:
name: skardi-${{ matrix.target }}
path: |
skardi-${{ matrix.target }}.tar.gz
skardi-${{ matrix.target }}.tar.gz.sha256
docker:
name: "Docker ${{ matrix.variant }} (${{ matrix.platform }}, ${{ inputs.version }})"
needs: validate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- variant: default
features: ""
suffix: ""
platform: linux/amd64
runner: ubuntu-latest
- variant: default
features: ""
suffix: ""
platform: linux/arm64
runner: ubuntu-24.04-arm
- variant: rag
features: "rag"
suffix: "-rag"
platform: linux/amd64
runner: ubuntu-latest
- variant: rag
features: "rag"
suffix: "-rag"
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version and repo
id: version
run: |
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
PLATFORM="${{ matrix.platform }}"
echo "arch=${PLATFORM#*/}" >> $GITHUB_OUTPUT
env:
VERSION: ${{ inputs.version }}
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: ${{ !inputs.dry_run }}
platforms: ${{ matrix.platform }}
build-args: |
FEATURES=${{ matrix.features }}
provenance: false
tags: |
ghcr.io/${{ steps.version.outputs.repo }}/skardi-server${{ matrix.suffix }}:${{ steps.version.outputs.version }}-${{ steps.version.outputs.arch }}
cache-from: type=gha,scope=${{ matrix.variant }}-${{ steps.version.outputs.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}-${{ steps.version.outputs.arch }}
docker-manifest:
name: "Docker Manifest ${{ matrix.variant }} (${{ inputs.version }})"
needs: docker
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- variant: default
suffix: ""
- variant: rag
suffix: "-rag"
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version and repo
id: version
run: |
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
echo "repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
env:
VERSION: ${{ inputs.version }}
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Create and push multi-arch manifest
run: |
IMAGE="ghcr.io/${{ steps.version.outputs.repo }}/skardi-server${{ matrix.suffix }}"
VERSION="${{ steps.version.outputs.version }}"
docker manifest create "${IMAGE}:${VERSION}" \
"${IMAGE}:${VERSION}-amd64" \
"${IMAGE}:${VERSION}-arm64"
docker manifest push "${IMAGE}:${VERSION}"
docker manifest create "${IMAGE}:latest" \
"${IMAGE}:${VERSION}-amd64" \
"${IMAGE}:${VERSION}-arm64"
docker manifest push "${IMAGE}:latest"
publish:
name: "Publish to crates.io (${{ inputs.version }})"
needs: validate
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install Rust
run: rustup toolchain install stable
- uses: Swatinem/rust-cache@v2
- name: Publish skardi
run: cargo publish -p skardi ${{ inputs.dry_run && '--dry-run' || '' }}
# skardi-sources is not published yet: it depends on lance via git which crates.io disallows.
# Once lance v4 is stable on crates.io, replace the git deps in Cargo.toml, add it to
# the skardi facade crate, and publish with:
# cargo publish -p skardi-sources (before cargo publish -p skardi)
release:
name: "Create Release (${{ inputs.version }})"
needs: [build, docker-manifest]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download CLI artifacts
if: ${{ !inputs.dry_run }}
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: skardi-*
merge-multiple: true
- name: Create GitHub Release
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
generate_release_notes: true
files: |
artifacts/*
- name: Dry run summary
if: ${{ inputs.dry_run }}
run: echo "Dry run complete. All build steps passed for ${{ inputs.version }}. No artifacts were pushed or published."