PyPI prerelease any module. #30
This file contains hidden or 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: Upload Python package to PyPI as dev release and build/push Docker image. | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: develop | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
- name: Configure Poetry | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
- name: Build and publish to PyPI as development release | |
working-directory: ./libs/llmstudio | |
run: | | |
poetry version prerelease | |
poetry build | |
poetry publish | |
- name: Commit and push updated pyproject.toml | |
working-directory: ./libs/llmstudio | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
git add pyproject.toml | |
git commit -m "[fix] bump prerelease version in pyproject.toml" | |
git push | |
# Wait for PyPI to update | |
- name: Wait for PyPI to update | |
working-directory: ./libs/llmstudio | |
run: | | |
VERSION=$(poetry version --short) | |
echo "Checking for llmstudio==$VERSION on PyPI..." | |
for i in {1..10}; do | |
if python -m pip install llmstudio==${VERSION} --dry-run >/dev/null 2>&1; then | |
echo "Package llmstudio==${VERSION} is available on PyPI." | |
break | |
else | |
echo "Package llmstudio==${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 | |
# Docker build and push section | |
- 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: Extract version for tagging Docker image | |
working-directory: ./libs/llmstudio | |
id: get_version | |
run: | | |
echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV | |
# Build and tag Docker images with both :latest and :[NEW_VERSION] | |
- name: Proxy Build and tag Docker images | |
working-directory: ./deploy | |
run: | | |
make version=${{ env.VERSION }} build-proxy | |
# Build and tag Docker images with both :latest and :[NEW_VERSION] | |
- name: Tracker Build and tag Docker images | |
working-directory: ./deploy | |
run: | | |
make version=${{ env.VERSION }} build-tracker | |
# Push both Docker images to Docker Hub | |
- name: Push Proxy Docker images to Docker Hub | |
run: | | |
docker push tensoropsai/llmstudio-proxy:${{ env.VERSION }} | |
# Push both Docker images to Docker Hub | |
- name: Push Tracker Docker images to Docker Hub | |
run: | | |
docker push tensoropsai/llmstudio-tracker:${{ env.VERSION }} |