-
Notifications
You must be signed in to change notification settings - Fork 47
265 lines (232 loc) · 8.67 KB
/
update-versions.yml
File metadata and controls
265 lines (232 loc) · 8.67 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: Update Agent Versions
on:
schedule:
# Run hourly at minute 0
- cron: "0 * * * *"
workflow_dispatch:
inputs:
apply:
description: "Apply updates and commit to main"
required: false
default: true
type: boolean
agents:
description: "Comma-separated agent IDs (leave empty for all)"
required: false
default: ""
type: string
permissions:
contents: read
jobs:
check-versions:
runs-on: ubuntu-latest
outputs:
has_updates: ${{ steps.check.outputs.has_updates }}
updates_json: ${{ steps.check.outputs.updates_json }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
- &generate-token
# Generating a GitHub token, so that PRs and tags created by
# the action can trigger actions workflows.
name: Generate GitHub token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf
id: generate-token
with:
# GitHub App ID secret name
app-id: ${{ secrets.RELEASE_PLZ_APP_ID }}
# GitHub App private key secret name
private-key: ${{ secrets.RELEASE_PLZ_APP_PRIVATE_KEY }}
- name: Check for version updates
id: check
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
set +e
ARGS="--json"
if [ -n "${{ inputs.agents }}" ]; then
ARGS="$ARGS --agents ${{ inputs.agents }}"
fi
OUTPUT=$(python .github/workflows/update_versions.py $ARGS)
EXIT_CODE=$?
echo "$OUTPUT"
# Save JSON output
echo "updates_json<<EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Check if updates are available (exit code 2)
if [ $EXIT_CODE -eq 2 ]; then
echo "has_updates=true" >> $GITHUB_OUTPUT
else
echo "has_updates=false" >> $GITHUB_OUTPUT
fi
# Fail on actual errors (exit code 1)
if [ $EXIT_CODE -eq 1 ]; then
exit 1
fi
notify-failure:
needs: check-versions
if: failure()
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Create failure issue
uses: actions/github-script@v8
with:
script: |
const title = `Version check failed - ${new Date().toISOString().split('T')[0]}`;
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
// Check if issue already exists today
const existingIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'version-check-failure',
per_page: 10
});
const todayIssue = existingIssues.data.find(i => i.title === title);
if (todayIssue) {
// Add comment to existing issue
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: todayIssue.number,
body: `Another failure occurred.\n\n**Run:** ${runUrl}`
});
} else {
// Create new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: `The automated version check workflow failed.\n\n**Run:** ${runUrl}\n\nPlease investigate the failure.`,
labels: ['version-check-failure', 'automated']
});
}
apply-updates:
needs: check-versions
if: needs.check-versions.outputs.has_updates == 'true' && (github.event_name == 'schedule' || inputs.apply == true || inputs.apply == 'true')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- *generate-token
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Apply version updates
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
ARGS="--apply"
if [ -n "${{ inputs.agents }}" ]; then
ARGS="$ARGS --agents ${{ inputs.agents }}"
fi
python .github/workflows/update_versions.py $ARGS
- name: Validate registry build
run: |
pip install jsonschema
python .github/workflows/build_registry.py
- name: Verify agent auth support
timeout-minutes: 15
run: python3 .github/workflows/verify_agents.py --auth-check
- name: Generate commit message
id: commit_msg
run: |
UPDATES='${{ needs.check-versions.outputs.updates_json }}'
# Generate summary of updates
SUMMARY=$(echo "$UPDATES" | python3 -c "
import sys, json
data = json.load(sys.stdin)
updates = data.get('updates', [])
if len(updates) == 1:
u = updates[0]
print(f\"Update {u['agent_id']} to {u['latest_version']}\")
else:
print(f\"Update {len(updates)} agents to latest versions\")
")
# Generate details
DETAILS=$(echo "$UPDATES" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for u in data.get('updates', []):
print(f\"- {u['agent_id']}: {u['current_version']} -> {u['latest_version']}\")
")
echo "summary=$SUMMARY" >> $GITHUB_OUTPUT
echo "details<<EOF" >> $GITHUB_OUTPUT
echo "$DETAILS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Commit and push to main
env:
COMMIT_SUMMARY: ${{ steps.commit_msg.outputs.summary }}
COMMIT_DETAILS: ${{ steps.commit_msg.outputs.details }}
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
git config user.name "acp-release[bot]"
git config user.email "2373403+acp-release[bot]@users.noreply.github.com"
git add -A
git commit -m "$(cat <<EOF
$COMMIT_SUMMARY
$COMMIT_DETAILS
EOF
)"
git push origin main
notify-apply-failure:
needs: [check-versions, apply-updates]
if: always() && needs.apply-updates.result == 'failure'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- *generate-token
- name: Create failure issue
uses: actions/github-script@v8
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
script: |
const title = `Version update failed - ${new Date().toISOString().split('T')[0]}`;
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
// Check if issue already exists today
const existingIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'version-update-failure',
per_page: 10
});
const todayIssue = existingIssues.data.find(i => i.title === title);
if (todayIssue) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: todayIssue.number,
body: `Another failure occurred.\n\n**Run:** ${runUrl}`
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: `The automated version update workflow failed while applying updates.\n\n**Run:** ${runUrl}\n\nThis could be due to:\n- Registry validation failure\n- Auth verification failure\n- Git push conflict\n- Network issues\n\nPlease investigate.`,
labels: ['version-update-failure', 'automated']
});
}