summaryrefslogtreecommitdiff
path: root/ci/upload.sc
diff options
context:
space:
mode:
Diffstat (limited to 'ci/upload.sc')
-rw-r--r--ci/upload.sc38
1 files changed, 21 insertions, 17 deletions
diff --git a/ci/upload.sc b/ci/upload.sc
index 6c47295..783f768 100644
--- a/ci/upload.sc
+++ b/ci/upload.sc
@@ -1,15 +1,14 @@
#!/usr/bin/env amm
import ammonite.ops._
-import scalaj.http._
@main
def shorten(longUrl: String) = {
println("shorten longUrl " + longUrl)
- val shortUrl = Http("https://git.io")
- .postForm(Seq("url" -> longUrl))
- .asString
- .headers("Location")
- .head
+ val shortUrl = requests.post(
+ "https://git.io",
+ data = Seq("url" -> longUrl),
+ ).headers("location").head
+
println("shorten shortUrl " + shortUrl)
shortUrl
}
@@ -18,9 +17,10 @@ def apply(uploadedFile: Path,
tagName: String,
uploadName: String,
authKey: String): String = {
- val body = Http("https://api.github.com/repos/lihaoyi/cask/releases/tags/" + tagName)
- .header("Authorization", "token " + authKey)
- .asString.body
+ val body = requests.get(
+ s"https://api.github.com/repos/lihaoyi/cask/releases/tags/$tagName",
+ headers = Seq("Authorization" -> s"token $authKey")
+ ).text
val parsed = ujson.read(body)
@@ -33,15 +33,19 @@ def apply(uploadedFile: Path,
s"https://uploads.github.com/repos/lihaoyi/cask/releases/" +
s"$snapshotReleaseId/assets?name=$uploadName"
- val res = Http(uploadUrl)
- .header("Content-Type", "application/octet-stream")
- .header("Authorization", "token " + authKey)
- .timeout(connTimeoutMs = 5000, readTimeoutMs = 60000)
- .postData(read.bytes! uploadedFile)
- .asString
+ val res = requests.post(
+ uploadUrl,
+ data = read.bytes! uploadedFile,
+ headers = Seq(
+ "Content-Type" -> "application/octet-stream",
+ "Authorization" -> s"token $authKey"
+ ),
+ connectTimeout = 5000, readTimeout = 60000
+ )
+
- println(res.body)
- val longUrl = ujson.read(res.body)("browser_download_url").str.toString
+ println(res.text)
+ val longUrl = ujson.read(res.text)("browser_download_url").str.toString
println("Long Url " + longUrl)