aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release-build.yaml
blob: 2d72b3d46052172f7fb536c91607b2f483095ac8 (plain)
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
name: "Release Build"

on:
  workflow_dispatch:
    inputs:
      version:
        required: true
        type: string
        description: 'The server and web stable release tag ("vX.Y.Z") or "master"'

permissions:
  contents: read

jobs:
  Docker:
    runs-on: ubuntu-22.04
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Log in to Docker Hub"
        uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: "Log in to the GHCR Container registry"
        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
        with:
          registry: ghcr.io
          username: ${{ secrets.GHCR_USERNAME }}
          password: ${{ secrets.GHCR_TOKEN }}

      - name: "Run builder for Docker containers"
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} docker

  Debian:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        release:
          - bullseye
          - bookworm
        arch:
          - amd64
          - arm64
          - armhf
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Run builder for ${{ matrix.version }} ${{ matrix.arch }}"
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} debian ${{ matrix.arch }} ${{ matrix.release }}

      - name: "Upload artifacts to repository server"
        uses: appleboy/scp-action@v0.1.7
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          source: "out/debian/*"
          strip_components: 2
          target: "/srv/incoming/${{ env.JELLYFIN_VERSION }}/debian/${{ matrix.arch }}/${{ matrix.release }}"

      - name: "Import artifacts into reprepro -V"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: false
          script: |
            set -o xtrace
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                COMPONENT="main"
            else
                COMPONENT="unstable"
            fi
            # Only include the architecture-dependent deb here, as the others are done only for amd64
            sudo reprepro -V --waitforlock 30 --basedir /srv/debian --component ${COMPONENT} includedeb ${{ matrix.release }} /srv/incoming/${{ env.JELLYFIN_VERSION }}/debian/${{ matrix.arch }}/${{ matrix.release }}/*_${{ matrix.arch }}.deb || exit 1
            if [[ ${{ matrix.arch }} == "amd64" ]]; then
                # Only include the architecture-independent packages for amd64; the other architectures are the same and conflict
                sudo reprepro -V --waitforlock 30 --basedir /srv/debian --component ${COMPONENT} includedeb ${{ matrix.release }} /srv/incoming/${{ env.JELLYFIN_VERSION }}/debian/${{ matrix.arch }}/${{ matrix.release }}/*_all.deb || exit 1
                # Only include the source DSC for amd64; the other architectures are the same and conflict
                sudo reprepro -V --waitforlock 30 --basedir /srv/debian --component ${COMPONENT} includedsc ${{ matrix.release }} /srv/incoming/${{ env.JELLYFIN_VERSION }}/debian/${{ matrix.arch }}/${{ matrix.release }}/*.dsc || exit 1
            fi

      - name: "Move artifacts into repository"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: false
          script: |
            export BASEDIR="/srv/repository/main/server/debian"
            sudo mkdir -p ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }} || exit 1
            sudo mv -t ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }}/ /srv/incoming/${{ env.JELLYFIN_VERSION }}/debian/${{ matrix.arch }}/${{ matrix.release }}/* || exit 1
            sudo rm ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || true
            sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || exit 1
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                sudo rm ${BASEDIR}/latest || true
                sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest || exit 1
            fi

  Ubuntu:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        release:
          - focal
          - jammy
        # - noble
        arch:
          - amd64
          - arm64
          - armhf
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Run builder for ${{ matrix.version }} ${{ matrix.arch }}"
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} ubuntu ${{ matrix.arch }} ${{ matrix.release }}

      - name: "Upload artifacts to repository server"
        uses: appleboy/scp-action@v0.1.7
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          source: "out/ubuntu/*"
          strip_components: 2
          target: "/srv/incoming/${{ env.JELLYFIN_VERSION }}/ubuntu/${{ matrix.arch }}/${{ matrix.release }}"

      - name: "Import artifacts into reprepro -V"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: false
          script: |
            set -o xtrace
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                COMPONENT="main"
            else
                COMPONENT="unstable"
            fi
            # Only include the architecture-dependent deb here, as the others are done only for amd64
            sudo reprepro -V --waitforlock 30 --basedir /srv/ubuntu --component ${COMPONENT} includedeb ${{ matrix.release }} /srv/incoming/${{ env.JELLYFIN_VERSION }}/ubuntu/${{ matrix.arch }}/${{ matrix.release }}/*_${{ matrix.arch }}.deb || exit 1
            if [[ ${{ matrix.arch }} == "amd64" ]]; then
                # Only include the architecture-independent packages for amd64; the other architectures are the same and conflict
                sudo reprepro -V --waitforlock 30 --basedir /srv/ubuntu --component ${COMPONENT} includedeb ${{ matrix.release }} /srv/incoming/${{ env.JELLYFIN_VERSION }}/ubuntu/${{ matrix.arch }}/${{ matrix.release }}/*_all.deb || exit 1
                # Only include the source DSC for amd64; the other architectures are the same and conflict
                sudo reprepro -V --waitforlock 30 --basedir /srv/ubuntu --component ${COMPONENT} includedsc ${{ matrix.release }} /srv/incoming/${{ env.JELLYFIN_VERSION }}/ubuntu/${{ matrix.arch }}/${{ matrix.release }}/*.dsc || exit 1
            fi

      - name: "Move artifacts into repository"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: false
          script: |
            export BASEDIR="/srv/repository/main/server/ubuntu"
            sudo mkdir -p ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }} || exit 1
            sudo mv -t ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }}/ /srv/incoming/${{ env.JELLYFIN_VERSION }}/ubuntu/${{ matrix.arch }}/${{ matrix.release }}/* || exit 1
            sudo rm ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || true
            sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || exit 1
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                sudo rm ${BASEDIR}/latest || true
                sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest || exit 1
            fi

  Linux:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        arch:
          - amd64
          - amd64-musl
          - arm64
          - arm64-musl
          - armhf
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Run builder for ${{ matrix.arch }}"
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} linux ${{ matrix.arch }}

      - name: "Upload artifacts to repository server"
        uses: appleboy/scp-action@v0.1.7
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          source: "out/linux/*"
          strip_components: 2
          target: "/srv/incoming/${{ env.JELLYFIN_VERSION }}/linux/${{ matrix.arch }}"

      - name: "Move artifacts into repository"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: true
          script: |
            export BASEDIR="/srv/repository/main/server/linux"
            sudo mkdir -p ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }} || exit 1
            sudo mv -t ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }}/ /srv/incoming/${{ env.JELLYFIN_VERSION }}/linux/${{ matrix.arch }}/${{ matrix.release }}/* || exit 1
            sudo rm ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || true
            sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || exit 1
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                sudo rm ${BASEDIR}/latest || true
                sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest || exit 1
            fi

  Windows:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        arch:
          - amd64
          - arm64
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Run builder for ${{ matrix.arch }}"
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} windows ${{ matrix.arch }}

      - name: "Upload artifacts to repository server"
        uses: appleboy/scp-action@v0.1.7
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          source: "out/windows/*"
          strip_components: 2
          target: "/srv/incoming/${{ env.JELLYFIN_VERSION }}/windows/${{ matrix.arch }}"

      - name: "Move artifacts into repository"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: true
          script: |
            export BASEDIR="/srv/repository/main/server/windows"
            sudo mkdir -p ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }} || exit 1
            sudo mv -t ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }}/ /srv/incoming/${{ env.JELLYFIN_VERSION }}/windows/${{ matrix.arch }}/${{ matrix.release }}/* || exit 1
            sudo rm ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || true
            sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || exit 1
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                sudo rm ${BASEDIR}/latest || true
                sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest || exit 1
            fi

  MacOS:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        arch:
          - amd64
          - arm64
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Run builder for ${{ matrix.version }} ${{ matrix.arch }}"
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} macos ${{ matrix.arch }}

      - name: "Upload artifacts to repository server"
        uses: appleboy/scp-action@v0.1.7
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          source: "out/macos/*"
          strip_components: 2
          target: "/srv/incoming/${{ env.JELLYFIN_VERSION }}/macos/${{ matrix.arch }}"

      - name: "Move artifacts into repository"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: true
          script: |
            export BASEDIR="/srv/repository/main/server/macos"
            sudo mkdir -p ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }} || exit 1
            sudo mv -t ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }}/ /srv/incoming/${{ env.JELLYFIN_VERSION }}/macos/${{ matrix.arch }}/${{ matrix.release }}/* || exit 1
            sudo rm ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || true
            sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || exit 1
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                sudo rm ${BASEDIR}/latest || true
                sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest || exit 1
            fi

  Portable:
    runs-on: ubuntu-22.04
    continue-on-error: false  # true in prod, false for testing
    steps:
      - name: "Set dated version for unstable builds"
        id: version
        run: |-
          if grep --silent --extended-regexp '^v[0-9]+' <<< "${{ inputs.version }}"; then
            echo "JELLYFIN_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=stable" >> $GITHUB_ENV
          else
            echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
            echo "JELLYFIN_RELEASE_TYPE=unstable" >> $GITHUB_ENV
          fi

      - name: "Install dependencies"
        run: |-
          sudo apt-get install --yes python3-git python3-yaml

      - name: "Checkout repository"
        uses: actions/checkout@v3

      - name: "Prepare repository"
        run: |-
          ./checkout.py ${{ inputs.version }}

      - name: "Run builder for Portable" 
        run: |-
          sudo ./build.py ${{ env.JELLYFIN_VERSION }} portable

      - name: "Upload artifacts to repository server"
        uses: appleboy/scp-action@v0.1.7
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          source: "out/portable/*"
          strip_components: 2
          target: "/srv/incoming/${{ env.JELLYFIN_VERSION }}/portable"

      - name: "Move artifacts into repository"
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: "${{ secrets.REPO_HOST }}"
          username: "${{ secrets.REPO_USER }}"
          key: "${{ secrets.REPO_KEY }}"
          debug: false
          script_stop: true
          script: |
            export BASEDIR="/srv/repository/main/server/portable"
            sudo mkdir -p ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }} || exit 1
            sudo mv -t ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }}/${{ matrix.arch }}/ /srv/incoming/${{ env.JELLYFIN_VERSION }}/portable/${{ matrix.arch }}/${{ matrix.release }}/* || exit 1
            sudo rm ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || true
            sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest-${{ env.JELLYFIN_RELEASE_TYPE }} || exit 1
            if [[ ${{ env.JELLYFIN_RELEASE_TYPE }} == "stable" ]]; then
                sudo rm ${BASEDIR}/latest || true
                sudo ln -sf ${BASEDIR}/${{ env.JELLYFIN_RELEASE_TYPE }}/${{ env.JELLYFIN_VERSION }} ${BASEDIR}/latest || exit 1
            fi
bgstack15