Skip to content

Commit

Permalink
update publishing to github functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
akolomentsev committed Sep 29, 2017
1 parent d47f468 commit 980f5c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
19 changes: 18 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import org.gradle.kotlin.dsl.*
import org.gradle.plugin.use.*
import org.jetbrains.kotlin.gradle.tasks.*
import org.gradle.plugins.ide.idea.model.*

plugins {
kotlin("jvm", "1.1.50")
id("idea")
}

group = "com.satori"
version = "0.3.0-SNAPSHOT"

buildDir = file(".out")

idea {
project {
jdkName = JavaVersion.VERSION_1_8.toString()
languageLevel = IdeaLanguageLevel(JavaVersion.VERSION_1_8)
}
module {
inheritOutputDirs = false
outputDir = file("$buildDir/idea")
testOutputDir = file("$buildDir/idea-tests")
}
}


java.sourceSets["main"].java.srcDir("src")
java.sourceSets["main"].resources.srcDir("res")

Expand All @@ -30,11 +44,14 @@ compileTestKotlin.kotlinOptions {

repositories {
mavenCentral()
jcenter()
}

val jacksonVer = "2.9.0"

dependencies {
//compile("com.github.fge:uri-template:0.9")
compile("com.damnhandy:handy-uri-templates:2.1.6")
compile(kotlin("stdlib-jre8", "1.1.50"))
compile("com.fasterxml.jackson.core:jackson-core:$jacksonVer")
compile("com.fasterxml.jackson.core:jackson-databind:$jacksonVer")
Expand Down
22 changes: 6 additions & 16 deletions buildSrc/src/GitHubPublishReleaseTask.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.damnhandy.uri.template.*
import com.fasterxml.jackson.annotation.*
import org.gradle.api.*
import org.gradle.api.file.*
Expand Down Expand Up @@ -75,29 +76,18 @@ open class GitHubPublishReleaseTask : GitHubTask() {
println("publishing release to github... ")

val createdRelease = post("releases", body).get()!!

//val uploadUrl = createdRelease!!["assets_url"].asText()
val uploadUrl ="https://uploads.github.com/repos/satori-com/satori-composer/releases/${createdRelease["id"].asText()}/assets"
val uploadUrl =createdRelease!!["upload_url"].asText()

assets.forEach {
println("uploading asset '${it.name}'")
Files.newInputStream(it.toPath()).use { content->
val uri = UriTemplate.fromTemplate(uploadUrl)
.set("name", it.name)
.expand()
upload(
"$uploadUrl?name=${urlEncode(it.name)}",
"application/zip",
content
uri, "application/zip", content
)
}
//println("${URL("https://uploads.github.com/repos/satori-com/satori-composer/releases/7936971/assets{?name,label}")}")
/*parameters.put("name", "Arnold")
val builder = UriBuilder.fromPath(template)
val output = builder.build(parameters)
parameters.put("name", "Arnold")
val builder = UriBuilder.fromPath(template)
val output = builder.build(parameters)*/
//POST https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name=foo.zip
}
}
}

0 comments on commit 980f5c6

Please sign in to comment.