* Updated docker to use buildx Buildkit * Updated github actions to include QEMU/buildx to build multiarch containers * Removed packages after build is done * Updated documentation to set the correct default thumbnail file name * Parallel jobs (#1) Implemented parallel docker builds on Github Actions * Updated default config file in Docker container * Replaced Pillow with ffmpeg for thumbnail converting (and updated documentation to change the default thumbnail to -thumb.jpg) (#2) * Swapped Pillow for ffmpeg for thumbnail conversion * Further changed default thumbname to include "-thumb" (Kodi needs this to pick up the thumbnail image) * Added ffmpeg bitexact for reproducability * Removed extra packages needed for Pillow * Updated ref check (#3) * Fixed formatting on if statement for deploy job Co-authored-by: Maka0 <bas@oddens.net>
220 lines
No EOL
5.5 KiB
YAML
220 lines
No EOL
5.5 KiB
YAML
name: ytld-sub Docker Build
|
|
|
|
on:
|
|
push:
|
|
# Publish `master` as Docker `latest` image.
|
|
branches:
|
|
- master
|
|
|
|
# Publish `v1.2.3` tags as releases.
|
|
tags:
|
|
- v*
|
|
|
|
# Run tests for any PRs.
|
|
pull_request:
|
|
|
|
env:
|
|
IMAGE_NAME: ytdl-sub
|
|
|
|
jobs:
|
|
# Push image to GitHub Packages.
|
|
# See also https://docs.docker.com/docker-hub/builds/
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: [ "3.10" ]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Build Wheel
|
|
run: |
|
|
pip install -e .[build]
|
|
python setup.py bdist_wheel
|
|
cp dist/*.whl docker/root
|
|
|
|
- name: Save Python build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: docker/root
|
|
key: ${{github.sha}}
|
|
|
|
|
|
# Build ARM64 container
|
|
package-arm64:
|
|
runs-on: ubuntu-latest
|
|
needs: [
|
|
build
|
|
]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Restore Python build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: docker/root
|
|
key: ${{github.sha}}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: linux/arm64
|
|
|
|
- name: Docker Setup Buildx
|
|
uses: docker/setup-buildx-action@v2.0.0
|
|
|
|
- name: Build Docker Image
|
|
run: |
|
|
docker buildx build \
|
|
--platform=linux/arm64 \
|
|
--cache-to=type=local,dest=/tmp/build-cache/arm64 \
|
|
--tag $IMAGE_NAME \
|
|
--label "runnumber=${GITHUB_RUN_ID}" \
|
|
docker/
|
|
|
|
- name: Save ARM64 build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/build-cache/arm64
|
|
key: ${{github.sha}}
|
|
|
|
|
|
# Build AMD64 container
|
|
package-amd64:
|
|
runs-on: ubuntu-latest
|
|
needs: [
|
|
build
|
|
]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Restore Python build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: docker/root
|
|
key: ${{github.sha}}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: linux/amd64
|
|
|
|
- name: Docker Setup Buildx
|
|
uses: docker/setup-buildx-action@v2.0.0
|
|
|
|
- name: Build Docker Image
|
|
run: |
|
|
docker buildx build \
|
|
--platform=linux/amd64 \
|
|
--cache-to=type=local,dest=/tmp/build-cache/amd64 \
|
|
--tag $IMAGE_NAME \
|
|
--label "runnumber=${GITHUB_RUN_ID}" \
|
|
docker/
|
|
|
|
- name: Save AMD64 build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/build-cache/amd64
|
|
key: ${{github.sha}}
|
|
|
|
|
|
# On master branch, build the docker manifest file from the cached docker builds and push to the registry
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: [
|
|
build,
|
|
package-arm64,
|
|
package-amd64
|
|
]
|
|
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
|
|
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Restore Python build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: docker/root
|
|
key: ${{github.sha}}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Docker Setup Buildx
|
|
uses: docker/setup-buildx-action@v2.0.0
|
|
|
|
- name: login to GitHub Container Registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Restore ARM64 build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/build-cache/arm64
|
|
key: ${{github.sha}}
|
|
|
|
- name: Restore AMD64 build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: /tmp/build-cache/amd64
|
|
key: ${{github.sha}}
|
|
|
|
- name: Format image_id
|
|
id: formatted-image_id
|
|
run: |
|
|
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}
|
|
|
|
# Change all uppercase to lowercase
|
|
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
|
|
echo IMAGE_ID=${IMAGE_ID}
|
|
|
|
echo ::set-output name=IMAGE_ID::${IMAGE_ID}
|
|
|
|
- name: Get the version
|
|
id: formatted_version
|
|
run: |
|
|
# Strip git ref prefix from version
|
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
|
# Strip "v" prefix from tag name
|
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
|
# Use Docker `latest` tag convention
|
|
[ "$VERSION" == "master" ] && VERSION=latest
|
|
echo VERSION=${VERSION}
|
|
|
|
echo ::set-output name=VERSION::${VERSION}
|
|
|
|
- name: Build Docker Image and push to registry
|
|
run: |
|
|
docker buildx build --push \
|
|
--platform=linux/amd64,linux/arm64 \
|
|
--cache-from=type=local,src=/tmp/build-cache/amd64 \
|
|
--cache-from=type=local,src=/tmp/build-cache/arm64 \
|
|
--tag ${{ steps.formatted-image_id.outputs.IMAGE_ID }}:${{ steps.formatted_version.outputs.VERSION }} \
|
|
--label "runnumber=${GITHUB_RUN_ID}" \
|
|
docker/ |