Skip to content

Commit 81f8bf5

Browse files
runningcodeclaude
andcommitted
refactor(docs): Refactor Gradle upload instructions into reusable components
- Create GradleUploadInstructions component to consolidate shared code - Create GradleFeatureConfig component for Gradle configuration snippets - Update build-distribution and size-analysis to use new components - Add missing android-metadata.png image to both includes and public directories - Register new components in mdxComponents.ts This reduces duplication across documentation files and makes it easier to maintain Gradle-related instructions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4c5b21f commit 81f8bf5

File tree

10 files changed

+277
-101
lines changed

10 files changed

+277
-101
lines changed

docs/platforms/android/build-distribution/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ description: Upload Android builds to Sentry for distribution to internal teams
1717

1818
### Uploading With Gradle
1919

20-
<Include name="size-analysis/upload-gradle" />
20+
<Include name="build-distribution/upload-gradle" />
2121

2222
### Uploading With the Sentry CLI
2323

32.9 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<GradleUploadInstructions feature="distribution" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```kotlin {filename:build.gradle.kts}
2+
sentry {
3+
distribution {
4+
enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
5+
}
6+
}
7+
```
8+
9+
```groovy {filename:build.gradle}
10+
sentry {
11+
distribution {
12+
enabled = providers.environmentVariable("GITHUB_ACTIONS").present
13+
}
14+
}
15+
```
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```kotlin {filename:build.gradle.kts}
2+
sentry {
3+
sizeAnalysis {
4+
enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
5+
}
6+
}
7+
```
8+
9+
```groovy {filename:build.gradle}
10+
sentry {
11+
sizeAnalysis {
12+
enabled = providers.environmentVariable("GITHUB_ACTIONS").present
13+
}
14+
}
15+
```
16+
Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1 @@
1-
The Gradle plugin automatically detects build metadata from your git repository. On GitHub Actions, all metadata is automatically detected. On other CI systems, you may need to manually set some values using the `vcsInfo` extension.
2-
3-
1. Configure the [Sentry Android Gradle plugin](/platforms/android/configuration/gradle/) with at least version `6.0.0-beta1`
4-
5-
2. Set the auth token as an environment variable to be used when running your release build.
6-
7-
<OrgAuthTokenNote />
8-
9-
```bash
10-
export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
11-
```
12-
13-
3. Enable uploading for size analysis for CI builds.
14-
15-
```kotlin {filename:build.gradle.kts}
16-
sentry {
17-
sizeAnalysis {
18-
enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
19-
}
20-
}
21-
```
22-
23-
```groovy {filename:build.gradle}
24-
sentry {
25-
sizeAnalysis {
26-
enabled = providers.environmentVariable("GITHUB_ACTIONS").present
27-
}
28-
}
29-
```
30-
31-
4. Invoke the following Gradle tasks to build your app and trigger the upload.
32-
33-
```aab {filename:aab}
34-
./gradlew bundleRelease
35-
```
36-
37-
```apk {filename:apk}
38-
./gradlew assembleRelease
39-
```
40-
41-
5. After an upload has successfully processed, confirm the metadata is correct in the Sentry UI
42-
43-
![Upload metadata =400x](./images/android-metadata.png)
44-
45-
### Overriding Metadata
46-
47-
The Gradle plugin automatically detects build metadata from your git repository. On GitHub Actions, all metadata is automatically detected. On other CI systems, you may need to manually set some values using the `vcsInfo` extension.
48-
49-
Configure overrides in your Gradle build configuration:
50-
51-
```kotlin {filename:build.gradle.kts}
52-
sentry {
53-
sizeAnalysis {
54-
enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
55-
}
56-
57-
vcsInfo {
58-
headSha.set("abc123")
59-
baseSha.set("def456")
60-
vcsProvider.set("github")
61-
headRepoName.set("organization/repository")
62-
baseRepoName.set("organization/repository")
63-
headRef.set("feature-branch")
64-
baseRef.set("main")
65-
prNumber.set(42)
66-
}
67-
}
68-
```
69-
70-
```groovy {filename:build.gradle}
71-
sentry {
72-
sizeAnalysis {
73-
enabled = providers.environmentVariable("GITHUB_ACTIONS").present
74-
}
75-
76-
vcsInfo {
77-
headSha = 'abc123'
78-
baseSha = 'def456'
79-
vcsProvider = 'github'
80-
headRepoName = 'organization/repository'
81-
baseRepoName = 'organization/repository'
82-
headRef = 'feature-branch'
83-
baseRef = 'main'
84-
prNumber = 42
85-
}
86-
}
87-
```
88-
89-
Available `vcsInfo` properties:
90-
91-
| Property | Type | Description |
92-
| -------------- | ------ | --------------------------------- |
93-
| `headSha` | String | Current commit SHA |
94-
| `baseSha` | String | Base commit SHA (for comparison) |
95-
| `vcsProvider` | String | VCS provider (e.g., "github") |
96-
| `headRepoName` | String | Repository name (org/repo format) |
97-
| `baseRepoName` | String | Base repository name |
98-
| `headRef` | String | Branch or tag name |
99-
| `baseRef` | String | Base branch name |
100-
| `prNumber` | Int | Pull request number |
1+
<GradleUploadInstructions feature="sizeAnalysis" />
32.9 KB
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {Fragment} from 'react';
2+
3+
import {CodeBlock} from './codeBlock';
4+
5+
type Props = {
6+
feature: string;
7+
};
8+
9+
export function GradleFeatureConfig({feature}: Props) {
10+
return (
11+
<Fragment>
12+
<CodeBlock language="kotlin" filename="build.gradle.kts">
13+
<pre>
14+
<code className="language-kotlin">{`sentry {
15+
${feature} {
16+
enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
17+
}
18+
}`}</code>
19+
</pre>
20+
</CodeBlock>
21+
22+
<CodeBlock language="groovy" filename="build.gradle">
23+
<pre>
24+
<code className="language-groovy">{`sentry {
25+
${feature} {
26+
enabled = providers.environmentVariable("GITHUB_ACTIONS").present
27+
}
28+
}`}</code>
29+
</pre>
30+
</CodeBlock>
31+
</Fragment>
32+
);
33+
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
import {Fragment} from 'react';
2+
3+
import {CodeBlock} from './codeBlock';
4+
import {GradleFeatureConfig} from './gradleFeatureConfig';
5+
import {OrgAuthTokenNote} from './orgAuthTokenNote';
6+
7+
type Props = {
8+
feature: 'sizeAnalysis' | 'distribution';
9+
};
10+
11+
export function GradleUploadInstructions({feature}: Props) {
12+
const featureName = feature === 'sizeAnalysis' ? 'size analysis' : 'distribution';
13+
14+
return (
15+
<Fragment>
16+
<p>
17+
The Gradle plugin automatically detects build metadata from your git
18+
repository. On GitHub Actions, all metadata is automatically detected. On other
19+
CI systems, you may need to manually set some values using the{' '}
20+
<code>vcsInfo</code> extension.
21+
</p>
22+
23+
<ol>
24+
<li>
25+
Configure the{' '}
26+
<a href="/platforms/android/configuration/gradle/">
27+
Sentry Android Gradle plugin
28+
</a>{' '}
29+
with at least version <code>6.0.0-beta1</code>
30+
</li>
31+
32+
<li>
33+
<p>
34+
Set the auth token as an environment variable to be used when running your
35+
release build.
36+
</p>
37+
<OrgAuthTokenNote />
38+
<CodeBlock language="bash">
39+
<pre>
40+
<code className="language-bash">{`export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___`}</code>
41+
</pre>
42+
</CodeBlock>
43+
</li>
44+
45+
<li>
46+
<p>Enable uploading for {featureName} for CI builds.</p>
47+
<GradleFeatureConfig feature={feature} />
48+
</li>
49+
50+
<li>
51+
<p>
52+
Invoke the following Gradle tasks to build your app and trigger the upload.
53+
</p>
54+
<CodeBlock language="bash" filename="aab">
55+
<pre>
56+
<code className="language-bash">{`./gradlew bundleRelease`}</code>
57+
</pre>
58+
</CodeBlock>
59+
<CodeBlock language="bash" filename="apk">
60+
<pre>
61+
<code className="language-bash">{`./gradlew assembleRelease`}</code>
62+
</pre>
63+
</CodeBlock>
64+
</li>
65+
66+
<li>
67+
<p>
68+
After an upload has successfully processed, confirm the metadata is correct
69+
in the Sentry UI
70+
</p>
71+
<img
72+
src="/platforms/android/build-distribution/images/android-metadata.png"
73+
alt="Upload metadata"
74+
style={{maxWidth: '400px'}}
75+
/>
76+
</li>
77+
</ol>
78+
79+
<h3>Overriding Metadata</h3>
80+
81+
<p>
82+
The Gradle plugin automatically detects build metadata from your git
83+
repository. On GitHub Actions, all metadata is automatically detected. On other
84+
CI systems, you may need to manually set some values using the{' '}
85+
<code>vcsInfo</code> extension.
86+
</p>
87+
88+
<p>Configure overrides in your Gradle build configuration:</p>
89+
90+
<CodeBlock language="kotlin" filename="build.gradle.kts">
91+
<pre>
92+
<code className="language-kotlin">{`sentry {
93+
${feature} {
94+
enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent
95+
}
96+
97+
vcsInfo {
98+
headSha.set("abc123")
99+
baseSha.set("def456")
100+
vcsProvider.set("github")
101+
headRepoName.set("organization/repository")
102+
baseRepoName.set("organization/repository")
103+
headRef.set("feature-branch")
104+
baseRef.set("main")
105+
prNumber.set(42)
106+
}
107+
}`}</code>
108+
</pre>
109+
</CodeBlock>
110+
111+
<CodeBlock language="groovy" filename="build.gradle">
112+
<pre>
113+
<code className="language-groovy">{`sentry {
114+
${feature} {
115+
enabled = providers.environmentVariable("GITHUB_ACTIONS").present
116+
}
117+
118+
vcsInfo {
119+
headSha = 'abc123'
120+
baseSha = 'def456'
121+
vcsProvider = 'github'
122+
headRepoName = 'organization/repository'
123+
baseRepoName = 'organization/repository'
124+
headRef = 'feature-branch'
125+
baseRef = 'main'
126+
prNumber = 42
127+
}
128+
}`}</code>
129+
</pre>
130+
</CodeBlock>
131+
132+
<p>
133+
Available <code>vcsInfo</code> properties:
134+
</p>
135+
136+
<table>
137+
<thead>
138+
<tr>
139+
<th>Property</th>
140+
<th>Type</th>
141+
<th>Description</th>
142+
</tr>
143+
</thead>
144+
<tbody>
145+
<tr>
146+
<td>
147+
<code>headSha</code>
148+
</td>
149+
<td>String</td>
150+
<td>Current commit SHA</td>
151+
</tr>
152+
<tr>
153+
<td>
154+
<code>baseSha</code>
155+
</td>
156+
<td>String</td>
157+
<td>Base commit SHA (for comparison)</td>
158+
</tr>
159+
<tr>
160+
<td>
161+
<code>vcsProvider</code>
162+
</td>
163+
<td>String</td>
164+
<td>VCS provider (e.g., "github")</td>
165+
</tr>
166+
<tr>
167+
<td>
168+
<code>headRepoName</code>
169+
</td>
170+
<td>String</td>
171+
<td>Repository name (org/repo format)</td>
172+
</tr>
173+
<tr>
174+
<td>
175+
<code>baseRepoName</code>
176+
</td>
177+
<td>String</td>
178+
<td>Base repository name</td>
179+
</tr>
180+
<tr>
181+
<td>
182+
<code>headRef</code>
183+
</td>
184+
<td>String</td>
185+
<td>Branch or tag name</td>
186+
</tr>
187+
<tr>
188+
<td>
189+
<code>baseRef</code>
190+
</td>
191+
<td>String</td>
192+
<td>Base branch name</td>
193+
</tr>
194+
<tr>
195+
<td>
196+
<code>prNumber</code>
197+
</td>
198+
<td>Int</td>
199+
<td>Pull request number</td>
200+
</tr>
201+
</tbody>
202+
</table>
203+
</Fragment>
204+
);
205+
}

0 commit comments

Comments
 (0)