Skip to content

Commit

Permalink
auto pull version for build.gradle to match CI version
Browse files Browse the repository at this point in the history
  • Loading branch information
yuandrew committed Oct 28, 2024
1 parent d23eb64 commit 73debd9
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,41 @@ 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'
implementation 'com.google.guava:guava:31.0.1-jre'
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'
}
Expand Down

0 comments on commit 73debd9

Please sign in to comment.