Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically pull latest version for build.gradle #556

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,43 @@ 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()) {
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")
}
}

// 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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is something that needs to be done at runtime of features instead of inside the build.gradle. IIUC every SDK language in features has a fixed default that can be overridden at runtime? Why override in this gradle instead of via CLI args of the features CLI?

implementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
implementation 'org.reflections:reflections:0.10.2'
}
Expand Down
Loading