Skip to content

Commit 56696fd

Browse files
committed
no-jira: Added action to update all versions for pre-release
1 parent 22dbaaf commit 56696fd

File tree

1 file changed

+334
-0
lines changed

1 file changed

+334
-0
lines changed
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
name: Update SDK, Ray, and CUDA Versions & Runtime Image SHAs
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
new_sdk_version:
7+
description: 'New SDK version (e.g., 0.32.0)'
8+
required: false
9+
type: string
10+
default: ''
11+
new_ray_version:
12+
description: 'New Ray version (e.g., 2.48.0)'
13+
required: false
14+
type: string
15+
default: ''
16+
new_cuda_py311_sha:
17+
description: 'New CUDA Python 3.11 runtime image SHA (e.g., abc123...)'
18+
required: false
19+
type: string
20+
default: ''
21+
new_cuda_py312_sha:
22+
description: 'New CUDA Python 3.12 runtime image SHA (e.g., def456...)'
23+
required: false
24+
type: string
25+
default: ''
26+
new_cuda_version_py311:
27+
description: 'New CUDA version for Python 3.11 (e.g., cu121)'
28+
required: false
29+
type: string
30+
default: ''
31+
new_cuda_version_py312:
32+
description: 'New CUDA version for Python 3.12 (e.g., cu128)'
33+
required: false
34+
type: string
35+
default: ''
36+
37+
env:
38+
PR_BRANCH_NAME: ray-version-update-${{ github.run_id }}
39+
40+
jobs:
41+
update-versions:
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: write
45+
pull-requests: write
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
with:
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
fetch-depth: 0
52+
53+
- name: Set up Python
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: '3.11'
57+
58+
59+
- name: Configure git and create branch
60+
run: |
61+
git config --local user.email "[email protected]"
62+
git config --local user.name "GitHub Action"
63+
git checkout main
64+
git pull origin main
65+
git checkout -b ${{ env.PR_BRANCH_NAME }}
66+
67+
- name: Update constants.py
68+
run: |
69+
# Update Ray version if provided
70+
if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then
71+
sed -i "s/RAY_VERSION = \"[^\"]*\"/RAY_VERSION = \"${{ github.event.inputs.new_ray_version }}\"/" src/codeflare_sdk/common/utils/constants.py
72+
73+
# Update comments with new Ray version and CUDA versions if both are provided
74+
if [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then
75+
sed -i "s/\* For python 3.11:ray:[^\"]*/\* For python 3.11:ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/" src/codeflare_sdk/common/utils/constants.py
76+
fi
77+
if [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then
78+
sed -i "s/\* For python 3.12:ray:[^\"]*/\* For python 3.12:ray:${{ github.event.inputs.new_ray_version }}-py312-${{ github.event.inputs.new_cuda_version_py312 }}/" src/codeflare_sdk/common/utils/constants.py
79+
fi
80+
fi
81+
82+
# Update runtime image SHAs if provided
83+
if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then
84+
sed -i "s/CUDA_PY311_RUNTIME_IMAGE = \"quay\.io\/modh\/ray@sha256:[^\"]*\"/CUDA_PY311_RUNTIME_IMAGE = \"quay.io\/modh\/ray@sha256:${{ github.event.inputs.new_cuda_py311_sha }}\"/" src/codeflare_sdk/common/utils/constants.py
85+
fi
86+
87+
if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then
88+
sed -i "s/CUDA_PY312_RUNTIME_IMAGE = \"quay\.io\/modh\/ray@sha256:[^\"]*\"/CUDA_PY312_RUNTIME_IMAGE = \"quay.io\/modh\/ray@sha256:${{ github.event.inputs.new_cuda_py312_sha }}\"/" src/codeflare_sdk/common/utils/constants.py
89+
fi
90+
91+
- name: Update pyproject.toml
92+
run: |
93+
# Update Ray dependency version in pyproject.toml if Ray version is provided
94+
if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then
95+
sed -i "s/ray = {version = \"[^\"]*\", extras = \[\"data\", \"default\"\]}/ray = {version = \"${{ github.event.inputs.new_ray_version }}\", extras = [\"data\", \"default\"]}/" pyproject.toml
96+
fi
97+
98+
# Update SDK version in pyproject.toml if SDK version is provided
99+
if [ -n "${{ github.event.inputs.new_sdk_version }}" ]; then
100+
# Update both [project] and [tool.poetry] version fields
101+
sed -i "s/^version = \"[^\"]*\"/version = \"${{ github.event.inputs.new_sdk_version }}\"/" pyproject.toml
102+
fi
103+
104+
- name: Update documentation files
105+
run: |
106+
# Update documentation files with new Ray version and image tags if provided
107+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then
108+
find docs/ -name "*.rst" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \;
109+
find docs/ -name "*.rst" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-rocm[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-rocm62/g" {} \;
110+
fi
111+
112+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then
113+
find docs/ -name "*.rst" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py312-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py312-${{ github.event.inputs.new_cuda_version_py312 }}/g" {} \;
114+
fi
115+
116+
- name: Update notebook files
117+
run: |
118+
# Update notebook files with new Ray version and image tags if provided
119+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then
120+
find demo-notebooks/ -name "*.ipynb" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \;
121+
fi
122+
123+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then
124+
find demo-notebooks/ -name "*.ipynb" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py312-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py312-${{ github.event.inputs.new_cuda_version_py312 }}/g" {} \;
125+
fi
126+
127+
# Update notebook files with new Ray version only (for cases where CUDA version isn't specified)
128+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -z "${{ github.event.inputs.new_cuda_version_py311 }}" ] && [ -z "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then
129+
# Update Ray version in image tags while preserving existing CUDA versions
130+
find demo-notebooks/ -name "*.ipynb" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-cu121/g" {} \;
131+
find demo-notebooks/ -name "*.ipynb" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py312-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py312-cu128/g" {} \;
132+
fi
133+
134+
- name: Update YAML test files
135+
run: |
136+
# Update YAML files with new Ray version if provided
137+
if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then
138+
find tests/ -name "*.yaml" -exec sed -i "s/rayVersion: [0-9]\+\.[0-9]\+\.[0-9]\+/rayVersion: ${{ github.event.inputs.new_ray_version }}/g" {} \;
139+
fi
140+
141+
# Update image tags in YAML files if Ray version and CUDA versions are provided
142+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then
143+
find tests/ -name "*.yaml" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \;
144+
fi
145+
146+
- name: Update output YAML files
147+
run: |
148+
# Update output YAML files in demo-notebooks if Ray version and CUDA version are provided
149+
if [ -n "${{ github.event.inputs.new_ray_version }}" ] && [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then
150+
find demo-notebooks/ -name "*.yaml" -exec sed -i "s/quay\.io\/modh\/ray:[0-9]\+\.[0-9]\+\.[0-9]\+-py311-cu[0-9]\+/quay.io\/modh\/ray:${{ github.event.inputs.new_ray_version }}-py311-${{ github.event.inputs.new_cuda_version_py311 }}/g" {} \;
151+
fi
152+
153+
- name: Validate updates
154+
run: |
155+
# Check if constants.py was updated correctly (only if Ray version was provided)
156+
if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then
157+
if ! grep -q "RAY_VERSION = \"${{ github.event.inputs.new_ray_version }}\"" src/codeflare_sdk/common/utils/constants.py; then
158+
echo "✗ Ray version not found in constants.py"
159+
echo "Expected: RAY_VERSION = \"${{ github.event.inputs.new_ray_version }}\""
160+
echo "Found:"
161+
grep "RAY_VERSION" src/codeflare_sdk/common/utils/constants.py || echo " (not found)"
162+
exit 1
163+
fi
164+
165+
# Check if pyproject.toml was updated correctly
166+
if ! grep -q "ray = {version = \"${{ github.event.inputs.new_ray_version }}\"" pyproject.toml; then
167+
echo "✗ Ray version not found in pyproject.toml"
168+
echo "Expected: ray = {version = \"${{ github.event.inputs.new_ray_version }}\""
169+
echo "Found:"
170+
grep "ray = " pyproject.toml || echo " (not found)"
171+
exit 1
172+
fi
173+
fi
174+
175+
# Check if SDK version was updated correctly (only if SDK version was provided)
176+
if [ -n "${{ github.event.inputs.new_sdk_version }}" ]; then
177+
if ! grep -q "version = \"${{ github.event.inputs.new_sdk_version }}\"" pyproject.toml; then
178+
echo "✗ SDK version not found in pyproject.toml"
179+
echo "Expected: version = \"${{ github.event.inputs.new_sdk_version }}\""
180+
echo "Found:"
181+
grep "version = " pyproject.toml || echo " (not found)"
182+
exit 1
183+
fi
184+
fi
185+
186+
# Check if runtime images were updated (only if SHAs were provided)
187+
if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then
188+
if ! grep -q "quay.io/modh/ray@sha256:${{ github.event.inputs.new_cuda_py311_sha }}" src/codeflare_sdk/common/utils/constants.py; then
189+
echo "✗ Python 3.11 runtime image not found"
190+
echo "Expected: quay.io/modh/ray@sha256:${{ github.event.inputs.new_cuda_py311_sha }}"
191+
echo "Found:"
192+
grep "CUDA_PY311_RUNTIME_IMAGE" src/codeflare_sdk/common/utils/constants.py || echo " (not found)"
193+
exit 1
194+
fi
195+
fi
196+
197+
if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then
198+
if ! grep -q "quay.io/modh/ray@sha256:${{ github.event.inputs.new_cuda_py312_sha }}" src/codeflare_sdk/common/utils/constants.py; then
199+
echo "✗ Python 3.12 runtime image not found"
200+
echo "Expected: quay.io/modh/ray@sha256:${{ github.event.inputs.new_cuda_py312_sha }}"
201+
echo "Found:"
202+
grep "CUDA_PY312_RUNTIME_IMAGE" src/codeflare_sdk/common/utils/constants.py || echo " (not found)"
203+
exit 1
204+
fi
205+
fi
206+
207+
- name: Check for changes
208+
id: check-changes
209+
run: |
210+
if git diff --quiet; then
211+
echo "has-changes=false" >> $GITHUB_OUTPUT
212+
else
213+
echo "has-changes=true" >> $GITHUB_OUTPUT
214+
fi
215+
216+
- name: Commit changes
217+
if: steps.check-changes.outputs.has-changes == 'true'
218+
run: |
219+
git add .
220+
221+
# Build commit message based on what was updated
222+
COMMIT_MSG="Update Ray configuration"
223+
224+
if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then
225+
COMMIT_MSG="$COMMIT_MSG
226+
227+
- Updated Ray version to ${{ github.event.inputs.new_ray_version }} in constants.py and pyproject.toml"
228+
fi
229+
230+
if [ -n "${{ github.event.inputs.new_sdk_version }}" ]; then
231+
COMMIT_MSG="$COMMIT_MSG
232+
- Updated SDK version to ${{ github.event.inputs.new_sdk_version }} in pyproject.toml"
233+
fi
234+
235+
if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then
236+
COMMIT_MSG="$COMMIT_MSG
237+
- Updated Python 3.11 CUDA runtime image SHA"
238+
fi
239+
240+
if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then
241+
COMMIT_MSG="$COMMIT_MSG
242+
- Updated Python 3.12 CUDA runtime image SHA"
243+
fi
244+
245+
if [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ] || [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then
246+
COMMIT_MSG="$COMMIT_MSG
247+
- Updated documentation and notebook files with new CUDA versions"
248+
fi
249+
250+
COMMIT_MSG="$COMMIT_MSG
251+
252+
Parameters provided:
253+
- Ray version: ${{ github.event.inputs.new_ray_version }}
254+
- SDK version: ${{ github.event.inputs.new_sdk_version }}
255+
- Python 3.11 CUDA version: ${{ github.event.inputs.new_cuda_version_py311 }}
256+
- Python 3.12 CUDA version: ${{ github.event.inputs.new_cuda_version_py312 }}
257+
- Python 3.11 runtime SHA: ${{ github.event.inputs.new_cuda_py311_sha }}
258+
- Python 3.12 runtime SHA: ${{ github.event.inputs.new_cuda_py312_sha }}"
259+
260+
git commit -m "$COMMIT_MSG"
261+
262+
- name: Push changes
263+
if: steps.check-changes.outputs.has-changes == 'true'
264+
run: |
265+
git push origin ${{ env.PR_BRANCH_NAME }}
266+
267+
- name: Create Pull Request
268+
if: steps.check-changes.outputs.has-changes == 'true'
269+
run: |
270+
# Get current versions for comparison
271+
CURRENT_SDK_VERSION=$(grep -E "^version = " pyproject.toml | head -1 | sed 's/version = "\([^"]*\)"/\1/')
272+
CURRENT_RAY_VERSION=$(grep "RAY_VERSION = " src/codeflare_sdk/common/utils/constants.py | sed 's/RAY_VERSION = "\([^"]*\)"/\1/')
273+
274+
PR_TITLE="Pre-Release Version Updates"
275+
276+
PR_BODY="## Pre-Release Version Updates
277+
278+
This PR contains automated version updates for the upcoming release.
279+
280+
### Changes Made:"
281+
282+
if [ -n "${{ github.event.inputs.new_sdk_version }}" ]; then
283+
PR_BODY="$PR_BODY
284+
- **CodeFlare SDK**: Bumped from \`v${CURRENT_SDK_VERSION}\` to \`v${{ github.event.inputs.new_sdk_version }}\`"
285+
fi
286+
287+
if [ -n "${{ github.event.inputs.new_ray_version }}" ]; then
288+
PR_BODY="$PR_BODY
289+
- **Ray**: Bumped from \`v${CURRENT_RAY_VERSION}\` to \`v${{ github.event.inputs.new_ray_version }}\`"
290+
fi
291+
292+
if [ -n "${{ github.event.inputs.new_cuda_py311_sha }}" ]; then
293+
PR_BODY="$PR_BODY
294+
- **Python 3.11 CUDA Runtime**: Updated to [\`${{ github.event.inputs.new_cuda_py311_sha }}\`](https://quay.io/repository/modh/ray/manifest/sha256:${{ github.event.inputs.new_cuda_py311_sha }})"
295+
if [ -n "${{ github.event.inputs.new_cuda_version_py311 }}" ]; then
296+
PR_BODY="$PR_BODY (CUDA \`${{ github.event.inputs.new_cuda_version_py311 }}\`)"
297+
fi
298+
fi
299+
300+
if [ -n "${{ github.event.inputs.new_cuda_py312_sha }}" ]; then
301+
PR_BODY="$PR_BODY
302+
- **Python 3.12 CUDA Runtime**: Updated to [\`${{ github.event.inputs.new_cuda_py312_sha }}\`](https://quay.io/repository/modh/ray/manifest/sha256:${{ github.event.inputs.new_cuda_py312_sha }})"
303+
if [ -n "${{ github.event.inputs.new_cuda_version_py312 }}" ]; then
304+
PR_BODY="$PR_BODY (CUDA \`${{ github.event.inputs.new_cuda_version_py312 }}\`)"
305+
fi
306+
fi
307+
308+
PR_BODY="$PR_BODY
309+
310+
### Testing:
311+
Please run the test suite to ensure all changes work correctly:
312+
\`\`\`bash
313+
poetry install
314+
poetry run pytest
315+
\`\`\`
316+
317+
### Review Checklist:
318+
- [ ] Verify version updates are correct
319+
- [ ] Check that runtime image SHAs are valid
320+
- [ ] Run tests to verify compatibility"
321+
322+
# Create PR using GitHub CLI
323+
gh pr create \
324+
--title "$PR_TITLE" \
325+
--body "$PR_BODY" \
326+
--base main \
327+
--head ${{ env.PR_BRANCH_NAME }}
328+
env:
329+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
330+
331+
- name: Comment on workflow run
332+
if: steps.check-changes.outputs.has-changes == 'false'
333+
run: |
334+
echo "No changes were made. Please verify the input parameters."

0 commit comments

Comments
 (0)