1- name : Upload Python package to PyPI
1+ name : Upload Python package to PyPI and build/push Docker images.
22
33on :
44 push :
@@ -11,23 +11,77 @@ jobs:
1111 deploy :
1212 runs-on : ubuntu-latest
1313 steps :
14+ # Checkout the code
1415 - name : Checkout code
1516 uses : actions/checkout@v2
1617
18+ # Set up Python environment
1719 - name : Set up Python
1820 uses : actions/setup-python@v2
1921 with :
2022 python-version : " 3.x"
2123
24+ # Install Poetry
2225 - name : Install Poetry
2326 run : |
2427 curl -sSL https://install.python-poetry.org | python3 -
2528
29+ # Configure Poetry with PyPI token
2630 - name : Configure Poetry
2731 run : |
2832 poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
2933
34+ # Build and publish package to PyPI
3035 - name : Build and publish to PyPI
3136 run : |
3237 poetry build
3338 poetry publish
39+
40+ # Extract the new version number from pyproject.toml
41+ - name : Extract version for tagging Docker image
42+ run : |
43+ echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV
44+
45+ # Wait for the package to become available on PyPI
46+ - name : Wait for PyPI to update
47+ run : |
48+ echo "Checking for llmstudio==${{ env.VERSION }} on PyPI..."
49+ for i in {1..10}; do
50+ if python -m pip install llmstudio==${{ env.VERSION }} --dry-run >/dev/null 2>&1; then
51+ echo "Package llmstudio==${{ env.VERSION }} is available on PyPI."
52+ break
53+ else
54+ echo "Package llmstudio==${{ env.VERSION }} not available yet. Waiting 15 seconds..."
55+ sleep 15
56+ fi
57+ if [ $i -eq 10 ]; then
58+ echo "Package did not become available in time."
59+ exit 1
60+ fi
61+ done
62+
63+ # Set up Docker Buildx
64+ - name : Set up Docker Buildx
65+ uses : docker/setup-buildx-action@v2
66+
67+ # Log in to Docker Hub
68+ - name : Log in to Docker Hub
69+ uses : docker/login-action@v2
70+ with :
71+ username : ${{ secrets.DOCKER_USERNAME }}
72+ password : ${{ secrets.DOCKER_PASSWORD }}
73+
74+ # Build and tag Docker images with both :latest and :[NEW_VERSION]
75+ - name : Build and tag Docker images
76+ run : |
77+ docker build \
78+ --build-arg LLMSTUDIO_VERSION=${{ env.VERSION }} \
79+ -t tensoropsai/llmstudio:latest \
80+ -t tensoropsai/llmstudio:${{ env.VERSION }} \
81+ .
82+
83+ # Push both Docker images to Docker Hub
84+ - name : Push Docker images to Docker Hub
85+ run : |
86+ docker push tensoropsai/llmstudio:${{ env.VERSION }}
87+ docker push tensoropsai/llmstudio:latest
0 commit comments