Skip to content

Commit 0c98d34

Browse files
authored
Kpg/release logging (#256)
* Add release logs * More logging * check response * Prep v1.0.1 * Remove temp file
1 parent 38baa70 commit 0c98d34

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ org.gradle.jvmargs=-Xmx4g
1818
#RELEASE_SIGNING_ENABLED=false
1919

2020
GROUP=co.touchlab.kmmbridge
21-
VERSION_NAME=1.0.0
21+
VERSION_NAME=1.0.1
2222
VERSION_NAME_3x=0.3.7
2323

2424
POM_URL=https://github.com/touchlab/KMMBridge

kmmbridge/src/main/kotlin/co/touchlab/faktory/artifactmanager/GithubReleaseArtifactManager.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class GithubReleaseArtifactManager(
1818
project, repoName, releaseVersion
1919
)
2020

21+
project.logger.info("existingReleaseId: $existingReleaseId")
22+
2123
if (existingReleaseId != null && !useExistingRelease) {
2224
throw GradleException("Release for '$releaseVersion' exists. Set 'useExistingRelease = true' to update existing releases.")
2325
}
@@ -26,6 +28,8 @@ class GithubReleaseArtifactManager(
2628
project, repoName, releaseVersion, null
2729
)
2830

31+
project.logger.info("GitHub Release created with id: $idReply")
32+
2933
val fileName = artifactName(project, version, useExistingRelease)
3034

3135
val uploadUrl = GithubCalls.uploadZipFile(project, zipFilePath, repoName, idReply, fileName)

kmmbridge/src/main/kotlin/co/touchlab/faktory/internal/GithubCalls.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import okhttp3.Request
2020
import okhttp3.RequestBody
2121
import okhttp3.RequestBody.Companion.asRequestBody
2222
import okhttp3.RequestBody.Companion.toRequestBody
23+
import org.gradle.api.GradleException
2324
import org.gradle.api.Project
2425
import java.io.File
2526
import java.net.URLEncoder
@@ -42,7 +43,16 @@ object GithubCalls {
4243
.post(gson.toJson(createReleaseBody).toRequestBody("application/json".toMediaTypeOrNull()))
4344
.addHeader("Accept", "application/vnd.github+json").addHeader("Authorization", "Bearer $token").build()
4445

45-
return gson.fromJson(okHttpClient.newCall(createRequest).execute().body!!.string(), IdReply::class.java).id
46+
val response = okHttpClient.newCall(createRequest).execute()
47+
if (!response.isSuccessful) {
48+
if (response.code == 403) {
49+
throw GradleException("Failed to create GitHub Release. Check Workflow permissions. Write permissions required.")
50+
} else {
51+
throw GradleException("Failed to create GitHub Release. Response code ${response.code}")
52+
}
53+
}
54+
55+
return gson.fromJson(response.body!!.string(), IdReply::class.java).id
4656
}
4757

4858
fun uploadZipFile(project: Project, zipFilePath: File, repo: String, releaseId: Int, fileName: String): String {

0 commit comments

Comments
 (0)