8
8
type : choice
9
9
description : " Choose the library to deploy (note: it points to develop branch only)"
10
10
options :
11
- - llmstudio
12
- - llmstudio- core
13
- - llmstudio- proxy
14
- - llmstudio- tracker
11
+ - ./libs/ llmstudio
12
+ - ./libs/ core
13
+ - ./libs/ proxy
14
+ - ./libs/ tracker
15
15
target_version :
16
16
description : " Target version (e.g., 1.1.0)"
17
17
required : true
20
20
jobs :
21
21
deploy :
22
22
runs-on : ubuntu-latest
23
- env :
24
- MODULE_PATH : |
25
- ${{
26
- inputs.library == 'llmstudio' && './libs/llmstudio' ||
27
- inputs.library == 'llmstudio-core' && './libs/core' ||
28
- inputs.library == 'llmstudio-proxy' && './libs/proxy' ||
29
- inputs.library == 'llmstudio-tracker' && './libs/tracker'
30
- }}
31
23
steps :
32
24
- name : Checkout code
33
25
uses : actions/checkout@v3
@@ -47,49 +39,38 @@ jobs:
47
39
run : poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
48
40
49
41
- name : Check PyPI for Target Version
50
- working-directory : ${{ env.MODULE_PATH }}
42
+ working-directory : ${{ inputs.library }}
51
43
id : check-version
52
44
run : |
53
45
TARGET_VERSION="${{ github.event.inputs.target_version }}"
54
- PACKAGE_NAME=${{ inputs.library }}
46
+ PACKAGE_NAME=$(poetry version | awk '{print $1}')
55
47
RESPONSE=$(curl -s "https://pypi.org/pypi/$PACKAGE_NAME/json" || echo "{}")
56
48
echo "$RESPONSE" | jq -r '.releases | keys[]' > all_versions.txt
57
- if grep -qx "$TARGET_VERSION" all_versions.txt; then
58
- echo "exists=true" >> $GITHUB_ENV
59
- else
60
- echo "exists=false" >> $GITHUB_ENV
61
- fi
62
49
63
- # Step 4: Decide on the next alpha version
64
- - name : Determine Next Alpha Version
65
- id : determine-version
66
- run : |
67
- if [[ "${{ env.exists }}" == "true" ]]; then
50
+ if grep -qx "$TARGET_VERSION" all_versions.txt; then
68
51
echo "Error: Version ${{ github.event.inputs.target_version }} already exists on PyPI."
69
52
exit 1
70
53
fi
71
- BASE_VERSION="${{ github.event.inputs.target_version }}"
72
- PACKAGE_NAME=${{ inputs.library }}
73
- ALPHA_VERSIONS=$(grep -E "^$BASE_VERSIONa[0-9]+$" all_versions.txt | sort -V || true)
74
- if [[ -z "$ALPHA_VERSIONS " ]]; then
75
- NEW_VERSION="${BASE_VERSION }a0"
54
+
55
+ NEXT_ALPHA=$(grep "^${TARGET_VERSION}a[0-9]*$" all_versions.txt | sort -V | tail -n 1 | awk -F'a' '{print $2}')
56
+
57
+ if [[ -z "$NEXT_ALPHA " ]]; then
58
+ NEW_VERSION="${TARGET_VERSION }a0"
76
59
else
77
- LATEST_ALPHA=$(echo "$ALPHA_VERSIONS" | tail -n 1)
78
- NEXT_ALPHA_NUM=$(( $(echo "$LATEST_ALPHA" | grep -oE '[0-9]+$') + 1 ))
79
- NEW_VERSION="${BASE_VERSION}a${NEXT_ALPHA_NUM}"
60
+ NEW_VERSION="${TARGET_VERSION}a$((NEXT_ALPHA + 1))"
80
61
fi
81
62
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
82
63
echo "Determined new version: $NEW_VERSION"
83
64
84
65
- name : Build and publish to PyPI as development release
85
- working-directory : ${{ env.MODULE_PATH }}
66
+ working-directory : ${{ inputs.library }}
86
67
run : |
87
68
poetry version ${{ env.new_version }}
88
69
poetry build
89
70
poetry publish
90
71
91
72
- name : Commit and push updated pyproject.toml
92
- working-directory : ${{ env.MODULE_PATH }}
73
+ working-directory : ${{ inputs.library }}
93
74
run : |
94
75
git config user.name "GitHub Actions"
95
76
git config user.email "[email protected] "
@@ -98,43 +79,21 @@ jobs:
98
79
git push
99
80
100
81
- name : Wait for PyPI to update
101
- working-directory : ${{ env.MODULE_PATH }}
82
+ working-directory : ${{ inputs.library }}
102
83
run : |
103
84
VERSION=$(poetry version --short)
104
- echo "Checking for ${{ github.event.inputs.library }}==$VERSION on PyPI..."
85
+ PACKAGE_NAME=$(poetry version | awk '{print $1}')
86
+ echo "Checking for $PACKAGE_NAME==$VERSION on PyPI..."
105
87
for i in {1..10}; do
106
- if python -m pip install ${{ github.event.inputs.library }} ==${VERSION} --dry-run >/dev/null 2>&1; then
107
- echo "Package ${{ github.event.inputs.library }} ==${VERSION} is available on PyPI."
88
+ if python -m pip install $PACKAGE_NAME ==${VERSION} --dry-run >/dev/null 2>&1; then
89
+ echo "Package $PACKAGE_NAME ==${VERSION} is available on PyPI."
108
90
break
109
91
else
110
- echo "Package ${{ github.event.inputs.library }} ==${VERSION} not available yet. Waiting 15 seconds..."
92
+ echo "Package $PACKAGE_NAME ==${VERSION} not available yet. Waiting 15 seconds..."
111
93
sleep 15
112
94
fi
113
95
if [ $i -eq 10 ]; then
114
96
echo "Package did not become available in time."
115
97
exit 1
116
98
fi
117
99
done
118
-
119
- - name : Set up Docker Buildx
120
- uses : docker/setup-buildx-action@v2
121
-
122
- - name : Log in to Docker Hub
123
- uses : docker/login-action@v2
124
- with :
125
- username : ${{ secrets.DOCKER_USERNAME }}
126
- password : ${{ secrets.DOCKER_PASSWORD }}
127
-
128
- - name : Extract version for tagging Docker image
129
- working-directory : ${{ env.MODULE_PATH }}
130
- id : get_version
131
- run : echo "VERSION=$(poetry version --short)" >> $GITHUB_ENV
132
-
133
- - name : Build Docker images
134
- working-directory : ./deploy
135
- run : |
136
- make version=${{ env.VERSION }} build-${{ github.event.inputs.library }}
137
-
138
- - name : Push Docker images
139
- run : |
140
- docker push tensoropsai/${{ github.event.inputs.library }}:${{ env.VERSION }}
0 commit comments