Skip to content

Commit

Permalink
CI automation for tagging latest images
Browse files Browse the repository at this point in the history
  • Loading branch information
dhiltgen committed Mar 28, 2024
1 parent 035b274 commit b0b7ace
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: latest

on:
release:
types: [released]

jobs:
update-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: fetch images
env:
ARCH_IMAGE_REPO: dhiltgen/release
FINAL_IMAGE_REPO: dhiltgen/ollama
# PUSH: "1"
run: |
export "VERSION=${GITHUB_REF_NAME#v}"
env
./scripts/tag_latest.sh
33 changes: 33 additions & 0 deletions scripts/tag_latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

set -eu

# We use 2 different image repositories to handle combining architecture images into multiarch manifest
# (The ROCm image is x86 only and is not a multiarch manifest)
# For developers, you can override the DOCKER_ORG to generate multiarch manifests
# DOCKER_ORG=jdoe PUSH=1 ./scripts/build_docker.sh
DOCKER_ORG=${DOCKER_ORG:-"ollama"}
ARCH_IMAGE_REPO=${ARCH_IMAGE_REPO:-"${DOCKER_ORG}/release"}
FINAL_IMAGE_REPO=${FINAL_IMAGE_REPO:-"${DOCKER_ORG}/ollama"}

# Set PUSH to a non-empty string to trigger push instead of load
PUSH=${PUSH:-""}

echo "Assembling manifest and tagging latest"
docker manifest rm ${FINAL_IMAGE_REPO}:latest || true
docker manifest create ${FINAL_IMAGE_REPO}:latest \
${ARCH_IMAGE_REPO}:$VERSION-amd64 \
${ARCH_IMAGE_REPO}:$VERSION-arm64

docker pull ${ARCH_IMAGE_REPO}:$VERSION-rocm
docker tag ${ARCH_IMAGE_REPO}:$VERSION-rocm ${FINAL_IMAGE_REPO}:rocm

if [ -n "${PUSH}" ]; then
echo "Pushing latest tags up..."
docker manifest push ${FINAL_IMAGE_REPO}:latest
docker push ${FINAL_IMAGE_REPO}:rocm
else
echo "Not pushing ${FINAL_IMAGE_REPO}:latest and ${FINAL_IMAGE_REPO}:rocm"
fi


0 comments on commit b0b7ace

Please sign in to comment.