@@ -139,42 +139,43 @@ if (isAndroid) {
139139 val repo = properties[" github_repo" ]
140140 val token = properties[" github_api_key" ]
141141
142- if (repo != null && repo is String && token != null && token is String ) {
143- tasks.create(" createGithubRelease" ) {
144- if (workingTreeClean && allCommitsPushed) {
145- dependsOn(" assembleRelease" )
142+ tasks.create(" createGithubRelease" ) {
143+ check(repo != null && repo is String ) { " github_repo not provided in local.properties" }
144+ check(token != null && token is String ) { " github_api_key not provided in local.properties" }
145+
146+ if (workingTreeClean && allCommitsPushed) {
147+ dependsOn(" assembleRelease" )
148+ }
149+
150+ doFirst {
151+ check(workingTreeClean) { " Commit all changes before creating release" }
152+ check(allCommitsPushed) { " Push to remote before creating release" }
153+
154+ val packageRelease = project.tasks.getByName<DefaultTask >(" packageRelease" )
155+
156+ val outputs = packageRelease.outputs.files
157+ val apks = outputs.filter { it.isDirectory }.flatMap { it.listFiles { file -> file.extension == " apk" }!! .toList() }
158+
159+ val github = GitHub .connectUsingOAuth(token)
160+ val repository = github.getRepository(repo)
161+
162+ val tagName = " ${android.namespace} -v$commitCount "
163+ val name = " ${project.name} -v$commitCount "
164+
165+ if (repository.getReleaseByTagName(tagName) != null ) {
166+ println (" Release $name already exists" )
167+ return @doFirst
146168 }
147169
148- doFirst {
149- check(workingTreeClean) { " Commit all changes before creating release." }
150- check(allCommitsPushed) { " Sync remote before creating release." }
151-
152- val packageRelease = project.tasks.getByName<DefaultTask >(" packageRelease" )
153-
154- val outputs = packageRelease.outputs.files
155- val apks = outputs.filter { it.isDirectory }.flatMap { it.listFiles { file -> file.extension == " apk" }!! .toList() }
156-
157- val github = GitHub .connectUsingOAuth(token)
158- val repository = github.getRepository(repo)
159-
160- val tagName = " ${android.namespace} -v$commitCount "
161- val name = " ${project.name} -v$commitCount "
162-
163- if (repository.getReleaseByTagName(tagName) != null ) {
164- println (" Release $name already exists" )
165- return @doFirst
166- }
167-
168- val release = repository.createRelease(tagName).name(name).draft(true ).makeLatest(GHReleaseBuilder .MakeLatest .FALSE ).create()
169-
170- apks.forEach {
171- release.uploadAsset(" ${project.name} -v$commitCount .apk" , it.inputStream(), " application/vnd.android.package-archive" )
172- }
173-
174- println (" Created release ${release.name} : ${release.htmlUrl} " )
170+ val release = repository.createRelease(tagName).name(name).draft(true ).makeLatest(GHReleaseBuilder .MakeLatest .FALSE ).create()
171+
172+ apks.forEach {
173+ release.uploadAsset(" ${project.name} -v$commitCount .apk" , it.inputStream(), " application/vnd.android.package-archive" )
175174 }
175+
176+ println (" Created release ${release.name} : ${release.htmlUrl} " )
176177 }
177- } else println ( " missing github_repo or github_api_key " )
178+ }
178179
179180 android.packagingOptions {
180181 resources.excludes + = listOf (
0 commit comments