-
Notifications
You must be signed in to change notification settings - Fork 8
254 lines (217 loc) · 7.82 KB
/
Copy pathrelease.yml
File metadata and controls
254 lines (217 loc) · 7.82 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
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: riscv64gc-unknown-linux-gnu
arch: riscv64
use_cross: true
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install system dependencies (native build)
if: ${{ !matrix.use_cross }}
run: |
sudo apt-get update
sudo apt-get install -y \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev \
libwayland-dev \
libxkbcommon-dev \
libinput-dev \
libudev-dev \
libseat-dev
- name: Install cross
if: ${{ matrix.use_cross }}
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install just
uses: extractions/setup-just@v3
- name: Build release binary
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
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@v5
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@v6
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@v3
- name: Install Flatpak dependencies
run: just flatpak-deps x86_64
- name: Install Python dependencies
run: pip install aiohttp toml tomlkit
- name: Build Flatpak bundle
run: just flatpak-bundle x86_64
- name: Upload Flatpak artifact
uses: actions/upload-artifact@v5
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@v6
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@v3
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@v3
- name: Install Flatpak dependencies
run: just flatpak-deps aarch64
- name: Install Python dependencies
run: pip install aiohttp toml tomlkit
- name: Build Flatpak bundle
run: just flatpak-bundle aarch64
- name: Upload Flatpak artifact
uses: actions/upload-artifact@v5
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@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Download all artifacts
uses: actions/download-artifact@v6
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-riscv64/camera-riscv64-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 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-riscv64-linux.tar.gz` | Linux binary for RISC-V 64 |
| `camera-${{ github.ref_name }}-source.zip` | Source code |
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
- name: Create GitHub Release
run: |
gh api repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="${{ github.ref_name }}" \
--jq '.body' > release_notes.md
cat release_notes_footer.md >> release_notes.md
gh release create ${{ github.ref_name }} \
--title "Camera ${{ github.ref_name }}" \
--notes-file release_notes.md \
release-assets/*
env:
GH_TOKEN: ${{ github.token }}