mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2026-09-03 05:10:26 +03:00
370 lines
13 KiB
YAML
370 lines
13 KiB
YAML
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/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.commit || github.sha }}
|
|
show-progress: false
|
|
|
|
- name: Setup node environment ⚙️
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: lts/*
|
|
check-latest: true
|
|
|
|
- name: Setup Rust Toolchain and cache 🦀
|
|
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
|
|
with:
|
|
cache-key: tauri-${{ runner.os }}
|
|
cache-workspaces: ${{ env.WORKING_DIR }}
|
|
|
|
- name: Install npm dependencies 📦
|
|
run: corepack pnpm i --frozen-lockfile
|
|
|
|
- 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: corepack pnpm build
|
|
|
|
- name: Upload built application artifact ⬆️🐧🍎🪟
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
id: artifact
|
|
with:
|
|
compression-level: 0
|
|
name: ${{ env.ARTIFACT_NAME }}
|
|
path: ${{ env.WORKING_DIR }}/${{ env.ARTIFACTS_PATH }}
|
|
|
|
- name: Create provenance attestation 🔏
|
|
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
|
|
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-slim
|
|
permissions: {}
|
|
outputs:
|
|
tags: ${{ env.tags }}
|
|
platforms: ${{ env.platforms }}
|
|
caches: ${{ env.caches }}
|
|
env:
|
|
REQUESTED_ARCHITECTURES: ${{ inputs.architectures }}
|
|
|
|
# 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
|
|
env:
|
|
COMMIT: ${{ inputs.commit }}
|
|
run: |
|
|
echo "sha=${COMMIT::7}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Generate tags 🏷️
|
|
env:
|
|
INPUT_COMMIT: ${{ inputs.commit }}
|
|
INPUT_TAG_NAME: ${{ inputs.tag_name }}
|
|
INPUT_IS_PRERELEASE: ${{ inputs.is_prerelease }}
|
|
STEP_DATE: ${{ steps.date.outputs.date }}
|
|
STEP_SHA: ${{ steps.sha.outputs.sha }}
|
|
run: |
|
|
TG=""
|
|
|
|
# Stable release: No commit, is_prerelease=false
|
|
if [[ -z "$INPUT_COMMIT" ]] && [[ "$INPUT_IS_PRERELEASE" == "false" ]]; then
|
|
TG+="${REGISTRY_IMAGE}:latest"$'\n'
|
|
TG+="${REGISTRY_IMAGE}:${RELEASE_TAG}"$'\n'
|
|
if [[ -n "$INPUT_TAG_NAME" ]]; then
|
|
TG+="${REGISTRY_IMAGE}:${RELEASE_TAG}.${INPUT_TAG_NAME}"$'\n'
|
|
fi
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:latest"$'\n'
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:${RELEASE_TAG}"$'\n'
|
|
if [[ -n "$INPUT_TAG_NAME" ]]; then
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:${RELEASE_TAG}.${INPUT_TAG_NAME}"$'\n'
|
|
fi
|
|
fi
|
|
|
|
# Stable-rc release: No commit, is_prerelease=true
|
|
if [[ -z "$INPUT_COMMIT" ]] && [[ "$INPUT_IS_PRERELEASE" == "true" ]]; then
|
|
TG+="${REGISTRY_IMAGE}:${PRERELEASE_TAG}"$'\n'
|
|
if [[ -n "$INPUT_TAG_NAME" ]]; then
|
|
TG+="${REGISTRY_IMAGE}:${PRERELEASE_TAG}.${INPUT_TAG_NAME}"$'\n'
|
|
fi
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:${PRERELEASE_TAG}"$'\n'
|
|
if [[ -n "$INPUT_TAG_NAME" ]]; then
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:${PRERELEASE_TAG}.${INPUT_TAG_NAME}"$'\n'
|
|
fi
|
|
fi
|
|
|
|
# Unstable release: Has commit hash
|
|
if [[ -n "$INPUT_COMMIT" ]]; then
|
|
TG+="${REGISTRY_IMAGE}:${COMMIT_TAG}"$'\n'
|
|
TG+="${REGISTRY_IMAGE}:${COMMIT_TAG}.${STEP_DATE}.${STEP_SHA}"$'\n'
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:${COMMIT_TAG}"$'\n'
|
|
TG+="ghcr.io/${REGISTRY_IMAGE}:${COMMIT_TAG}.${STEP_DATE}.${STEP_SHA}"$'\n'
|
|
fi
|
|
|
|
echo "tags<<EOF" >> $GITHUB_ENV
|
|
echo -e "$TG" | sed '/^$/d' >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
|
|
- name: Generate platform array 🖥️📝
|
|
env:
|
|
ARCHITECTURES: ${{ env.REQUESTED_ARCHITECTURES }}
|
|
run: |
|
|
PARSED_ARRAY=$(echo "$ARCHITECTURES" | jq '. | map("linux/" + .) | .[]' | tr -d '"')
|
|
echo "platforms<<EOF" >> $GITHUB_ENV
|
|
echo "$PARSED_ARRAY" >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
|
|
- name: Generate cache array 💾📝
|
|
env:
|
|
ARCHITECTURES: ${{ env.REQUESTED_ARCHITECTURES }}
|
|
IMAGE: ${{ env.REGISTRY_IMAGE }}
|
|
run: |
|
|
PARSED_ARRAY=$(echo "$ARCHITECTURES" | jq --arg image "$IMAGE" '. | map("type=local,mode=min,src=/tmp/" + $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: ${{ contains(matrix.platform, 'arm') && 'ubuntu-24.04-arm' || '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/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.commit || github.sha }}
|
|
show-progress: false
|
|
|
|
- name: Configure QEMU ⚙️
|
|
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
|
|
|
- name: Configure Docker Buildx ⚙️
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
with:
|
|
cleanup: false
|
|
version: latest
|
|
|
|
- name: Build images 🛠️
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
id: image
|
|
with:
|
|
context: .
|
|
file: packaging/docker/Dockerfile
|
|
platforms: ${{ format('linux/{0}', matrix.platform) }}
|
|
no-cache: true
|
|
cache-to: |
|
|
type=local,mode=min,dest=/tmp/${{ env.REGISTRY_IMAGE }}/cache/${{ 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/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
id: artifact
|
|
with:
|
|
compression-level: 0
|
|
name: ${{ env.ARTIFACT_NAME }}
|
|
path: docker_image.tar
|
|
|
|
- name: Upload cache artifact ⬆️⚙️
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
if: ${{ inputs.push }}
|
|
with:
|
|
compression-level: 0
|
|
name: buildx-${{ matrix.platform }}
|
|
path: |
|
|
/tmp/${{ env.REGISTRY_IMAGE }}/cache/${{ matrix.platform }}
|
|
|
|
- name: Create provenance attestation 🔏
|
|
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
|
|
continue-on-error: true
|
|
with:
|
|
subject-name: ${{ env.ARTIFACT_NAME }}
|
|
subject-digest: sha256:${{ steps.artifact.outputs.artifact-digest }}
|
|
|
|
frontend:
|
|
name: Publish frontend artifact 🚀
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- docker
|
|
env:
|
|
ARTIFACT_NAME: frontend
|
|
|
|
steps:
|
|
- name: Download Docker image artifact 📦⬇️
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
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/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
id: artifact
|
|
with:
|
|
compression-level: 0
|
|
name: ${{ env.ARTIFACT_NAME }}
|
|
path: dist
|
|
|
|
- name: Create provenance attestation 🔏
|
|
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
|
|
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 }}
|
|
permissions: {}
|
|
needs:
|
|
- docker
|
|
- docker_inputs
|
|
|
|
steps:
|
|
- name: Download cache artifacts 📦⬇️
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
pattern: buildx-*
|
|
path: /tmp/${{ env.REGISTRY_IMAGE }}/cache/
|
|
|
|
- name: Checkout ⬇️
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.commit || github.sha }}
|
|
show-progress: false
|
|
|
|
- name: Configure QEMU ⚙️
|
|
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
|
|
|
|
- name: Configure Docker Buildx ⚙️
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
with:
|
|
cleanup: false
|
|
version: latest
|
|
|
|
- name: Login to Docker Hub 🔑
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to GitHub Container Registry 🔑
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.JF_BOT_TOKEN }}
|
|
|
|
- name: Create multiplatform image ${{ inputs.push && 'and push 🛠️⬆️' || '🛠️' }}
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
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/delete-artifact@176a747ab7e287e3ff4787bf8a148716375ca118 # v6.0.0
|
|
continue-on-error: true
|
|
with:
|
|
name: |
|
|
buildx-*
|