-
Notifications
You must be signed in to change notification settings - Fork 22
339 lines (290 loc) · 10.1 KB
/
ci.yml
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
name: CI
on:
workflow_dispatch:
pull_request:
push:
schedule:
# Run every 6 days to help us stay on our toes
- cron: '0 0 */6 * *'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt install -y xvfb
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Run bun
run: |
bun install --frozen-lockfile
bun run lint
bun run typecheck
bun run build
deploy-page:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Run bun
run: |
bun install --frozen-lockfile
bun run build
- name: Deploy 🚀
uses: JamesIves/[email protected]
if: success() && github.event_name != 'pull_request'
with:
branch: gh-pages
folder: dist
deploy-electron:
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
suffix: mac
arch: x64
extension: dmg
latestMetadataName: latest-mac.yml
- os: ubuntu-latest
suffix: linux
arch: x86_64
extension: AppImage
latestMetadataName: latest-linux.yml
- os: ubuntu-24-arm
suffix: linux
arch: arm64
extension: AppImage
latestMetadataName: latest-linux-arm64.yml
- os: windows-latest
suffix: win
arch: x64
extension: exe
latestMetadataName: latest.yml
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install snapcraft for arm64
if: matrix.os == 'ubuntu-24-arm'
run: |
sudo apt update
sudo apt install -y --fix-missing snapd
sudo snap install snapcraft --classic
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Set version as environment variable (Windows)
if: matrix.os == 'windows-latest'
run: echo "VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $env:GITHUB_ENV
- name: Set version as environment variable (others)
if: matrix.os != 'windows-latest'
run: echo "VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_ENV
- name: Bun build
run: |
bun install --frozen-lockfile
bun run build
- name: Bun deploy (arm)
if: matrix.os == 'ubuntu-24-arm'
run: |
SNAPCRAFT_BUILD_ENVIRONMENT="host" bun run deploy:electron
- name: Bun deploy (others)
if: matrix.os != 'ubuntu-24-arm'
run: |
bun run deploy:electron
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
path: dist/Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
if-no-files-found: error
- name: Upload diff artifact (mac-only)
if: matrix.os == 'macos-13'
uses: actions/upload-artifact@v4
with:
name: Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.zip
path: dist/Cockpit*.zip
if-no-files-found: error
- name: Upload latest metadata artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.latestMetadataName }}
path: dist/latest*.yml
if-no-files-found: error
- name: Upload binary release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
- name: Upload diff release (mac-only)
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success() && matrix.os == 'macos-13'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.zip
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
- name: Upload latest metadata release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/${{ matrix.latestMetadataName }}
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
deploy-flatpak:
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
suffix: linux
arch: x86_64
extension: flatpak
- os: ubuntu-24-arm
suffix: linux
arch: arm64
extension: flatpak
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install flatpak
run: |
sudo apt update
sudo apt install -y --fix-missing flatpak flatpak-builder
sudo flatpak remote-add --system flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo || true
- name: Set version as environment variable (others)
run: echo "VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_ENV
- name: Build electron (arm)
if: matrix.os == 'ubuntu-24-arm'
run: |
bun install --frozen-lockfile
bun run build
env DEBUG="@malept/flatpak-bundler" bun run deploy:flatpak --arm64
- name: Build electron (x86_64)
if: matrix.os == 'ubuntu-latest'
run: |
bun install --frozen-lockfile
bun run build
env DEBUG="@malept/flatpak-bundler" bun run deploy:flatpak --x64
- name: Rename 'aarch64' to 'arm64'
if: matrix.os == 'ubuntu-24-arm'
run: |
mv dist/Cockpit-${{ matrix.suffix }}-aarch64-${{ env.VERSION }}.${{ matrix.extension }} dist/Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
path: dist/Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
if-no-files-found: error
- name: Upload Release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/') && success()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Cockpit-${{ matrix.suffix }}-${{ matrix.arch }}-${{ env.VERSION }}.${{ matrix.extension }}
tag: ${{ github.ref }}
overwrite: true
prerelease: true
file_glob: true
deploy-blueos-extension:
needs: test
runs-on: ubuntu-latest
env:
PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
steps:
- name: Login to Docker Hub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Build cockpit
run: |
bun install --frozen-lockfile
bun run build
- name: Prepare
id: prepare
run: |
# Deploy image with the name of the branch, if the build is a git tag, replace tag with the tag name.
# If git tag matches semver, append latest tag to the push.
DOCKER_IMAGE=${DOCKER_USERNAME:-bluerobotics}/cockpit
VERSION=${GITHUB_REF##*/}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "buildx_args=${TAGS} --file Dockerfile ." >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Docker Buildx (build)
run: |
docker buildx build \
--output "type=image,push=false" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build \
--output "type=image,push=true" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools \
inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}