From 73debd94b0415d93b18dc577c4b5d4691895e675 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Mon, 28 Oct 2024 09:04:03 -0700 Subject: [PATCH 1/2] auto pull version for build.gradle to match CI version --- build.gradle | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b45f1fa6..ae185082 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,33 @@ spotless { } } +ext { + def fetchLatestVersion = { + def url = 'https://api.github.com/repos/temporalio/sdk-java/releases/latest' + def connection = new URL(url).openConnection() + connection.setRequestProperty("Accept", "application/vnd.github.v3+json") + + // Read the entire response as a single string + def response = connection.inputStream.text + + // Use a regular expression to find the tag_name value + def matcher = (response =~ /"tag_name"\s*:\s*"(.*?)"/) + if (matcher.find()) { + return matcher.group(1).replaceFirst("^v", "") + } else { + throw new Exception("Failed to extract tag_name from GitHub response") + } + } + + // Default fallback version in case fetching the latest version fails + latestSdkVersion = "1.0.0" + try { + latestSdkVersion = fetchLatestVersion() + } catch (Exception e) { + println "Failed to fetch latest SDK version; using fallback: ${latestSdkVersion}" + } +} + dependencies { implementation 'ch.qos.logback:logback-classic:1.2.9' @@ -32,7 +59,7 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.9' implementation 'com.jayway.jsonpath:json-path:2.6.0' implementation 'info.picocli:picocli:4.6.2' - implementation 'io.temporal:temporal-sdk:1.26.1' + implementation "io.temporal:temporal-sdk:${latestSdkVersion}" implementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' implementation 'org.reflections:reflections:0.10.2' } From b994e30e4cb3c727af46272c6d57d6a623a05933 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Mon, 28 Oct 2024 09:07:17 -0700 Subject: [PATCH 2/2] add print statement with version pulled --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ae185082..9d1437e8 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,9 @@ ext { // Use a regular expression to find the tag_name value def matcher = (response =~ /"tag_name"\s*:\s*"(.*?)"/) if (matcher.find()) { - return matcher.group(1).replaceFirst("^v", "") + def version = matcher.group(1).replaceFirst("^v", "") + println "Fetched latest SDK version: ${version}" + return version } else { throw new Exception("Failed to extract tag_name from GitHub response") }