-
Notifications
You must be signed in to change notification settings - Fork 9
364 lines (319 loc) · 13.6 KB
/
Copy pathrelease.yml
File metadata and controls
364 lines (319 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
build_aarch64_flatpak:
description: 'Build aarch64 Flatpak (slow, ~6 hours with QEMU)'
required: false
default: false
type: boolean
env:
CARGO_TERM_COLOR: always
jobs:
# Build Linux binaries for multiple architectures
build-binaries:
name: Build Binary (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
arch: x86_64
use_cross: false
- target: aarch64-unknown-linux-gnu
arch: aarch64
use_cross: true
- target: armv7-unknown-linux-gnueabihf
arch: armhf
use_cross: true
- target: riscv64gc-unknown-linux-gnu
arch: riscv64
use_cross: true
- target: x86_64-unknown-linux-musl
arch: x86_64-musl
use_cross: true
- target: aarch64-unknown-linux-musl
arch: aarch64-musl
use_cross: true
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.98.0
targets: ${{ matrix.target }}
- name: Install system dependencies (native build)
if: ${{ !matrix.use_cross }}
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
libwayland-dev \
libxkbcommon-dev \
libinput-dev \
libudev-dev \
libseat-dev \
libclang-dev \
cmake \
nasm \
meson \
ninja-build \
python3-jinja2 \
python3-yaml \
python3-ply \
libyaml-dev
# Built from source: ubuntu-latest (currently Ubuntu 24.04) ships only
# libcamera 0.2.0 in apt. Keep this pinned to the same release and commit as
# the Flatpak manifest until the runner packages libcamera 0.7.2 or newer.
- name: Build and install libcamera 0.7.2 (native build)
if: ${{ !matrix.use_cross }}
run: |
git clone --depth 1 --branch v0.7.2 https://git.libcamera.org/libcamera/libcamera.git /tmp/libcamera
cd /tmp/libcamera
test "$(git rev-parse HEAD)" = 191e202178f02430b5942397c70d215cdd2056fa
meson setup build -Dprefix=/usr -Dpipelines=uvcvideo,simple -Dipas=simple -Dgstreamer=disabled -Dtest=false -Dcam=disabled -Dqcam=disabled -Dlc-compliance=disabled -Dtracing=disabled -Ddocumentation=disabled -Dpycamera=disabled
ninja -C build
sudo ninja -C build install
sudo ldconfig
- name: Install cross
if: ${{ matrix.use_cross }}
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install and verify podman
if: ${{ matrix.use_cross }}
# See the matching step in ci.yml: podman on the current runner image
# cannot start a container with its own crun, which breaks every cross
# build. Smoke test the runtime and fall back to runc when it is broken.
run: |
set -euo pipefail
command -v podman >/dev/null 2>&1 || { sudo apt-get update && sudo apt-get install -y podman; }
echo "podman: $(podman --version)"
echo "crun: $(crun --version 2>/dev/null | head -1 || echo 'not installed')"
echo "runc: $(runc --version 2>/dev/null | head -1 || echo 'not installed')"
# A pull failure (Docker Hub rate limits) must not be mistaken for a
# broken runtime, so only the `run` result decides anything.
probe=docker.io/library/busybox:latest
if ! podman pull -q "$probe" >/dev/null 2>&1; then
echo "::warning::could not pull $probe; skipping OCI runtime check"
exit 0
fi
if podman run --rm "$probe" true; then
echo "Default OCI runtime works"
exit 0
fi
echo "Default OCI runtime cannot start a container; falling back to runc"
if ! command -v runc >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y runc
fi
mkdir -p ~/.config/containers
printf '[engine]\nruntime = "runc"\n' > ~/.config/containers/containers.conf
# Fail here rather than 10 minutes into the build if runc is no better.
podman run --rm "$probe" true
echo "Using runc"
- name: Install just
uses: extractions/setup-just@v4
- name: Build release binary
env:
CROSS_CONTAINER_ENGINE: podman
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
CROSS_BUILD_OPTS="--build-arg RUST_VERSION=$(rustc -V | cut -d' ' -f2)" \
cross build --release --target ${{ matrix.target }}
else
just build-release --target ${{ matrix.target }}
fi
- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/camera dist/
cd dist
tar -czvf camera-${{ matrix.arch }}-linux.tar.gz camera
rm camera
- name: Upload binary artifact
uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.arch }}
path: dist/camera-${{ matrix.arch }}-linux.tar.gz
retention-days: 1
# Build Flatpak for x86_64 (native, fast)
build-flatpak-x86_64:
name: Build Flatpak (x86_64)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Install Flatpak and flatpak-builder
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder
- name: Add Flathub remote
run: sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Install just
uses: extractions/setup-just@v4
- name: Install Flatpak dependencies
run: just flatpak-deps x86_64
- name: Build Flatpak bundle
run: just flatpak-bundle x86_64
- name: Upload Flatpak artifact
uses: actions/upload-artifact@v7
with:
name: flatpak-x86_64
path: camera-x86_64.flatpak
if-no-files-found: error
retention-days: 1
# Build Flatpak for aarch64 (QEMU emulation, slow but necessary for releases)
build-flatpak-aarch64:
name: Build Flatpak (aarch64)
runs-on: ubuntu-latest
# Only run on manual trigger with build_aarch64_flatpak=true
if: github.event_name == 'workflow_dispatch' && inputs.build_aarch64_flatpak
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Install Flatpak and flatpak-builder
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder
- name: Set up QEMU for multi-arch builds
uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- name: Add Flathub remote
run: sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Install just
uses: extractions/setup-just@v4
- name: Install Flatpak dependencies
run: just flatpak-deps aarch64
- name: Build Flatpak bundle
run: just flatpak-bundle aarch64
- name: Upload Flatpak artifact
uses: actions/upload-artifact@v7
with:
name: flatpak-aarch64
path: camera-aarch64.flatpak
if-no-files-found: error
retention-days: 1
# Create the GitHub release with all artifacts
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-binaries, build-flatpak-x86_64, build-flatpak-aarch64]
if: ${{ !cancelled() && needs.build-binaries.result == 'success' && needs.build-flatpak-x86_64.result == 'success' }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release-assets
mv artifacts/binary-x86_64/camera-x86_64-linux.tar.gz release-assets/
mv artifacts/binary-aarch64/camera-aarch64-linux.tar.gz release-assets/
mv artifacts/binary-armhf/camera-armhf-linux.tar.gz release-assets/
mv artifacts/binary-riscv64/camera-riscv64-linux.tar.gz release-assets/
mv artifacts/binary-x86_64-musl/camera-x86_64-musl-linux.tar.gz release-assets/
mv artifacts/binary-aarch64-musl/camera-aarch64-musl-linux.tar.gz release-assets/
mv artifacts/flatpak-x86_64/camera-x86_64.flatpak release-assets/
# aarch64 flatpak is optional (only built when manually triggered)
if [ -d "artifacts/flatpak-aarch64" ]; then
mv artifacts/flatpak-aarch64/camera-aarch64.flatpak release-assets/
fi
git archive --format=zip --prefix=camera-${{ github.ref_name }}/ -o release-assets/camera-${{ github.ref_name }}-source.zip HEAD
- name: Generate Alpine Linux APKBUILD
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
# Download the source tarball that Alpine will use and compute checksum
curl -sL -o /tmp/source.tar.gz \
"https://github.com/${{ github.repository }}/archive/refs/tags/${TAG}.tar.gz"
CHECKSUM=$(sha512sum /tmp/source.tar.gz | awk '{print $1}')
# Generate APKBUILD from template
sed -e "s/@@VERSION@@/${VERSION}/g" \
-e "s/@@CHECKSUM@@/${CHECKSUM}/g" \
.github/APKBUILD.template > release-assets/APKBUILD
echo "Generated APKBUILD for cosmic-ext-camera ${VERSION}"
- name: Generate release notes
run: |
cat << 'EOF' > release_notes_footer.md
## Installation
### Flatpak (Recommended)
```bash
flatpak install camera-x86_64.flatpak
```
### Binary
```bash
tar -xzf camera-x86_64-linux.tar.gz
./camera
```
## Assets
| File | Description |
|------|-------------|
| `camera-x86_64.flatpak` | Flatpak bundle for x86_64 |
| `camera-x86_64-linux.tar.gz` | Linux binary for x86_64 |
| `camera-aarch64-linux.tar.gz` | Linux binary for ARM64 |
| `camera-armhf-linux.tar.gz` | Linux binary for armhf (32-bit) |
| `camera-riscv64-linux.tar.gz` | Linux binary for RISC-V 64 |
| `camera-x86_64-musl-linux.tar.gz` | Linux binary for x86_64 (musl/static) |
| `camera-aarch64-musl-linux.tar.gz` | Linux binary for ARM64 (musl/static) |
| `camera-${{ github.ref_name }}-source.zip` | Source code |
| `APKBUILD` | Alpine Linux package build recipe |
EOF
# Add aarch64 flatpak to release notes if it was built
if [ -f "release-assets/camera-aarch64.flatpak" ]; then
sed -i '/camera-x86_64.flatpak/a | `camera-aarch64.flatpak` | Flatpak bundle for ARM64 |' release_notes_footer.md
fi
# Reconstruct notes from the merged-PR list instead of GitHub's
# releases/generate-notes API. generate-notes matches PRs by merge-commit
# SHA, which the 2026-07 Git LFS history rewrite invalidated for every
# pre-rewrite PR (see create-release.yml for the full explanation). Listing
# merged PRs by merge date is SHA-independent and stays correct going
# forward.
- name: Create GitHub Release
run: |
TAG="${{ github.ref_name }}"
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${TAG}$" | head -1)
{
echo "## What's Changed"
if [ -n "$PREVIOUS_TAG" ]; then
PREV_DATE=$(git log -1 --format=%cI "$PREVIOUS_TAG")
gh pr list --state merged --base main --limit 1000 \
--json number,title,author,mergedAt \
--jq "[.[] | select(.mergedAt > \"$PREV_DATE\")] | sort_by(.mergedAt) | .[] | \"* \(.title) by @\(if (.author.login | startswith(\"app/\")) then (.author.login[4:] + \"[bot]\") else .author.login end) in ${{ github.server_url }}/${{ github.repository }}/pull/\(.number)\""
echo ""
echo "**Full Changelog**: ${{ github.server_url }}/${{ github.repository }}/compare/${PREVIOUS_TAG}...${TAG}"
else
gh pr list --state merged --base main --limit 1000 \
--json number,title,author,mergedAt \
--jq "sort_by(.mergedAt) | .[] | \"* \(.title) by @\(if (.author.login | startswith(\"app/\")) then (.author.login[4:] + \"[bot]\") else .author.login end) in ${{ github.server_url }}/${{ github.repository }}/pull/\(.number)\""
fi
} > release_notes.md
cat release_notes_footer.md >> release_notes.md
gh release create "$TAG" \
--title "Camera ${TAG}" \
--notes-file release_notes.md \
release-assets/*
env:
GH_TOKEN: ${{ github.token }}