From b47104227cf00f9ba38d1fadc8a114a03b71e48c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 7 Jun 2022 20:30:54 +0600 Subject: [PATCH] add publication workaround --- CHANGELOG.md | 3 ++ build.gradle | 3 +- changelog_parser.sh | 24 ++++++++++++ github_release.gradle | 30 +++++++++++++++ publish.gradle | 86 +++++++++++++++++++++++++++++++++++++++++++ publish.kpsb | 1 + 6 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md create mode 100755 changelog_parser.sh create mode 100644 github_release.gradle create mode 100644 publish.gradle create mode 100644 publish.kpsb diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2cc9210 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +## 0.0.1 diff --git a/build.gradle b/build.gradle index 6f8a775..b65051e 100644 --- a/build.gradle +++ b/build.gradle @@ -82,4 +82,5 @@ java { apply from: "defaultAndroidSettings.gradle" -// apply from: "./github_release.gradle" +apply from: "./github_release.gradle" +apply from: "./publish.gradle" diff --git a/changelog_parser.sh b/changelog_parser.sh new file mode 100755 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..4982278 --- /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 "KSLog" + + tagName "${project.version}" + releaseName "${project.version}" + targetCommitish "${project.version}" + + body getCurrentVersionChangelog() + } +} diff --git a/publish.gradle b/publish.gradle new file mode 100644 index 0000000..cf53271 --- /dev/null +++ b/publish.gradle @@ -0,0 +1,86 @@ +apply plugin: 'maven-publish' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "Simple logging library for kotlin" + name = "${project.name}" + url = "https://github.com/InsanusMokrassar/KSLog" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/KSLog.git[push=]https://github.com/InsanusMokrassar/KSLog.git" + url = "https://github.com/InsanusMokrassar/KSLog.git" + } + + developers { + + developer { + id = "Akkihi" + name = "Akkihi" + email = "akkihiguy@gmail.com" + } + + + developer { + id = "InsanusMokrassar" + name = "InsanusMokrassar" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "MIT License" + url = "https://opensource.org/licenses/MIT" + } + + } + } + repositories { + if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) { + maven { + name = "GithubPackages" + url = uri("https://maven.pkg.github.com/InsanusMokrassar/KSLog") + credentials { + username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') + password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') + } + } + } + if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } + } +} + +if (project.hasProperty("signing.gnupg.keyName")) { + apply plugin: 'signing' + + signing { + useGpgCmd() + + sign publishing.publications + } + + task signAll { + tasks.withType(Sign).forEach { + dependsOn(it) + } + } +} diff --git a/publish.kpsb b/publish.kpsb new file mode 100644 index 0000000..f90c37d --- /dev/null +++ b/publish.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"MIT","title":"MIT License","url":"https://opensource.org/licenses/MIT"}],"mavenConfig":{"name":"${project.name}","description":"Simple logging library for kotlin","url":"https://github.com/InsanusMokrassar/KSLog","vcsUrl":"https://github.com/InsanusMokrassar/KSLog.git","developers":[{"id":"Akkihi","name":"Akkihi","eMail":"akkihiguy@gmail.com"},{"id":"InsanusMokrassar","name":"InsanusMokrassar","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/KSLog"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}} \ No newline at end of file