mirror of
https://github.com/open-webui/oikb.git
synced 2026-11-22 21:50:43 -05:00
The merge jobs needed the whole build matrix, so the alpine/arm64 build failing on pymupdf blocked the default image too and no 0.5.0 tag was published. Each merge job now runs unless the workflow was cancelled and publishes only when both of its own arches built. Refs #126
301 lines
9.7 KiB
YAML
301 lines
9.7 KiB
YAML
name: Docker (GHCR)
|
|
|
|
on:
|
|
push:
|
|
branches: [main, release]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: docker-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
IMAGE: ghcr.io/${{ github.repository }}
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
read-version:
|
|
if: github.ref == 'refs/heads/release'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.pkg.outputs.version }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Read version
|
|
id: pkg
|
|
run: |
|
|
VERSION=$(python3 -c "
|
|
import re, pathlib
|
|
text = pathlib.Path('pyproject.toml').read_text()
|
|
m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.M)
|
|
print(m.group(1))
|
|
")
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
build-dev:
|
|
if: github.ref == 'refs/heads/main'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
arch: amd64
|
|
flavor: default
|
|
dockerfile: Dockerfile
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
arch: arm64
|
|
flavor: default
|
|
dockerfile: Dockerfile
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
arch: amd64
|
|
flavor: alpine
|
|
dockerfile: Dockerfile.alpine
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
arch: arm64
|
|
flavor: alpine
|
|
dockerfile: Dockerfile.alpine
|
|
runs-on: ${{ matrix.runner }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push ${{ matrix.platform }} dev image by digest
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ matrix.dockerfile }}
|
|
platforms: ${{ matrix.platform }}
|
|
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
cache-from: type=gha,scope=dev-${{ matrix.flavor }}-${{ matrix.arch }}
|
|
cache-to: type=gha,mode=max,scope=dev-${{ matrix.flavor }}-${{ matrix.arch }}
|
|
|
|
- name: Export digest
|
|
run: |
|
|
mkdir -p /tmp/digests
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
- name: Upload digest
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: digests-dev-${{ matrix.flavor }}-${{ matrix.arch }}
|
|
path: /tmp/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
merge-dev:
|
|
if: ${{ !cancelled() && github.ref == 'refs/heads/main' }}
|
|
needs: build-dev
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-dev-default-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create dev multi-arch manifest
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
SHORT_SHA="${GITHUB_SHA::7}"
|
|
tags=("${{ env.IMAGE }}:dev" "${{ env.IMAGE }}:dev-${SHORT_SHA}")
|
|
# A flavor publishes only when every one of its arches built.
|
|
[ "$(ls | wc -l)" -eq 2 ] || { echo "expected 2 digests, found: $(ls)"; exit 1; }
|
|
docker buildx imagetools create $(printf -- '-t %s ' "${tags[@]}") \
|
|
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|
|
|
|
merge-dev-alpine:
|
|
if: ${{ !cancelled() && github.ref == 'refs/heads/main' }}
|
|
needs: build-dev
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-dev-alpine-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create dev Alpine multi-arch manifest
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
SHORT_SHA="${GITHUB_SHA::7}"
|
|
tags=("${{ env.IMAGE }}:dev-alpine" "${{ env.IMAGE }}:dev-${SHORT_SHA}-alpine")
|
|
# A flavor publishes only when every one of its arches built.
|
|
[ "$(ls | wc -l)" -eq 2 ] || { echo "expected 2 digests, found: $(ls)"; exit 1; }
|
|
docker buildx imagetools create $(printf -- '-t %s ' "${tags[@]}") \
|
|
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|
|
|
|
build-release:
|
|
needs: read-version
|
|
if: github.ref == 'refs/heads/release'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
arch: amd64
|
|
flavor: default
|
|
dockerfile: Dockerfile
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
arch: arm64
|
|
flavor: default
|
|
dockerfile: Dockerfile
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
arch: amd64
|
|
flavor: alpine
|
|
dockerfile: Dockerfile.alpine
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
arch: arm64
|
|
flavor: alpine
|
|
dockerfile: Dockerfile.alpine
|
|
runs-on: ${{ matrix.runner }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push ${{ matrix.platform }} release image by digest
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ matrix.dockerfile }}
|
|
platforms: ${{ matrix.platform }}
|
|
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
cache-from: type=gha,scope=release-${{ matrix.flavor }}-${{ matrix.arch }}
|
|
cache-to: type=gha,mode=max,scope=release-${{ matrix.flavor }}-${{ matrix.arch }}
|
|
|
|
- name: Export digest
|
|
run: |
|
|
mkdir -p /tmp/digests
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
- name: Upload digest
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: digests-release-${{ matrix.flavor }}-${{ matrix.arch }}
|
|
path: /tmp/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
merge-release:
|
|
needs: [read-version, build-release]
|
|
if: ${{ !cancelled() && needs.read-version.result == 'success' && github.ref == 'refs/heads/release' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-release-default-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create release multi-arch manifest
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
VERSION="${{ needs.read-version.outputs.version }}"
|
|
MAJOR_MINOR="${VERSION%.*}"
|
|
tags=("${{ env.IMAGE }}:latest" "${{ env.IMAGE }}:${VERSION}" "${{ env.IMAGE }}:${MAJOR_MINOR}")
|
|
# A flavor publishes only when every one of its arches built.
|
|
[ "$(ls | wc -l)" -eq 2 ] || { echo "expected 2 digests, found: $(ls)"; exit 1; }
|
|
docker buildx imagetools create $(printf -- '-t %s ' "${tags[@]}") \
|
|
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|
|
|
|
merge-release-alpine:
|
|
needs: [read-version, build-release]
|
|
if: ${{ !cancelled() && needs.read-version.result == 'success' && github.ref == 'refs/heads/release' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-release-alpine-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create release Alpine multi-arch manifest
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
VERSION="${{ needs.read-version.outputs.version }}"
|
|
MAJOR_MINOR="${VERSION%.*}"
|
|
tags=("${{ env.IMAGE }}:alpine" "${{ env.IMAGE }}:latest-alpine" "${{ env.IMAGE }}:${VERSION}-alpine" "${{ env.IMAGE }}:${MAJOR_MINOR}-alpine")
|
|
# A flavor publishes only when every one of its arches built.
|
|
[ "$(ls | wc -l)" -eq 2 ] || { echo "expected 2 digests, found: $(ls)"; exit 1; }
|
|
docker buildx imagetools create $(printf -- '-t %s ' "${tags[@]}") \
|
|
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|