-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (171 loc) · 7.82 KB
/
publish-dev.yml
File metadata and controls
213 lines (171 loc) · 7.82 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Publish Dev Build
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
jobs:
detect-changes:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'build:dev')
outputs:
core-changed: ${{ steps.changes.outputs.core }}
langchain-changed: ${{ steps.changes.outputs.langchain }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect changed packages
id: changes
run: |
# Get list of changed files
git diff origin/main...HEAD --name-only > changes.txt
echo "Changed files:"
cat changes.txt
# Check if core package changed
if grep -qE '^src/uipath/llm_client/' changes.txt; then
echo "core=true" >> $GITHUB_OUTPUT
echo "Core package has changes"
else
echo "core=false" >> $GITHUB_OUTPUT
echo "Core package has no changes"
fi
# Check if langchain package changed
if grep -qE '^packages/uipath_langchain_client/' changes.txt; then
echo "langchain=true" >> $GITHUB_OUTPUT
echo "Langchain package has changes"
else
echo "langchain=false" >> $GITHUB_OUTPUT
echo "Langchain package has no changes"
fi
publish-dev:
needs: detect-changes
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.core-changed == 'true' || needs.detect-changes.outputs.langchain-changed == 'true'
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.9.27"
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: ".python-version"
- name: Install dependencies
run: uv sync --dev --all-extras --locked
- name: Set development versions and update PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CORE_CHANGED: ${{ needs.detect-changes.outputs.core-changed }}
LANGCHAIN_CHANGED: ${{ needs.detect-changes.outputs.langchain-changed }}
run: |
# Get PR number and run number with proper padding
PR_NUM="${{ github.event.pull_request.number }}"
PADDED_PR=$(printf "%05d" $PR_NUM)
PADDED_RUN=$(printf "%04d" ${{ github.run_number }})
NEXT_PR=$((PR_NUM + 1))
PADDED_NEXT_PR=$(printf "%05d" $NEXT_PR)
# Initialize arrays for changed packages
PACKAGES_INFO=""
DEPENDENCIES_EXACT=""
DEPENDENCIES_RANGE=""
SOURCES=""
OVERRIDES=""
# Process core package if changed
if [ "$CORE_CHANGED" == "true" ]; then
# Read current version from __version__.py
CORE_VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]+' src/uipath/llm_client/__version__.py)
DEV_VERSION="${CORE_VERSION}.dev1${PADDED_PR}${PADDED_RUN}"
MIN_VERSION="${CORE_VERSION}.dev1${PADDED_PR}0000"
MAX_VERSION="${CORE_VERSION}.dev1${PADDED_NEXT_PR}0000"
# Update __version__.py
sed -i "s/__version__ = \".*\"/__version__ = \"${DEV_VERSION}\"/" src/uipath/llm_client/__version__.py
echo "Core package version set to $DEV_VERSION"
DEPENDENCIES_EXACT="${DEPENDENCIES_EXACT} \"uipath-llm-client==${DEV_VERSION}\",\n"
DEPENDENCIES_RANGE="${DEPENDENCIES_RANGE} \"uipath-llm-client>=${MIN_VERSION},<${MAX_VERSION}\",\n"
SOURCES="${SOURCES}uipath-llm-client = { index = \"testpypi\" }\n"
OVERRIDES="${OVERRIDES} \"uipath-llm-client>=${MIN_VERSION},<${MAX_VERSION}\",\n"
fi
# Process langchain package if changed
if [ "$LANGCHAIN_CHANGED" == "true" ]; then
# Read current version from __version__.py
LC_VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]+' packages/uipath_langchain_client/src/uipath_langchain_client/__version__.py)
DEV_VERSION="${LC_VERSION}.dev1${PADDED_PR}${PADDED_RUN}"
MIN_VERSION="${LC_VERSION}.dev1${PADDED_PR}0000"
MAX_VERSION="${LC_VERSION}.dev1${PADDED_NEXT_PR}0000"
# Update __version__.py
sed -i "s/__version__ = \".*\"/__version__ = \"${DEV_VERSION}\"/" packages/uipath_langchain_client/src/uipath_langchain_client/__version__.py
echo "Langchain package version set to $DEV_VERSION"
DEPENDENCIES_EXACT="${DEPENDENCIES_EXACT} \"uipath-langchain-client==${DEV_VERSION}\",\n"
DEPENDENCIES_RANGE="${DEPENDENCIES_RANGE} \"uipath-langchain-client>=${MIN_VERSION},<${MAX_VERSION}\",\n"
SOURCES="${SOURCES}uipath-langchain-client = { index = \"testpypi\" }\n"
OVERRIDES="${OVERRIDES} \"uipath-langchain-client>=${MIN_VERSION},<${MAX_VERSION}\",\n"
fi
# Build PR description
cat > /tmp/pr_update.md << 'HEREDOC_END'
<!-- DEV_PACKAGE_START -->
## Development Package
Add these packages as dependencies in your pyproject.toml:
```toml
[project]
dependencies = [
# Exact versions:
HEREDOC_END
echo -e "${DEPENDENCIES_EXACT}" >> /tmp/pr_update.md
cat >> /tmp/pr_update.md << 'HEREDOC_END'
# Or use version ranges for any build from this PR:
HEREDOC_END
echo -e "${DEPENDENCIES_RANGE}" >> /tmp/pr_update.md
cat >> /tmp/pr_update.md << 'HEREDOC_END'
]
[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
[tool.uv.sources]
HEREDOC_END
echo -e "${SOURCES}" >> /tmp/pr_update.md
cat >> /tmp/pr_update.md << 'HEREDOC_END'
[tool.uv]
override-dependencies = [
HEREDOC_END
echo -e "${OVERRIDES}" >> /tmp/pr_update.md
cat >> /tmp/pr_update.md << 'HEREDOC_END'
]
```
<!-- DEV_PACKAGE_END -->
HEREDOC_END
DEV_MESSAGE=$(cat /tmp/pr_update.md)
# Update PR description using GitHub API
PR_URL="https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUM}"
CURRENT_BODY=$(gh pr view ${PR_NUM} --json body -q '.body' || echo "")
# Check if markers exist and replace or append
if echo "$CURRENT_BODY" | grep -q "<!-- DEV_PACKAGE_START -->"; then
# Replace content between markers
NEW_BODY=$(echo "$CURRENT_BODY" | sed '/<!-- DEV_PACKAGE_START -->/,/<!-- DEV_PACKAGE_END -->/d')
NEW_BODY="${NEW_BODY}
${DEV_MESSAGE}"
else
# Append to end
NEW_BODY="${CURRENT_BODY}
${DEV_MESSAGE}"
fi
# Update PR
gh pr edit ${PR_NUM} --body "$NEW_BODY"
echo "Updated PR description with development package information"
- name: Build core package
if: needs.detect-changes.outputs.core-changed == 'true'
run: uv build --package uipath-llm-client
- name: Build langchain package
if: needs.detect-changes.outputs.langchain-changed == 'true'
run: uv build --package uipath-langchain-client
- name: Publish core package
if: needs.detect-changes.outputs.core-changed == 'true'
run: uv publish dist/uipath_llm_client* --index testpypi --token ${{ secrets.UV_PUBLISH_TOKEN_UIPATH_LLM_CLIENT }}
- name: Publish langchain package
if: needs.detect-changes.outputs.langchain-changed == 'true'
run: uv publish dist/uipath_langchain_client* --index testpypi --token ${{ secrets.UV_PUBLISH_TOKEN_UIPATH_LANGCHAIN_CLIENT }}