diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3ced3e6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 0.0.1 + +Inited :) diff --git a/bot/build.gradle b/bot/build.gradle index 0cfd5d3..954b20f 100644 --- a/bot/build.gradle +++ b/bot/build.gradle @@ -9,6 +9,7 @@ project.group="$group" project.version="$version" apply from: "publish.gradle" +apply from: "${rootProject.projectDir.path}${File.separator}github_release.gradle" dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_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..06d1d6e --- /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 "PlaguBot" + + tagName "${project.version}" + releaseName "${project.version}" + targetCommitish "${project.version}" + + body getCurrentVersionChangelog() + } +} diff --git a/plugin/build.gradle b/plugin/build.gradle index 4a95f1d..0ddbc1c 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -7,6 +7,7 @@ project.group="$group" project.version="$version" apply from: "publish.gradle" +apply from: "${rootProject.projectDir.path}${File.separator}github_release.gradle" dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"