-
-
Notifications
You must be signed in to change notification settings - Fork 230
336 lines (291 loc) Β· 12.1 KB
/
__package.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
name: Packaging π¦
on:
workflow_call:
inputs:
commit:
required: false
type: string
tag_name:
required: false
type: string
is_prerelease:
required: false
type: boolean
push:
required: false
type: boolean
architectures:
description: As GitHub Actions doesn't support globals and/or arrays, you must pass this as an string, like '["amd64", "arm64"]'
required: false
type: string
default: '["amd64", "arm64"]'
env:
REGISTRY_IMAGE: jellyfin/jellyfin-vue
RELEASE_TAG: stable
PRERELEASE_TAG: stable-rc
COMMIT_TAG: unstable
DOCKER_BUILD_RECORD_UPLOAD: false
defaults:
run:
shell: bash
jobs:
tauri:
name: Tauri for ${{ matrix.platform }} π₯οΈ
strategy:
fail-fast: false
matrix:
platform:
- MacOS
- Ubuntu
- Windows
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
env:
WORKING_DIR: packaging/tauri
ARTIFACT_NAME: jellyfin-vue_${{ matrix.platform }}
ARTIFACTS_PATH: ${{
format('target/release/{0}', matrix.platform == 'windows' && 'jellyfin-vue-tauri.exe' ||
format('bundle/*/*.{0}', matrix.platform == 'macos' && 'dmg' || 'AppImage'))
}}
runs-on: ${{ matrix.platform }}-latest
steps:
- name: Checkout β¬οΈ
uses: actions/[email protected]
with:
ref: ${{ inputs.commit || github.sha }}
show-progress: false
- name: Setup node environment βοΈ
uses: actions/[email protected]
with:
node-version: lts/*
check-latest: true
cache: 'npm'
- name: Setup Rust Toolchain and cache π¦
uses: actions-rust-lang/[email protected]
with:
cache-key: tauri-${{ runner.os }}
cache-workspaces: ${{ env.WORKING_DIR }}
- name: Install npm dependencies π¦
run: npm ci --no-audit
- name: Install Linux dependencies π¦π§
if: ${{ matrix.platform == 'ubuntu' }}
run: |
sudo apt update -qq
sudo apt install -y --no-install-recommends $(cat apt_packages)
- name: Build application π οΈ
run: npm run build
- name: Upload built application artifact β¬οΈπ§ππͺ
uses: actions/[email protected]
id: artifact
with:
compression-level: 0
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.WORKING_DIR }}/${{ env.ARTIFACTS_PATH }}
- name: Create provenance attestation π
uses: actions/[email protected]
continue-on-error: true
with:
subject-name: ${{ env.ARTIFACT_NAME }}
subject-digest: sha256:${{ steps.artifact.outputs.artifact-digest }}
docker_inputs:
name: Prepare Docker build variables π·οΈπ³
runs-on: ubuntu-latest
outputs:
tags: ${{ env.tags }}
platforms: ${{ env.platforms }}
caches: ${{ env.caches }}
# EOF is needed for multiline environment variables in a GitHub Actions context
steps:
- name: Get current date β
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Parse commit hash βοΈ
if: ${{ inputs.commit != '' }}
id: sha
run: |
PARSEABLE_SHA='${{ inputs.commit }}'
echo "sha=${PARSEABLE_SHA::7}" >> $GITHUB_OUTPUT
## How tags are assigned:
## - 1ΒΊ block: Handle 'stable' release: No commit, is_prerelease=false
## - 2ΒΊ block: Handle 'stable-rc' release: No commit, is_prerelease=true
## - 3ΒΊ block: Handle 'unstable' release: Has commit hash
#
## Before setting as output, we remove the blank lines
- name: Generate tags π·οΈ
run: |
TG='${{ inputs.commit == '' && !inputs.is_prerelease && format('{0}:{1}', env.REGISTRY_IMAGE, 'latest') || '' }}\n'
TG+='${{ inputs.commit == '' && !inputs.is_prerelease && format('{0}:{1}', env.REGISTRY_IMAGE, env.RELEASE_TAG) || '' }}\n'
TG+='${{ inputs.commit == '' && !inputs.is_prerelease && inputs.tag_name && format('{0}:{1}.{2}', env.REGISTRY_IMAGE, env.RELEASE_TAG, inputs.tag_name) || '' }}\n'
TG+='${{ inputs.commit == '' && !inputs.is_prerelease && format('ghcr.io/{0}:{1}', env.REGISTRY_IMAGE, 'latest') || '' }}\n'
TG+='${{ inputs.commit == '' && !inputs.is_prerelease && format('ghcr.io/{0}:{1}', env.REGISTRY_IMAGE, env.RELEASE_TAG) || '' }}\n'
TG+='${{ inputs.commit == '' && !inputs.is_prerelease && inputs.tag_name && format('ghcr.io/{0}:{1}.{2}', env.REGISTRY_IMAGE, env.RELEASE_TAG, inputs.tag_name) || '' }}\n'
TG+='${{ inputs.commit == '' && inputs.is_prerelease && format('{0}:{1}', env.REGISTRY_IMAGE, env.PRERELEASE_TAG) || '' }}\n'
TG+='${{ inputs.commit == '' && inputs.is_prerelease && inputs.tag_name && format('{0}:{1}.{2}', env.REGISTRY_IMAGE, env.PRERELEASE_TAG, inputs.tag_name) || '' }}\n'
TG+='${{ inputs.commit == '' && inputs.is_prerelease && format('ghcr.io/{0}:{1}', env.REGISTRY_IMAGE, env.PRERELEASE_TAG) || '' }}\n'
TG+='${{ inputs.commit == '' && inputs.is_prerelease && inputs.tag_name && format('ghcr.io/{0}:{1}.{2}', env.REGISTRY_IMAGE, env.PRERELEASE_TAG, inputs.tag_name) || '' }}\n'
TG+='${{ inputs.commit != '' && format('{0}:{1}', env.REGISTRY_IMAGE, env.COMMIT_TAG) || '' }}\n'
TG+='${{ inputs.commit != '' && format('{0}:{1}.{2}.{3}', env.REGISTRY_IMAGE, env.COMMIT_TAG, steps.date.outputs.date, steps.sha.outputs.sha) || '' }}\n'
TG+='${{ inputs.commit != '' && format('ghcr.io/{0}:{1}', env.REGISTRY_IMAGE, env.COMMIT_TAG) || '' }}\n'
TG+='${{ inputs.commit != '' && format('ghcr.io/{0}:{1}.{2}.{3}', env.REGISTRY_IMAGE, env.COMMIT_TAG, steps.date.outputs.date, steps.sha.outputs.sha) || '' }}'
echo "tags<<EOF" >> $GITHUB_ENV
echo -e "$TG" | tr -s '\n' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Generate platform array π₯οΈπ
run: |
PARSED_ARRAY=$(echo '${{ inputs.architectures }}' | jq '. | map("linux/" + .) | .[]' | tr -d '"')
echo "platforms<<EOF" >> $GITHUB_ENV
echo "$PARSED_ARRAY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Generate cache array πΎπ
run: |
PARSED_ARRAY=$(echo '${{ inputs.architectures }}' | jq '. | map("type=local,mode=min,src=/tmp/${{ env.REGISTRY_IMAGE }}/cache/buildx-" + .) | .[]' | tr -d '"')
echo "caches<<EOF" >> $GITHUB_ENV
echo "$PARSED_ARRAY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
docker:
name: Docker image for ${{ matrix.platform }} πΏπ³
runs-on: ubuntu-latest
needs: docker_inputs
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(inputs.architectures) }}
env:
ARTIFACT_NAME: docker_image-linux_${{ matrix.platform }}
steps:
- name: Checkout β¬οΈ
uses: actions/[email protected]
with:
ref: ${{ inputs.commit || github.sha }}
show-progress: false
- name: Configure QEMU βοΈ
uses: docker/[email protected]
- name: Configure Docker Buildx βοΈ
uses: docker/[email protected]
- name: Build images π οΈ
uses: docker/[email protected]
id: image
with:
context: .
file: packaging/docker/Dockerfile
platforms: ${{ format('linux/{0}', matrix.platform) }}
cache-from: |
type=gha,scope=buildx-${{ matrix.platform }}
cache-to: |
type=local,mode=min,dest=/tmp/${{ env.REGISTRY_IMAGE }}/cache/${{ matrix.platform }}
type=gha,mode=min,ignore-error=true,scope=buildx-${{ matrix.platform }}
outputs: type=docker,dest=docker_image.tar
build-args: |
${{ inputs.commit == '' && 'IS_STABLE=1' || '' }}
${{ inputs.commit != '' && format('COMMIT_HASH={0}', inputs.commit) || '' }}
tags: |
${{ needs.docker_inputs.outputs.tags }}
- name: Upload Docker image as artifact β¬οΈπ¦
uses: actions/[email protected]
id: artifact
with:
compression-level: 0
name: ${{ env.ARTIFACT_NAME }}
path: docker_image.tar
- name: Create provenance attestation π
uses: actions/[email protected]
continue-on-error: true
with:
subject-name: ${{ env.ARTIFACT_NAME }}
subject-digest: sha256:${{ steps.artifact.outputs.artifact-digest }}
- name: Upload cache artifact β¬οΈβοΈ
uses: actions/[email protected]
if: ${{ inputs.push }}
with:
compression-level: 0
name: buildx-${{ matrix.platform }}
path: |
/tmp/${{ env.REGISTRY_IMAGE }}/cache/${{ matrix.platform }}
frontend:
name: Publish frontend artifact π
runs-on: ubuntu-latest
needs: docker
env:
ARTIFACT_NAME: frontend
steps:
- name: Download Docker image artifact π¦β¬οΈ
uses: actions/[email protected]
with:
name: docker_image-linux_amd64
- name: Extract built client from Docker image ποΈ
run: |
docker load < docker_image.tar
IMAGE_SHA=$(docker images --filter=reference='${{ env.REGISTRY_IMAGE }}' -q | head -n 1)
ASSETS=$(docker inspect $IMAGE_SHA --format='{{range .Config.Env}}{{println .}}{{end}}' | grep ^ASSETS= | cut -d '=' -f2-)
docker cp $(docker create --name jf $IMAGE_SHA):$ASSETS/ ./dist
- name: Upload client artifact β¬οΈπ»
uses: actions/[email protected]
id: artifact
with:
compression-level: 0
name: ${{ env.ARTIFACT_NAME }}
path: dist
- name: Create provenance attestation π
uses: actions/[email protected]
continue-on-error: true
with:
subject-name: ${{ env.ARTIFACT_NAME }}
subject-digest: sha256:${{ steps.artifact.outputs.artifact-digest }}
docker_merge:
name: Merge Docker images πΏπ³
runs-on: ubuntu-latest
if: ${{ inputs.push }}
needs:
- docker
- docker_inputs
steps:
- name: Download cache artifacts π¦β¬οΈ
uses: actions/[email protected]
with:
pattern: buildx-*
path: /tmp/${{ env.REGISTRY_IMAGE }}/cache/
- name: Checkout β¬οΈ
uses: actions/[email protected]
with:
ref: ${{ inputs.commit || github.sha }}
show-progress: false
- name: Configure QEMU βοΈ
uses: docker/[email protected]
- name: Configure Docker Buildx βοΈ
uses: docker/[email protected]
- name: Login to Docker Hub π
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry π
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.JF_BOT_TOKEN }}
- name: Create multiplatform image ${{ inputs.push && 'and push π οΈβ¬οΈ' || 'π οΈ' }}
uses: docker/[email protected]
id: image
with:
context: .
file: packaging/docker/Dockerfile
push: true
provenance: mode=max
sbom: true
cache-from: |
${{ needs.docker_inputs.outputs.caches }}
platforms: |
${{ needs.docker_inputs.outputs.platforms }}
build-args: |
${{ inputs.commit == '' && 'IS_STABLE=1' || '' }}
${{ inputs.commit != '' && format('COMMIT_HASH={0}', inputs.commit) || '' }}
tags: |
${{ needs.docker_inputs.outputs.tags }}
- name: Remove cache artifacts ποΈ
uses: geekyeggo/[email protected]
continue-on-error: true
with:
name: |
buildx-*