Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

ci: build the release docker image once (#4469)

Zayn Jarvis26314efb7a8f
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index bfdfda560..1c9192af4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -156,223 +156,60 @@ jobs:
echo "Published to PyPI (or already existed) with version: $VERSION"
echo "::notice::Published to PyPI (or already existed) with version: $VERSION"
- docker:
- name: Build and Push Docker Image (${{ matrix.arch }})
- needs: [build, permission-check]
- if: >-
- needs.permission-check.outputs.allowed == 'true' &&
- github.event_name == 'release'
- strategy:
- fail-fast: false
- matrix:
- include:
- - arch: amd64
- platform: linux/amd64
- runner: ubuntu-24.04
- - arch: arm64
- platform: linux/arm64
- runner: ubuntu-24.04-arm
- runs-on: ${{ matrix.runner }}
- permissions:
- contents: read
- packages: write
- attestations: write
- id-token: write
- steps:
- - name: Checkout repository
- uses: actions/checkout@v6
- with:
- submodules: recursive
-
- - name: Normalize image name
- id: image-name
- env:
- RAW_IMAGE_NAME: ${{ github.repository }}
- run: |
- echo "image=$(echo "$RAW_IMAGE_NAME" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
-
- - name: Log in to the Container registry
- uses: docker/login-action@v4
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Log in to Docker Hub
- uses: docker/login-action@v4
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Extract metadata (tags, labels) for Docker
- id: meta
- uses: docker/metadata-action@v6
- with:
- images: |
- ghcr.io/${{ steps.image-name.outputs.image }}
- docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking
- tags: |
- type=raw,value=${{ github.event.release.tag_name }}
- type=raw,value=latest
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v4
-
- - name: Build and push Docker image to GHCR
- id: push-ghcr
- uses: docker/build-push-action@v7
- with:
- context: .
- platforms: ${{ matrix.platform }}
- outputs: |
- type=image,name=ghcr.io/${{ steps.image-name.outputs.image }},push-by-digest=true,name-canonical=true,push=true
- labels: ${{ steps.meta.outputs.labels }}
- build-args: |
- OPENVIKING_VERSION=${{ github.event.release.tag_name }}
-
- - name: Build and push Docker image to Docker Hub
- id: push-dockerhub
- uses: docker/build-push-action@v7
- with:
- context: .
- platforms: ${{ matrix.platform }}
- outputs: |
- type=image,name=docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking,push-by-digest=true,name-canonical=true,push=true
- labels: ${{ steps.meta.outputs.labels }}
- build-args: |
- OPENVIKING_VERSION=${{ github.event.release.tag_name }}
-
- - name: Export GHCR image digest
- run: |
- mkdir -p /tmp/digests-ghcr
- ghcr_digest="${{ steps.push-ghcr.outputs.digest }}"
- touch "/tmp/digests-ghcr/${ghcr_digest#sha256:}"
-
- - name: Upload GHCR image digest
- uses: actions/upload-artifact@v7
- with:
- name: docker-digests-ghcr-${{ matrix.arch }}
- path: /tmp/digests-ghcr/*
- if-no-files-found: error
- retention-days: 1
-
- - name: Export Docker Hub image digest
- run: |
- mkdir -p /tmp/digests-dockerhub
- dockerhub_digest="${{ steps.push-dockerhub.outputs.digest }}"
- touch "/tmp/digests-dockerhub/${dockerhub_digest#sha256:}"
-
- - name: Upload Docker Hub image digest
- uses: actions/upload-artifact@v7
- with:
- name: docker-digests-dockerhub-${{ matrix.arch }}
- path: /tmp/digests-dockerhub/*
- if-no-files-found: error
- retention-days: 1
-
- docker-manifest:
- name: Publish Docker Manifest
- needs: [docker, permission-check]
+ verify-docker:
+ name: Verify Docker Image Published
+ needs: [permission-check]
if: >-
needs.permission-check.outputs.allowed == 'true' &&
github.event_name == 'release'
runs-on: ubuntu-24.04
permissions:
- contents: read
- packages: write
+ actions: read
steps:
- - name: Checkout repository
- uses: actions/checkout@v6
- with:
- submodules: recursive
-
- - name: Normalize image name
- id: image-name
+ # The tag push and the release event fire at the same instant, so the
+ # image does not exist yet when this job starts. Wait for the tag's
+ # build-docker-image.yml run, then assert the tags really landed.
+ - name: Wait for the tag's docker build
env:
- RAW_IMAGE_NAME: ${{ github.repository }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPO: ${{ github.repository }}
+ TAG: ${{ github.event.release.tag_name }}
run: |
- echo "image=$(echo "$RAW_IMAGE_NAME" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
-
- - name: Log in to the Container registry
- uses: docker/login-action@v4
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Log in to Docker Hub
- uses: docker/login-action@v4
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- - name: Extract metadata (tags, labels) for Docker
- id: meta
- uses: docker/metadata-action@v6
- with:
- images: |
- ghcr.io/${{ steps.image-name.outputs.image }}
- docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking
- tags: |
- type=raw,value=${{ github.event.release.tag_name }}
- type=raw,value=latest
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v4
-
- - name: Download GHCR image digests
- uses: actions/download-artifact@v8
- with:
- pattern: docker-digests-ghcr-*
- path: /tmp/digests-ghcr
- merge-multiple: true
-
- - name: Download Docker Hub image digests
- uses: actions/download-artifact@v8
- with:
- pattern: docker-digests-dockerhub-*
- path: /tmp/digests-dockerhub
- merge-multiple: true
+ set -euo pipefail
+ for _ in $(seq 60); do
+ run=$(gh run list --workflow build-docker-image.yml --branch "$TAG" \
+ --event push --limit 1 \
+ --json status,conclusion,url \
+ --jq '.[0] | "\(.status) \(.conclusion) \(.url)"')
+ if [ -z "$run" ]; then
+ echo "No build-docker-image run for $TAG yet"
+ else
+ set -- $run
+ if [ "$1" = completed ]; then
+ [ "$2" = success ] || { echo "::error::docker build $2: $3"; exit 1; }
+ echo "docker build succeeded: $3"
+ exit 0
+ fi
+ echo "docker build $1 ($3)"
+ fi
+ sleep 30
+ done
+ echo "::error::timed out waiting for the docker build of $TAG"
+ exit 1
- - name: Create multi-arch manifests
+ - name: Assert version and latest tags point at this release
env:
- SOURCE_TAGS: ${{ steps.meta.outputs.tags }}
+ TAG: ${{ github.event.release.tag_name }}
+ DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run: |
- # Collect image references for both registries
- ghcr_image_refs=()
- dockerhub_image_refs=()
- for digest_file in /tmp/digests-ghcr/*; do
- [ -e "$digest_file" ] || continue
- digest="sha256:$(basename "$digest_file")"
- ghcr_image_refs+=("ghcr.io/${{ steps.image-name.outputs.image }}@${digest}")
- done
- for digest_file in /tmp/digests-dockerhub/*; do
- [ -e "$digest_file" ] || continue
- digest="sha256:$(basename "$digest_file")"
- dockerhub_image_refs+=("docker.io/${{ secrets.DOCKERHUB_USERNAME }}/openviking@${digest}")
- done
-
- [ ${#ghcr_image_refs[@]} -gt 0 ] || {
- echo "No GHCR image digests found" >&2
- exit 1
- }
- [ ${#dockerhub_image_refs[@]} -gt 0 ] || {
- echo "No Docker Hub image digests found" >&2
- exit 1
- }
-
- # Create manifests for all tags
- while IFS= read -r tag; do
- [ -n "$tag" ] || continue
-
- # Determine which registry this tag belongs to
- if [[ "$tag" == ghcr.io/* ]]; then
- docker buildx imagetools create \
- --tag "$tag" \
- "${ghcr_image_refs[@]}"
- elif [[ "$tag" == docker.io/* ]]; then
- docker buildx imagetools create \
- --tag "$tag" \
- "${dockerhub_image_refs[@]}"
+ set -euo pipefail
+ image=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
+ for ref in "ghcr.io/${image}" "docker.io/${DOCKERHUB_USERNAME}/openviking"; do
+ tagged=$(docker buildx imagetools inspect "${ref}:${TAG}" --format '{{.Manifest.Digest}}')
+ latest=$(docker buildx imagetools inspect "${ref}:latest" --format '{{.Manifest.Digest}}')
+ if [ "$tagged" != "$latest" ]; then
+ echo "::error::${ref}:latest is ${latest}, expected ${tagged} (${TAG})"
+ exit 1
fi
- done <<< "$SOURCE_TAGS"
+ echo "${ref}: ${TAG} == latest == ${tagged}"
+ done