From 17c6d4a889701ac81b3b8dfe2d8c49e8cfa1086e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 2 Oct 2020 20:45:16 +0600 Subject: [PATCH] add github release mechanism --- .gitignore | 2 ++ build.gradle | 2 ++ changelog_info_retriever | 27 +++++++++++++++++++++++++++ github_release.gradle | 27 +++++++++++++++++++++++++++ gradle.properties | 1 + 5 files changed, 59 insertions(+) create mode 100644 changelog_info_retriever create mode 100644 github_release.gradle diff --git a/.gitignore b/.gitignore index 5dc177e2715..2542547c968 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ settings.xml .gradle/ build/ out/ + +secret.gradle diff --git a/build.gradle b/build.gradle index 8be9aaaa6a0..4e79f30a28a 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" } } @@ -20,3 +21,4 @@ repositories { } apply from: "./extensions.gradle" +apply from: "./github.gradle" diff --git a/changelog_info_retriever b/changelog_info_retriever new file mode 100644 index 00000000000..00c4a482060 --- /dev/null +++ b/changelog_info_retriever @@ -0,0 +1,27 @@ +#!/bin/bash + +function parse() { + version=$1 + + read -r + while [ -z "`echo $REPLY | grep -e "^#\+ $version"`" ] + do + read -r + done + + read -r + while [ -z "`echo $REPLY | grep -e "^#\+"`" ] + do + echo "$REPLY" + read -r + 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 00000000000..60efbdcc981 --- /dev/null +++ b/github_release.gradle @@ -0,0 +1,27 @@ +private String getCurrentVersionChangelog() { + OutputStream changelogDataOS = new ByteArrayOutputStream() + exec { + standardOutput = changelogDataOS + commandLine './changelog_info_retriever', "$library_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 "MicroUtils" + + tagName "$library_version" + releaseName "$library_version" + targetCommitish "$library_version" + + body getCurrentVersionChangelog() + } +} diff --git a/gradle.properties b/gradle.properties index fad12944bb9..3eeb5c15579 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,7 @@ ktor_version=1.4.1 klockVersion=1.12.1 gradle_bintray_plugin_version=1.8.5 +github_release_plugin_version=2.2.12 uuidVersion=0.2.2