Skip to content

Commit b3d9db1

Browse files
committed
[???] android build: Add suffix to versionName when testing Sentry.
Part of the process of building a Sentry-enabled release involves uploading the release's source map to sentry.io. Releases are distinguished only by the "release name", which for Android is the `versionName`. [Before being merged, if it ever is, this should be consolidated into the existing `defaultConfig` block. It is where it is only to simplify rebasing past a version bump.]
1 parent 2c6e3f1 commit b3d9db1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

android/app/build.gradle

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,35 @@ android {
129129
sourceCompatibility JavaVersion.VERSION_1_8
130130
targetCompatibility JavaVersion.VERSION_1_8
131131
}
132+
defaultConfig {
133+
// Marker for unsigned Sentry-enabled builds. Presumably, if you're
134+
// making such a build, you're really just testing Sentry and won't want
135+
// your development "releases" mixed in with real releases.
136+
//
137+
// The formatting of this affix is almost entirely arbitrary; it's
138+
// intended for humans to read, not machines. Adjust to taste -- but
139+
// please leave the username and date in, for the sake of other people
140+
// looking at Sentry events.
141+
if (project.hasProperty('sentry') && !project.hasProperty('signed')) {
142+
// use local git-config email, which is not necessarily `whoami`
143+
def username = ({ ->
144+
def proc = "git config --get user.email".execute()
145+
proc.waitFor()
146+
proc.in.text.takeWhile { it != '@'}
147+
})()
148+
if (username.isEmpty()) {
149+
throw new GradleException("Git user.email not configured?")
150+
}
151+
152+
def date = new Date().format('yyyy-MM-dd')
153+
154+
// Increment manually as desired. (Or replace with text, if you
155+
// prefer.)
156+
def revision = "001"
157+
158+
versionName += "-${username}-${date}.${revision}"
159+
}
160+
}
132161
signingConfigs {
133162
release {
134163
if (project.hasProperty('signed')) {

0 commit comments

Comments
 (0)