-
Notifications
You must be signed in to change notification settings - Fork 116
197 lines (170 loc) · 6.15 KB
/
Copy pathsdk-version-bump.yml
File metadata and controls
197 lines (170 loc) · 6.15 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
name: SDK Version Bump
on:
schedule:
# Run daily at 9 AM UTC
- cron: '0 9 * * *'
workflow_dispatch:
inputs:
package:
description: 'Package to check'
required: false
default: 'all'
type: choice
options:
- all
- claude-agent-sdk
- anthropic
permissions:
contents: write
pull-requests: write
concurrency:
group: sdk-version-bump
cancel-in-progress: true
jobs:
check-and-bump:
name: Check & Bump SDK Versions
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Check for SDK updates
id: check
env:
PACKAGE_ARG: ${{ inputs.package || 'all' }}
run: |
EXIT_CODE=0
python scripts/sdk-version-bump.py --check-only --package "$PACKAGE_ARG" || EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 2 ]; then
echo "updates_available=true" >> "$GITHUB_OUTPUT"
elif [ "$EXIT_CODE" -eq 0 ]; then
echo "updates_available=false" >> "$GITHUB_OUTPUT"
else
echo "Script failed with exit code $EXIT_CODE"
exit 1
fi
- name: Check for existing PR
if: steps.check.outputs.updates_available == 'true'
id: existing_pr
run: |
# Check if there's already an open PR from this workflow
EXISTING=$(gh pr list \
--head "automated/sdk-version-bump" \
--state open \
--json number \
--jq 'length')
if [ "$EXISTING" -gt "0" ]; then
echo "pr_exists=true" >> "$GITHUB_OUTPUT"
PR_NUM=$(gh pr list \
--head "automated/sdk-version-bump" \
--state open \
--json number \
--jq '.[0].number')
echo "pr_number=$PR_NUM" >> "$GITHUB_OUTPUT"
echo "Existing PR #$PR_NUM found - will update it"
else
echo "pr_exists=false" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Apply updates
if: steps.check.outputs.updates_available == 'true'
id: apply
env:
PACKAGE_ARG: ${{ inputs.package || 'all' }}
run: |
python scripts/sdk-version-bump.py --package "$PACKAGE_ARG"
# Read outputs
PR_TITLE=$(cat .sdk-bump-output/pr-title.txt)
echo "pr_title=$PR_TITLE" >> "$GITHUB_OUTPUT"
- name: Check for SDK options drift
if: steps.check.outputs.updates_available == 'true'
id: drift
run: |
pip install claude-agent-sdk
EXIT_CODE=0
python scripts/sdk-options-drift-check.py || EXIT_CODE=$?
echo "drift_exit=$EXIT_CODE" >> "$GITHUB_OUTPUT"
if [ "$EXIT_CODE" -eq 2 ]; then
echo "::warning::SDK options drift check encountered an error"
elif [ "$EXIT_CODE" -eq 1 ]; then
echo "SDK options drift detected — manifest updated"
fi
- name: Create or update PR
if: steps.check.outputs.updates_available == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: ${{ steps.apply.outputs.pr_title }}
PR_EXISTS: ${{ steps.existing_pr.outputs.pr_exists }}
PR_NUMBER: ${{ steps.existing_pr.outputs.pr_number }}
run: |
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
BRANCH="automated/sdk-version-bump"
# Create or reset the branch
git checkout -B "$BRANCH"
# Stage changes
git add components/runners/ambient-runner/pyproject.toml
git add components/runners/ambient-runner/uv.lock
# Include manifest if drift was detected
if [ -n "$(git diff -- components/runners/ambient-runner/sdk-options-manifest.json)" ]; then
git add components/runners/ambient-runner/sdk-options-manifest.json
{
echo ""
echo "## SDK Options Drift"
echo ""
echo "ClaudeAgentOptions fields changed — sdk-options-manifest.json updated."
echo "Review backend allowlist and frontend schema for new/removed fields."
} >> .sdk-bump-output/pr-body.md
fi
# Commit
git commit -m "${PR_TITLE}
Automated SDK version bump.
Co-Authored-By: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
# Force push (we own this branch)
git push --force origin "$BRANCH"
# Create or update PR (use --body-file to avoid arg length limits)
if [ "$PR_EXISTS" == "true" ]; then
gh pr edit "$PR_NUMBER" \
--title "$PR_TITLE" \
--body-file .sdk-bump-output/pr-body.md
echo "Updated existing PR #$PR_NUMBER"
else
gh pr create \
--title "$PR_TITLE" \
--body-file .sdk-bump-output/pr-body.md \
--base main \
--head "$BRANCH" \
--label "dependencies,automated"
echo "Created new PR"
fi
- name: Summary
if: always()
env:
UPDATES_AVAILABLE: ${{ steps.check.outputs.updates_available }}
run: |
if [ "$UPDATES_AVAILABLE" == "true" ]; then
{
echo "## SDK Version Bump"
echo "Updates applied and PR created/updated."
echo ""
cat .sdk-bump-output/pr-body.md 2>/dev/null || true
} >> "$GITHUB_STEP_SUMMARY"
else
{
echo "## SDK Version Bump"
echo "All tracked SDKs are up to date. No action needed."
} >> "$GITHUB_STEP_SUMMARY"
fi
- name: Clean up output directory
if: always()
run: rm -rf .sdk-bump-output