-
Notifications
You must be signed in to change notification settings - Fork 34
114 lines (97 loc) · 3.58 KB
/
upload-pypi-proxy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: llmstudio-proxy to PyPI and build/push Docker images.
on:
push:
branches:
- main
paths:
- "libs/proxy/**"
- "!libs/proxy/pyproject.toml"
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v3
with:
ref: main
token: ${{ secrets.GH_TOKEN }}
# 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
poetry version "$FINAL_VERSION"
echo "Updated version: $(poetry version --short)"
poetry build
poetry publish
if [ "$CURRENT_VERSION" = "$FINAL_VERSION" ]; then
echo "SAME_VERSION=true" >> $GITHUB_ENV
else
echo "SAME_VERSION=false" >> $GITHUB_ENV
fi
- name: Commit and push updated pyproject.toml
working-directory: ./libs/proxy
run: |
if [ "${{ env.SAME_VERSION }}" = "false" ]; then
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
fi
- 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 }}