1 | |
2 | |
3 | * Create a new release for an organization |
4 | * Create a new release for the given organization. Releases are used by |
5 | Sentry to improve its error reporting abilities by correlating |
6 | first seen events with the release that might have introduced the |
7 | problem. |
8 | Releases are also necessary for source maps and other debug features |
9 | that require manual upload for functioning well. |
10 | */ |
11 | export async function main(auth: RT.Sentry, body: Body) { |
12 | const url = new URL( |
13 | `https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/releases/` |
14 | ) |
15 |
|
16 | const response = await fetch(url, { |
17 | method: 'POST', |
18 | headers: { |
19 | 'Content-Type': 'application/json', |
20 | Authorization: 'Bearer ' + auth.token |
21 | }, |
22 | body: JSON.stringify(body) |
23 | }) |
24 | if (!response.ok) { |
25 | const text = await response.text() |
26 | throw new Error(`${response.status} ${text}`) |
27 | } |
28 | return await response.json() |
29 | } |
30 |
|
31 | |
32 | |
33 | * This file was automatically generated by json-schema-to-typescript. |
34 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
35 | * and run json-schema-to-typescript to regenerate this file. |
36 | */ |
37 |
|
38 | export interface Body { |
39 | |
40 | * A version identifier for this release. Can be a version number, a commit hash, etc. |
41 | */ |
42 | version: string |
43 | |
44 | * A list of project slugs that are involved in this release. |
45 | */ |
46 | projects: string[] |
47 | |
48 | * An optional commit reference. This is useful if a tagged version has been provided. |
49 | */ |
50 | ref?: string |
51 | |
52 | * A URL that points to the release. This can be the path to an online interface to the source code for instance |
53 | */ |
54 | url?: string |
55 | |
56 | * An optional date that indicates when the release went live. If not provided the current time is assumed. |
57 | */ |
58 | dateReleased?: string |
59 | |
60 | * An optional list of commit data to be associated with the release. Commits must include parameters `id` (the SHA of the commit), and can optionally include `repository`, `message`, `patch_set`, `author_name`, `author_email`, and `timestamp`. |
61 | */ |
62 | commits?: { |
63 | |
64 | * A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees. |
65 | */ |
66 | patch_set?: { |
67 | |
68 | * The path to the file. Both forward and backward slashes are supported. |
69 | */ |
70 | path: string |
71 | |
72 | * The type of change that happened in the commit. |
73 | */ |
74 | type: 'A' | 'M' | 'D' |
75 | [k: string]: unknown |
76 | }[] |
77 | |
78 | * The full name of the repository the commit belongs to. If this field is not given Sentry will generate a name in the form: u'organization-<organization_id>' (i.e. if the organization id is 123, then the generated repository name will be u'organization-123). |
79 | */ |
80 | repository?: string |
81 | |
82 | * The name of the commit author. |
83 | */ |
84 | author_name?: string |
85 | |
86 | * The email of the commit author. The commit author's email is required to enable the suggested assignee feature. |
87 | */ |
88 | author_email?: string |
89 | |
90 | * The commit timestamp is used to sort the commits given. If a timestamp is not included, the commits will remain sorted in the order given. |
91 | */ |
92 | timestamp?: string |
93 | |
94 | * The commit message. |
95 | */ |
96 | message?: string |
97 | |
98 | * The commit ID (the commit SHA). |
99 | */ |
100 | id?: string |
101 | [k: string]: unknown |
102 | }[] |
103 | |
104 | * An optional way to indicate the start and end commits for each repository included in a release. Head commits must include parameters `repository` and `commit` (the HEAD sha). They can optionally include `previousCommit` (the sha of the HEAD of the previous release), which should be specified if this is the first time you've sent commit data. `commit` may contain a range in the form of `previousCommit..commit`. |
105 | */ |
106 | refs?: { |
107 | |
108 | * The full name of the repository the commit belongs to. |
109 | */ |
110 | repository?: string |
111 | |
112 | * The current release's commit. |
113 | */ |
114 | commit?: string |
115 | |
116 | * The previous release's commit. |
117 | */ |
118 | previousCommit?: string |
119 | [k: string]: unknown |
120 | }[] |
121 | [k: string]: unknown |
122 | } |
123 |
|