Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/publish-dockers.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Publish Docker images

on:
schedule:
- cron: '45 23 * * *' # Every day at 11:45
workflow_dispatch: # Keep manual trigger
inputs:
version:
Expand All @@ -14,6 +16,7 @@ on:

jobs:
publish-docker-images:
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -23,3 +26,18 @@ jobs:
templates: ${{ inputs.templates }}
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

publish-nightly-docker-images:
if: ${{ github.event_name == 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set version variable
id: set_version
run: echo "VERSION=nightly-$(date +'%Y%m%d')" >> $GITHUB_ENV
- uses: ./actions/publish-dockers
with:
templates: "ollama, together, fireworks, bedrock, remote-vllm, tgi, meta-reference-gpu"
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
version: ${{ env.VERSION }}
9 changes: 9 additions & 0 deletions actions/publish-dockers/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ runs:
username: ${{ inputs.dockerhub_username }}
password: ${{ inputs.dockerhub_token }}


- name: Pull the main branch of llama-stack
if: startsWith(github.event.inputs.version, 'nightly-')
uses: actions/checkout@v2
with:
ref: 'main'
repository: 'meta-llama/llama-stack'
path: 'llama-stack'

- name: Build and publish
shell: bash
env:
Expand Down
98 changes: 59 additions & 39 deletions actions/publish-dockers/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,92 @@ if [ -z "$VERSION" ]; then
echo "You must set the VERSION environment variable" >&2
exit 1
fi
TEMPLATES=${TEMPLATES:-}

set -euo pipefail
TEMPLATES=${TEMPLATES:-}
IS_NIGHTLY=false

release_exists() {
local source=$1
releases=$(curl -s https://${source}.org/pypi/llama-stack/json | jq -r '.releases | keys[]')
for release in $releases; do
if [ x"$release" = x"$VERSION" ]; then
return 0
fi
done
return 1
}
if [[ "$VERSION" == nightly-* ]]; then
IS_NIGHTLY=true
fi

set -euo pipefail

if release_exists "test.pypi"; then
echo "Version $VERSION found in test.pypi"
PYPI_SOURCE="testpypi"
elif release_exists "pypi"; then
echo "Version $VERSION found in pypi"
PYPI_SOURCE="pypi"
else
echo "Version $VERSION not found in either test.pypi or pypi" >&2
exit 1
if [ "$IS_NIGHTLY" = true ]; then
cd llama-stack
fi

set -x
TMPDIR=$(mktemp -d)
cd $TMPDIR
uv venv -p python3.10
source .venv/bin/activate

uv pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
--index-strategy unsafe-best-match \
llama-stack==${VERSION}
if [ "$IS_NIGHTLY" = true ]; then
pip install -U .
else
release_exists() {
local source=$1
releases=$(curl -s https://${source}.org/pypi/llama-stack/json | jq -r '.releases | keys[]')
for release in $releases; do
if [ x"$release" = x"$VERSION" ]; then
return 0
fi
done
return 1
}

if release_exists "test.pypi"; then
echo "Version $VERSION found in test.pypi"
PYPI_SOURCE="testpypi"
elif release_exists "pypi"; then
echo "Version $VERSION found in pypi"
PYPI_SOURCE="pypi"
else
echo "Version $VERSION not found in either test.pypi or pypi" >&2
exit 1
fi

uv pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
--index-strategy unsafe-best-match \
llama-stack==${VERSION} llama-models==${VERSION} llama-stack-client==${VERSION}
fi

which llama
llama stack list-apis


build_and_push_docker() {
template=$1

echo "Building and pushing docker for template $template"
if [ "$PYPI_SOURCE" = "testpypi" ]; then
TEST_PYPI_VERSION=${VERSION} llama stack build --template $template --image-type container

if [ "$IS_NIGHTLY" = true ]; then
USE_COPY_NOT_MOUNT=true LLAMA_STACK_DIR=. llama stack build --template $template --image-type container
else
PYPI_VERSION=${VERSION} llama stack build --template $template --image-type container
if [ "$PYPI_SOURCE" = "testpypi" ]; then
TEST_PYPI_VERSION=${VERSION} llama stack build --template $template --image-type container
else
PYPI_VERSION=${VERSION} llama stack build --template $template --image-type container
fi
fi

docker images

echo "Pushing docker image"
if [ "$PYPI_SOURCE" = "testpypi" ]; then
docker tag distribution-$template:test-${VERSION} llamastack/distribution-$template:test-${VERSION}
docker push llamastack/distribution-$template:test-${VERSION}
else
docker tag distribution-$template:${VERSION} llamastack/distribution-$template:${VERSION}
docker tag distribution-$template:${VERSION} llamastack/distribution-$template:latest
if [ "$IS_NIGHTLY" = true ]; then
docker tag distribution-$template:dev llamastack/distribution-$template:${VERSION}
docker push llamastack/distribution-$template:${VERSION}
docker push llamastack/distribution-$template:latest
else
if [ "$PYPI_SOURCE" = "testpypi" ]; then
docker tag distribution-$template:test-${VERSION} llamastack/distribution-$template:test-${VERSION}
docker push llamastack/distribution-$template:test-${VERSION}
else
docker tag distribution-$template:${VERSION} llamastack/distribution-$template:${VERSION}
docker tag distribution-$template:${VERSION} llamastack/distribution-$template:latest
docker push llamastack/distribution-$template:${VERSION}
docker push llamastack/distribution-$template:latest
fi
fi
}


if [ -z "$TEMPLATES" ]; then
TEMPLATES=(ollama together fireworks bedrock remote-vllm tgi meta-reference-gpu)
else
Expand Down