Update GH action so it correctly queries for test.pypi, etc. (#875)

The previous curl command was wrong and did not actually check for
version correctly (status code was always 200 regardless of what you
retrieved.)

Also added tagging latest. cc @wukaixingxp
This commit is contained in:
Ashwin Bharambe 2025-01-24 11:56:29 -08:00 committed by GitHub
parent 2cebb24d3a
commit d111bad2f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,8 +46,11 @@ jobs:
# Function to check if version exists in a repository # Function to check if version exists in a repository
check_version() { check_version() {
local repo=$1 local repo=$1
local status_code=$(curl -s -o /dev/null -w "%{http_code}" "https://$repo.org/project/llama-stack/${{ steps.version.outputs.version }}") local VERSION_TO_CHECK=${{ steps.version.outputs.version }}
return $([ "$status_code" -eq 200 ]) echo "Checking version $VERSION_TO_CHECK in $repo"
result=$(curl -s "https://$repo.org/pypi/llama-stack/json" | jq --arg v "$VERSION_TO_CHECK" '.releases | has($v)')
echo "Result: $result"
return $([ "$result" = "true" ])
} }
# Check TestPyPI first, then PyPI # Check TestPyPI first, then PyPI
@ -64,6 +67,7 @@ jobs:
- name: Install llama-stack - name: Install llama-stack
run: | run: |
echo "PYPI_SOURCE=${PYPI_SOURCE}"
if [ "${{ github.event_name }}" = "push" ]; then if [ "${{ github.event_name }}" = "push" ]; then
pip install -e . pip install -e .
else else
@ -76,6 +80,8 @@ jobs:
- name: Build docker image - name: Build docker image
run: | run: |
echo "PYPI_SOURCE=${PYPI_SOURCE}"
echo "VERSION=${{ steps.version.outputs.version }}"
TEMPLATES=("ollama" "bedrock" "remote-vllm" "fireworks" "together" "tgi" "meta-reference-gpu") TEMPLATES=("ollama" "bedrock" "remote-vllm" "fireworks" "together" "tgi" "meta-reference-gpu")
for template in "${TEMPLATES[@]}"; do for template in "${TEMPLATES[@]}"; do
if [ "$PYPI_SOURCE" = "testpypi" ]; then if [ "$PYPI_SOURCE" = "testpypi" ]; then
@ -126,6 +132,8 @@ jobs:
- name: Push to dockerhub - name: Push to dockerhub
run: | run: |
echo "PYPI_SOURCE=${PYPI_SOURCE}"
echo "VERSION=${{ steps.version.outputs.version }}"
TEMPLATES=("ollama" "bedrock" "remote-vllm" "fireworks" "together" "tgi" "meta-reference-gpu") TEMPLATES=("ollama" "bedrock" "remote-vllm" "fireworks" "together" "tgi" "meta-reference-gpu")
for template in "${TEMPLATES[@]}"; do for template in "${TEMPLATES[@]}"; do
if [ "$PYPI_SOURCE" = "testpypi" ]; then if [ "$PYPI_SOURCE" = "testpypi" ]; then
@ -133,6 +141,8 @@ jobs:
docker push llamastack/distribution-$template:test-${{ steps.version.outputs.version }} docker push llamastack/distribution-$template:test-${{ steps.version.outputs.version }}
else else
docker tag distribution-$template:${{ steps.version.outputs.version }} llamastack/distribution-$template:${{ steps.version.outputs.version }} docker tag distribution-$template:${{ steps.version.outputs.version }} llamastack/distribution-$template:${{ steps.version.outputs.version }}
docker tag distribution-$template:${{ steps.version.outputs.version }} llamastack/distribution-$template:latest
docker push llamastack/distribution-$template:${{ steps.version.outputs.version }} docker push llamastack/distribution-$template:${{ steps.version.outputs.version }}
docker push llamastack/distribution-$template:latest
fi fi
done done