From a0191c4d530938e8f35276780e29ffcbea75ec8f Mon Sep 17 00:00:00 2001 From: Ryan Cook Date: Fri, 28 Feb 2025 16:59:03 -0500 Subject: [PATCH 1/3] combined nightly and push actions Signed-off-by: Ryan Cook --- .github/workflows/publish-dockers.yaml | 18 +++++ actions/publish-dockers/action.yaml | 9 +++ actions/publish-dockers/main.sh | 101 +++++++++++++++---------- 3 files changed, 88 insertions(+), 40 deletions(-) diff --git a/.github/workflows/publish-dockers.yaml b/.github/workflows/publish-dockers.yaml index 713080a..5fda622 100644 --- a/.github/workflows/publish-dockers.yaml +++ b/.github/workflows/publish-dockers.yaml @@ -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: @@ -14,6 +16,7 @@ on: jobs: publish-docker-images: + if: ${{ github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -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 }} diff --git a/actions/publish-dockers/action.yaml b/actions/publish-dockers/action.yaml index bb7df12..fb572b0 100644 --- a/actions/publish-dockers/action.yaml +++ b/actions/publish-dockers/action.yaml @@ -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: diff --git a/actions/publish-dockers/main.sh b/actions/publish-dockers/main.sh index 77cb46e..6175085 100755 --- a/actions/publish-dockers/main.sh +++ b/actions/publish-dockers/main.sh @@ -4,72 +4,93 @@ 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 +# Common setup for both scripts +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} llama-models==${VERSION} llama-stack-client==${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 @@ -80,4 +101,4 @@ for template in "${TEMPLATES[@]}"; do build_and_push_docker $template done -echo "Done" \ No newline at end of file +echo "Done" From e4ef24239591d079a36c1cdd2df5edd8570e7055 Mon Sep 17 00:00:00 2001 From: Ryan Cook Date: Tue, 11 Mar 2025 14:10:14 -0400 Subject: [PATCH 2/3] version bump to match other checkouts Signed-off-by: Ryan Cook --- .github/workflows/publish-dockers.yaml | 2 +- actions/publish-dockers/action.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-dockers.yaml b/.github/workflows/publish-dockers.yaml index 5fda622..c952a70 100644 --- a/.github/workflows/publish-dockers.yaml +++ b/.github/workflows/publish-dockers.yaml @@ -2,7 +2,7 @@ name: Publish Docker images on: schedule: - - cron: '45 23 * * *' # Every day at 11:45 + - cron: '45 23 * * *' # Every day at 11:45 UTC workflow_dispatch: # Keep manual trigger inputs: version: diff --git a/actions/publish-dockers/action.yaml b/actions/publish-dockers/action.yaml index fb572b0..73a99ff 100644 --- a/actions/publish-dockers/action.yaml +++ b/actions/publish-dockers/action.yaml @@ -37,7 +37,7 @@ runs: - name: Pull the main branch of llama-stack if: startsWith(github.event.inputs.version, 'nightly-') - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: 'main' repository: 'meta-llama/llama-stack' From d200367e1ecbc63c326e822958c994aa1185431e Mon Sep 17 00:00:00 2001 From: Ryan Cook Date: Wed, 19 Mar 2025 10:14:29 -0400 Subject: [PATCH 3/3] include commit id from llama stack --- actions/publish-dockers/main.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actions/publish-dockers/main.sh b/actions/publish-dockers/main.sh index 9e1fad6..024a049 100755 --- a/actions/publish-dockers/main.sh +++ b/actions/publish-dockers/main.sh @@ -75,8 +75,9 @@ build_and_push_docker() { echo "Pushing docker image" if [ "$IS_NIGHTLY" = true ]; then - docker tag distribution-$template:dev llamastack/distribution-$template:${VERSION} - docker push llamastack/distribution-$template:${VERSION} + COMMIT=$(git rev-parse --short HEAD) + docker tag distribution-$template:dev llamastack/distribution-$template:${VERSION}-${COMMIT} + docker push llamastack/distribution-$template:${VERSION}-${COMMIT} else if [ "$PYPI_SOURCE" = "testpypi" ]; then docker tag distribution-$template:test-${VERSION} llamastack/distribution-$template:test-${VERSION}