diff --git a/build.gradle b/build.gradle index 1edf918..c628ecf 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" + classpath "com.github.breadmoirai:github-release:$github_release_plugin_version" } } diff --git a/changelog_parser.sh b/changelog_parser.sh new file mode 100644 index 0000000..9dd39e6 --- /dev/null +++ b/changelog_parser.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +function parse() { + version="$1" + + while IFS= read -r line && [ -z "`echo "$line" | grep -e "^#\+ $version"`" ] + do + : # do nothing + done + + while IFS= read -r line && [ -z "`echo "$line" | grep -e "^#\+"`" ] + do + echo "$line" + done +} + +version="$1" +file="$2" + +if [ -n "$file" ]; then + parse "$version" < "$file" +else + parse "$version" +fi diff --git a/github_release.gradle b/github_release.gradle new file mode 100644 index 0000000..30bf97d --- /dev/null +++ b/github_release.gradle @@ -0,0 +1,30 @@ +private String getCurrentVersionChangelog() { + OutputStream changelogDataOS = new ByteArrayOutputStream() + exec { + commandLine 'chmod', "+x", './changelog_parser.sh' + } + exec { + standardOutput = changelogDataOS + commandLine './changelog_parser.sh', "${project.version}", 'CHANGELOG.md' + } + + return changelogDataOS.toString().trim() +} + +if (new File(projectDir, "secret.gradle").exists()) { + apply from: './secret.gradle' + apply plugin: "com.github.breadmoirai.github-release" + + githubRelease { + token "${project.property('GITHUB_RELEASE_TOKEN')}" + + owner "InsanusMokrassar" + repo "SDI" + + tagName "${project.version}" + releaseName "${project.version}" + targetCommitish "${project.version}" + + body getCurrentVersionChangelog() + } +} diff --git a/gradle.properties b/gradle.properties index 84eaf39..2167b03 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ kotlin.code.style=official kotlin_version=1.3.72 kotlin_serialisation_runtime_version=0.20.0 -gradle_bintray_plugin_version=1.8.4 +gradle_bintray_plugin_version=1.8.5 +github_release_plugin_version=2.2.12 kotlin.incremental.multiplatform=true