Permalink to latest version of briefcase

Since move to github, can't automatically update ODK briefcase using permalink

Mac OS / PC Windows / Ubuntu

Github seems to have permissions issues on downloading files automatically. I'd like to be able to provide software like R with a permalink to update briefcase J in background

i.e. this does work (in R) but is version specific.

download.file(url = "https://github.com/opendatakit/briefcase/releases/download/v1.10.1/ODK-Briefcase-v1.10.1.jar", destfile = paste( "./odkbriefcase.jar",sep = ""), method="curl", mode = "wb",extra="-L")

Please could you add a fixed link to the most recent version.

Thanks
Chrissy h

Hi @chrissyhroberts! https://github.com/opendatakit/briefcase/releases/latest goes to the latest release, but there's currently no easy way for maintainers to link to the latest binary.

Does R let you hit the latest link and parse the HTML for the /download/ link?

Hi, @chrissyhroberts!

This command should get you going on a Linux/Mac terminal: curl --silent "https://api.github.com/repos/opendatakit/briefcase/releases/latest" | grep "browser_download_url" | sed -E 's/.*"([^"]+)".*/\1/'

Thanks @yanokwa and @ggalmazor

I took Yaw's advice and parsed current versions from the html. Guillermo's version is what I had been doing but unfortunately not cross compatible between PC and Mac versions of R.

This solution works on both platforms as it uses R's built in download.file command. Code here is as a simple function that runs download either if the odk briefcase jar file is absent, or if the update flag is set to TRUE.

###########################################################################
#odk.update.briefcase function : Downloads the current version of the ODK Briefcase Jar file
###########################################################################
odk.update.briefcase<-function(update=FALSE)
{
if(update==TRUE|!file.exists("odkbriefcase.jar"))
{
message("Updating Briefcase")
# destfile = paste( "./odkbriefcase.jar",sep = ""), method="curl", mode = "wb",extra="-L")
download.file(url = "https://github.com/opendatakit/briefcase/releases/latest",destfile = "odkbriefcase.html")
a<-readLines("odkbriefcase.html")
a<-strsplit(a[grep(a,pattern = 'opendatakit/briefcase/releases/download/v')],split = c("briefcase|jar"))[[1]][[2]]
odk.briefcase.url<-paste("https://github.com/opendatakit/briefcase/",a,"jar",sep="")
unlink("odkbriefcase.html")
download.file(url = odk.briefcase.url,destfile = paste( "./odkbriefcase.jar",sep = ""), method="curl", mode = "wb",extra="-L")
}
else(message("Briefcase will NOT be updated"))
}

1 Like