Version 1.0.2 (#180) #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: llmstudio-proxy to PyPI and build/push Docker images. | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "libs/proxy/**" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
# Install Poetry | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
# Configure Poetry with PyPI token | |
- name: Configure Poetry | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
# Build and publish package to PyPI | |
- name: Build and publish to PyPI | |
working-directory: ./libs/proxy | |
run: | | |
CURRENT_VERSION=$(poetry version --short) | |
FINAL_VERSION=$(echo "$CURRENT_VERSION" | sed -E 's/[a-zA-Z]+[0-9]*//') | |
echo "Checking for llmstudio-proxy==$FINAL_VERSION on PyPI..." | |
if python -m pip install llmstudio-proxy==$FINAL_VERSION --dry-run >/dev/null 2>&1; then | |
echo "Package llmstudio-proxy==$FINAL_VERSION is already available on PyPI. Please bump version." | |
exit 1 | |
fi | |
done | |
poetry version "$FINAL_VERSION" | |
echo "Updated version: $(poetry version --short)" | |
poetry build | |
poetry publish | |
- name: Commit and push updated pyproject.toml | |
working-directory: ./libs/proxy | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add pyproject.toml | |
git commit -m "[fix] bump release version in pyproject.toml" | |
git push | |
- name: Extract version for tagging Docker image | |
working-directory: ./libs/proxy | |
id: get_version | |
run: echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV | |
# Wait for the package to become available on PyPI | |
- name: Wait for PyPI to update | |
run: | | |
echo "Checking for llmstudio-proxy==${{ env.VERSION }} on PyPI..." | |
for i in {1..10}; do | |
if python -m pip install llmstudio-proxy==${{ env.VERSION }} --dry-run >/dev/null 2>&1; then | |
echo "Package llmstudio-proxy==${{ env.VERSION }} is available on PyPI." | |
break | |
else | |
echo "Package llmstudio-proxy==${{ env.VERSION }} not available yet. Waiting 15 seconds..." | |
sleep 15 | |
fi | |
if [ $i -eq 10 ]; then | |
echo "Package did not become available in time." | |
exit 1 | |
fi | |
done | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker images | |
working-directory: ./deploy | |
run: | | |
make version=${{ env.VERSION }} build-llmstudio-proxy | |
- name: Push Docker images | |
run: | | |
docker push tensoropsai/llmstudio-proxy:${{ env.VERSION }} |