diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-08-13 01:22:04 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-08-13 01:22:04 +0800 |
commit | 3dadfbdf338af0e72eefada7bbcb997b62a3798e (patch) | |
tree | 8b6e9730f20f8b8ab233bb5e02c631b3830a4922 /upload.sc | |
parent | 974dcbe09830785f202f54959ae5397e9084f7a0 (diff) | |
download | cask-3dadfbdf338af0e72eefada7bbcb997b62a3798e.tar.gz cask-3dadfbdf338af0e72eefada7bbcb997b62a3798e.tar.bz2 cask-3dadfbdf338af0e72eefada7bbcb997b62a3798e.zip |
cleanup root dir
Diffstat (limited to 'upload.sc')
-rw-r--r-- | upload.sc | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/upload.sc b/upload.sc deleted file mode 100644 index 6c47295..0000000 --- a/upload.sc +++ /dev/null @@ -1,52 +0,0 @@ -#!/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 - println("shorten shortUrl " + shortUrl) - shortUrl -} -@main -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 parsed = ujson.read(body) - - println(body) - - val snapshotReleaseId = parsed("id").num.toInt - - - val uploadUrl = - 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 - - println(res.body) - val longUrl = ujson.read(res.body)("browser_download_url").str.toString - - println("Long Url " + longUrl) - - val shortUrl = shorten(longUrl) - - println("Short Url " + shortUrl) - shortUrl -} |