-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathupdate_release.ts
More file actions
213 lines (203 loc) · 6.25 KB
/
Copy pathupdate_release.ts
File metadata and controls
213 lines (203 loc) · 6.25 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
import type { ReleaseResponse, UpdateReleaseParams } from '@/tools/github/types'
import {
RELEASE_ASSET_OUTPUT_PROPERTIES,
RELEASE_OUTPUT_PROPERTIES,
USER_OUTPUT,
} from '@/tools/github/types'
import type { ToolConfig } from '@/tools/types'
export const updateReleaseTool: ToolConfig<UpdateReleaseParams, ReleaseResponse> = {
id: 'github_update_release',
name: 'GitHub Update Release',
description:
'Update an existing GitHub release. Modify tag name, target commit, title, description, draft status, or prerelease status.',
version: '1.0.0',
params: {
owner: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository owner (user or organization)',
},
repo: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Repository name',
},
release_id: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'The unique identifier of the release',
},
tag_name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the tag',
},
target_commitish: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Specifies the commitish value for where the tag is created from',
},
name: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the release',
},
body: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Text describing the contents of the release (markdown supported)',
},
draft: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'true to set as draft, false to publish',
},
prerelease: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'true to identify as a prerelease, false for a full release',
},
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'GitHub Personal Access Token',
},
},
request: {
url: (params) =>
`https://api.github.com/repos/${params.owner}/${params.repo}/releases/${params.release_id}`,
method: 'PATCH',
headers: (params) => ({
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${params.apiKey}`,
'X-GitHub-Api-Version': '2022-11-28',
}),
body: (params) => {
const body: any = {}
if (params.tag_name) {
body.tag_name = params.tag_name
}
if (params.target_commitish) {
body.target_commitish = params.target_commitish
}
if (params.name !== undefined) {
body.name = params.name
}
if (params.body !== undefined) {
body.body = params.body
}
if (params.draft !== undefined) {
body.draft = params.draft
}
if (params.prerelease !== undefined) {
body.prerelease = params.prerelease
}
return body
},
},
transformResponse: async (response) => {
const data = await response.json()
const releaseType = data.draft ? 'Draft' : data.prerelease ? 'Prerelease' : 'Release'
const content = `${releaseType} updated: "${data.name || data.tag_name}"
Tag: ${data.tag_name}
URL: ${data.html_url}
Last updated: ${data.updated_at || data.created_at}
${data.published_at ? `Published: ${data.published_at}` : 'Not yet published'}
Download URLs:
- Tarball: ${data.tarball_url}
- Zipball: ${data.zipball_url}`
return {
success: true,
output: {
content,
metadata: {
id: data.id,
tag_name: data.tag_name,
name: data.name || data.tag_name,
html_url: data.html_url,
tarball_url: data.tarball_url,
zipball_url: data.zipball_url,
draft: data.draft,
prerelease: data.prerelease,
created_at: data.created_at,
published_at: data.published_at,
},
},
}
},
outputs: {
content: { type: 'string', description: 'Human-readable release update summary' },
metadata: {
type: 'object',
description: 'Updated release metadata including download URLs',
properties: {
id: { type: 'number', description: 'Release ID' },
tag_name: { type: 'string', description: 'Git tag name' },
name: { type: 'string', description: 'Release name' },
html_url: { type: 'string', description: 'GitHub web URL for the release' },
tarball_url: { type: 'string', description: 'URL to download release as tarball' },
zipball_url: { type: 'string', description: 'URL to download release as zipball' },
draft: { type: 'boolean', description: 'Whether this is a draft release' },
prerelease: { type: 'boolean', description: 'Whether this is a prerelease' },
created_at: { type: 'string', description: 'Creation timestamp' },
published_at: { type: 'string', description: 'Publication timestamp' },
},
},
},
}
export const updateReleaseV2Tool: ToolConfig = {
id: 'github_update_release_v2',
name: updateReleaseTool.name,
description: updateReleaseTool.description,
version: '2.0.0',
params: updateReleaseTool.params,
request: updateReleaseTool.request,
oauth: updateReleaseTool.oauth,
transformResponse: async (response: Response) => {
const data = await response.json()
return {
success: true,
output: {
id: data.id,
tag_name: data.tag_name,
name: data.name,
body: data.body ?? null,
html_url: data.html_url,
tarball_url: data.tarball_url,
zipball_url: data.zipball_url,
draft: data.draft,
prerelease: data.prerelease,
author: data.author,
assets: data.assets,
target_commitish: data.target_commitish,
created_at: data.created_at,
published_at: data.published_at ?? null,
},
}
},
outputs: {
...RELEASE_OUTPUT_PROPERTIES,
author: USER_OUTPUT,
assets: {
type: 'array',
description: 'Release assets',
items: {
type: 'object',
properties: {
...RELEASE_ASSET_OUTPUT_PROPERTIES,
uploader: USER_OUTPUT,
},
},
},
},
}