-
Notifications
You must be signed in to change notification settings - Fork 2
411 lines (374 loc) · 13.6 KB
/
release.yml
File metadata and controls
411 lines (374 loc) · 13.6 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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
name: Release
on:
workflow_dispatch:
inputs:
release_date:
description: "Override date (UTC YYYY.MM.DD). Leave empty for today."
required: false
type: string
dry_run:
description: "Do not push/tag/publish (build only)"
required: false
type: boolean
default: false
permissions:
contents: write
packages: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
jobs:
validate:
name: Validate (fmt, clippy, tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install Linux deps for winit/wgpu
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config libx11-dev libxcb1-dev libxcb-render0-dev \
libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev \
libwayland-dev libudev-dev \
libvulkan-dev libvulkan1 mesa-vulkan-drivers vulkan-tools
- name: Configure Vulkan for headless CI
run: |
echo "WGPU_BACKEND=vulkan" >> "$GITHUB_ENV"
# Prefer Mesa's software Vulkan (lavapipe) for headless availability.
# The exact ICD filename can differ across Ubuntu images, so discover it.
LVP_ICD="$(
if [[ -d /usr/share/vulkan/icd.d ]]; then
find /usr/share/vulkan/icd.d -maxdepth 1 -type f \
\( -name '*lvp_icd*.json' -o -name '*lavapipe*.json' \) \
-print 2>/dev/null | head -n1
fi
)"
if [[ -z "$LVP_ICD" ]]; then
echo "lavapipe Vulkan ICD not found under /usr/share/vulkan/icd.d" >&2
ls -la /usr/share/vulkan/icd.d || true
else
echo "Using lavapipe ICD: $LVP_ICD"
echo "VK_ICD_FILENAMES=$LVP_ICD" >> "$GITHUB_ENV"
fi
echo "LAMBDA_REQUIRE_GPU_ADAPTER=1" >> "$GITHUB_ENV"
vulkaninfo --summary || true
- name: Format check
run: cargo fmt --all -- --check
- name: Clippy
run: |
cargo clippy --workspace \
# Excluded in the release workflow to avoid pulling in Linux ALSA
# build dependencies (`alsa-sys`) that are unnecessary for release
# binaries. Audio/tool validation runs in the CI build matrix when
# audio features are enabled.
--exclude lambda-audio-tool \
# Demo crates are validated in the CI build matrix (compile & test
# workflow). Exclude them here to keep the release workflow focused
# on release artifacts.
--exclude lambda-demos-audio \
--exclude lambda-demos-minimal \
--exclude lambda-demos-render \
--all-targets \
-- -D warnings
- name: Tests
run: |
cargo test --workspace \
# See note above in the Clippy step.
--exclude lambda-audio-tool \
--exclude lambda-demos-audio \
--exclude lambda-demos-minimal \
--exclude lambda-demos-render \
-- --nocapture
prepare_version:
name: Prepare version, tag, push
needs: validate
runs-on: ubuntu-latest
outputs:
version: ${{ steps.setver.outputs.version }}
tag: ${{ steps.setver.outputs.tag }}
commit_sha: ${{ steps.commit.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-workspaces
run: cargo install cargo-workspaces --locked
- name: Compute date-based version
id: setver
shell: bash
run: |
set -euo pipefail
BASE="${{ inputs.release_date }}"
if [[ -z "${BASE}" ]]; then
BASE="$(date -u +%Y.%m.%d)"
fi
git fetch --tags --quiet
LAST=$(git tag -l "v${BASE}*" | sed 's/^v//' | sort -V | tail -n1 || true)
if [[ -z "${LAST}" ]]; then
VERSION="${BASE}"
else
if [[ "${LAST}" == "${BASE}" ]]; then
N=1
else
SUF="${LAST#${BASE}-}"
N=$((10#${SUF} + 1))
fi
VERSION=$(printf "%s-%02d" "${BASE}" "${N}")
fi
echo "version=${VERSION}" | tee -a "$GITHUB_OUTPUT"
echo "tag=v${VERSION}" | tee -a "$GITHUB_OUTPUT"
echo "${VERSION}" > VERSION
- name: Bump workspace versions
if: ${{ !inputs.dry_run }}
shell: bash
run: |
set -euo pipefail
# Update all crate versions and internal dependency requirements
cargo workspaces version ${{ steps.setver.outputs.version }} \
--exact --force --yes --no-git-tag --no-git-commit
# Align lockfile
cargo update -w
- name: Commit and tag
id: commit
if: ${{ !inputs.dry_run }}
shell: bash
run: |
set -euo pipefail
git add -A
git commit -m "[release] v${{ steps.setver.outputs.version }}"
git tag "v${{ steps.setver.outputs.version }}"
git push origin HEAD:${{ github.ref_name }}
git push origin "v${{ steps.setver.outputs.version }}"
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
publish_crates:
name: Publish to crates.io
needs: prepare_version
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- name: Checkout release tag
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
ref: ${{ needs.prepare_version.outputs.tag }}
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-workspaces
run: cargo install cargo-workspaces --locked
- name: Publish workspace
run: |
set -euo pipefail
# Publish in dependency order, skipping those already on the registry
cargo workspaces publish --from-git --yes --skip-published
build:
name: Build artifacts (${{ matrix.os_slug }})
needs: prepare_version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
os_slug: linux
archive: tar.gz
- os: macos-latest
os_slug: macos
archive: tar.gz
- os: windows-latest
os_slug: windows
archive: zip
steps:
- name: Checkout release tag
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
ref: ${{ needs.prepare_version.outputs.tag }}
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
components: clippy,rustfmt
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install jq
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y jq
else
brew update && brew install jq
fi
- name: Install jq (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: choco install jq -y
- name: Build binaries
shell: bash
run: |
set -euo pipefail
# See note in the validate job: `lambda-audio-tool` is excluded here
# to avoid Linux ALSA build dependencies that are unnecessary for
# release artifacts.
cargo build --workspace \
--exclude lambda-audio-tool \
--exclude lambda-demos-audio \
--exclude lambda-demos-minimal \
--exclude lambda-demos-render \
--release \
--bins
- name: Stage files
id: stage
shell: bash
run: |
set -euo pipefail
VERSION='${{ needs.prepare_version.outputs.version }}'
OUTDIR="stage/lambda-${VERSION}-${{ matrix.os_slug }}"
mkdir -p "${OUTDIR}/bin"
# List workspace binary targets
bins=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[].targets[] | select(.kind[]=="bin") | .name' | sort -u)
for b in $bins; do
if [[ "${{ runner.os }}" == "Windows" ]]; then
src="target/release/${b}.exe"
else
src="target/release/${b}"
fi
if [[ -f "$src" ]]; then
cp "$src" "${OUTDIR}/bin/"
fi
done
# Include example 'minimal' if present
if [[ -f target/release/examples/minimal ]]; then
mkdir -p "${OUTDIR}/examples"
cp target/release/examples/minimal "${OUTDIR}/examples/"
elif [[ -f target/release/examples/minimal.exe ]]; then
mkdir -p "${OUTDIR}/examples"
cp target/release/examples/minimal.exe "${OUTDIR}/examples/"
fi
# Include assets if present
if [[ -d crates/lambda-rs/assets ]]; then
mkdir -p "${OUTDIR}/assets"
cp -R crates/lambda-rs/assets/* "${OUTDIR}/assets/" || true
fi
# Top-level docs
for f in LICENSE LICENSE.md README.md README; do
[[ -f "$f" ]] && cp "$f" "${OUTDIR}/" || true
done
echo "${VERSION}" > "${OUTDIR}/VERSION"
- name: Package (tar.gz)
if: ${{ matrix.archive == 'tar.gz' }}
shell: bash
run: |
set -euo pipefail
cd stage
tar -czf "lambda-${{ needs.prepare_version.outputs.version }}-${{ matrix.os_slug }}.tar.gz" "lambda-${{ needs.prepare_version.outputs.version }}-${{ matrix.os_slug }}"
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 "lambda-${{ needs.prepare_version.outputs.version }}-${{ matrix.os_slug }}.tar.gz" > "lambda-${{ needs.prepare_version.outputs.version }}-${{ matrix.os_slug }}.tar.gz.sha256"
elif command -v sha256sum >/dev/null 2>&1; then
sha256sum "lambda-${{ needs.prepare_version.outputs.version }}-${{ matrix.os_slug }}.tar.gz" > "lambda-${{ needs.prepare_version.outputs.version }}-${{ matrix.os_slug }}.tar.gz.sha256"
fi
- name: Package (zip)
if: ${{ matrix.archive == 'zip' }}
shell: pwsh
run: |
$v = "${{ needs.prepare_version.outputs.version }}"
$slug = "${{ matrix.os_slug }}"
$src = "stage/lambda-$v-$slug"
$zip = "stage/lambda-$v-$slug.zip"
Compress-Archive -Path "$src\*" -DestinationPath $zip -CompressionLevel Optimal
(Get-FileHash $zip -Algorithm SHA256).Hash + " *$(Split-Path -Leaf $zip)" | Out-File "$zip.sha256" -Encoding ascii
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os_slug }}
path: stage/*
if-no-files-found: error
release:
name: Create GitHub release
needs: [prepare_version, build, publish_crates]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
steps:
- name: Checkout release tag
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: false
ref: ${{ needs.prepare_version.outputs.tag }}
- name: Generate changelog
id: changelog
shell: bash
run: |
set -euo pipefail
TAG='${{ needs.prepare_version.outputs.tag }}'
VERSION='${{ needs.prepare_version.outputs.version }}'
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
git fetch --tags --quiet
PREV=$(git tag -l 'v*' | sort -V | awk -v t="$TAG" '$0==t{print last; exit} {last=$0}')
if [[ -n "${PREV}" ]]; then
RANGE="${PREV}..${TAG}"
COMPARE_URL="${REPO_URL}/compare/${PREV}...${TAG}"
else
RANGE="${TAG}"
COMPARE_URL="${REPO_URL}/commits/${TAG}"
fi
FILE="CHANGELOG-v${VERSION}.md"
{
echo "# Changelog";
echo;
echo "Version ${TAG}";
echo;
if [[ -n "${PREV}" ]]; then
echo "Changes since ${PREV}";
else
echo "Initial release";
fi
echo;
echo "Compare: ${COMPARE_URL}";
echo;
echo "Commits:";
echo;
} > "${FILE}"
git log --no-merges --pretty=format:"- [%h](${REPO_URL}/commit/%H) %s" ${RANGE} >> "${FILE}"
echo "path=${FILE}" >> "$GITHUB_OUTPUT"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dl
merge-multiple: true
- name: Create release and upload assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare_version.outputs.tag }}
name: "lambda v${{ needs.prepare_version.outputs.version }}"
draft: false
prerelease: false
body_path: ${{ steps.changelog.outputs.path }}
files: |
dl/*.tar.gz
dl/*.tar.gz.sha256
dl/*.zip
dl/*.zip.sha256
${{ steps.changelog.outputs.path }}