From 40c58750dbb9a2c128f495634035758a6850105d Mon Sep 17 00:00:00 2001 From: Leonardo Colman Lopes Date: Fri, 16 Apr 2021 16:38:49 -0300 Subject: [PATCH] Add publishing to MavenCentral instead of jcenter Closes #19 --- .github/dependabot.yml | 6 ++ .github/release-drafter.yml | 29 ++++++ .github/workflows/build.yml | 14 +++ .github/workflows/release-drafter.yml | 14 +++ .github/workflows/release.yml | 27 ++++++ .travis.yml | 15 --- README.md | 9 +- build.gradle.kts | 112 ++++++++++++----------- gradle/wrapper/gradle-wrapper.properties | 2 +- upload-bintray.sh | 3 - 10 files changed, 150 insertions(+), 81 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml delete mode 100755 upload-bintray.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7f283b1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..ac78c23 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,29 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + ## Changes + $CHANGES \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a4c6326 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,14 @@ +name: Build +on: + pull_request: + paths-ignore: + - '*.md' + push: +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: check + run: ./gradlew check \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..3fb8ef3 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,14 @@ +name: Release Drafter + +on: + push: + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6be9b84 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: "Release Version" + required: true + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Publish to Maven Central + run: ./gradlew publish + env: + RELEASE_VERSION: ${{ github.event.inputs.version }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 686b5b3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: java - -sudo: false - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -cache: - directories: - - "$HOME/.gradle/caches/" - - "$HOME/.gradle/wrapper/" - - "$HOME/.m2/repository/" - -script: "./gradlew build --stacktrace" \ No newline at end of file diff --git a/README.md b/README.md index 6be6a77..9e853b9 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,8 @@ This library comes to the rescue of programmers dealing with fixed length files. ## Using with Gradle -This library is published to `Bintray jcenter`, so you'll need to configure that in your repositories: -```kotlin -repositories { - mavenCentral() - jcenter() -} -``` +Import it into your dependencies: -And then you can import it into your dependencies: ```kotlin dependencies { implementation("br.com.guiabolso:FixedLengthFileHandler:{version}") diff --git a/build.gradle.kts b/build.gradle.kts index 94f2acf..014edbd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,42 +1,29 @@ -import com.novoda.gradle.release.PublishExtension -import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -buildscript { - repositories { - mavenCentral() - jcenter() - } - - dependencies { - classpath("com.novoda:bintray-release:0.9.1") - } -} +import java.lang.System.getenv plugins { - kotlin("jvm") version "1.3.61" - + kotlin("jvm") version "1.4.31" `maven-publish` - id("org.jetbrains.dokka") version "0.9.17" - id("io.gitlab.arturbosch.detekt").version("1.1.1") + signing + id("io.gitlab.arturbosch.detekt").version("1.16.0") } -apply(plugin = "com.novoda.bintray-release") - group = "br.com.guiabolso" -version = "0.5.0" +version = getenv("RELEASE_VERSION") ?: "local" repositories { - mavenCentral() jcenter() + mavenCentral() +} + +repositories { + mavenCentral() } dependencies { // Kotlin - implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - // KotlinTest testImplementation("io.kotlintest:kotlintest-runner-junit5:3.4.2") } @@ -49,65 +36,82 @@ tasks.withType { useJUnitPlatform() } -val sourcesJar by tasks.registering(Jar::class) { - classifier = "sources" - from(sourceSets.getByName("main").allSource) +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } } -val javadocJar by tasks.registering(Jar::class) { - val javadoc = tasks["dokka"] as DokkaTask - javadoc.outputFormat = "javadoc" - javadoc.outputDirectory = "$buildDir/javadoc" - dependsOn(javadoc) - classifier = "javadoc" - from(javadoc.outputDirectory) +val sourcesJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets.getByName("main").allSource) } -detekt { - toolVersion = "1.1.1" - input = files("src/main/kotlin", "src/test/kotlin") +val javadoc = tasks.named("javadoc") +val javadocsJar by tasks.creating(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + description = "Assembles java doc to jar" + archiveClassifier.set("javadoc") + from(javadoc) } publishing { + + repositories { + maven { + url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = getenv("OSSRH_USERNAME") + password = getenv("OSSRH_PASSWORD") + } + } + } + publications { - + register("maven", MavenPublication::class) { from(components["java"]) artifact(sourcesJar.get()) - artifact(javadocJar.get()) - + artifact(javadocsJar) + pom { name.set("Fixed-Length-File-Handler") description.set("Fixed-Length-File-Handler") url.set("https://github.com/GuiaBolso/fixed-length-file-handler") - - + + scm { connection.set("scm:git:https://github.com/GuiaBolso/fixed-length-file-handler/") developerConnection.set("scm:git:https://github.com/GuiaBolso/") url.set("https://github.com/GuiaBolso/fixed-length-file-handler") } - + licenses { license { name.set("The Apache 2.0 License") url.set("https://opensource.org/licenses/Apache-2.0") } } + + developers { + developer { + id.set("Guiabolso") + name.set("Guiabolso") + } + } } } } } -configure { - artifactId = "fixed-length-file-handler" - autoPublish = true - desc = "Fixed Length File Handler" - groupId = "br.com.guiabolso" - userOrg = "gb-opensource" - setLicences("APACHE-2.0") - publishVersion = version.toString() - uploadName = "Fixed-Length-File-Handler" - website = "https://github.com/GuiaBolso/fixed-length-file-handler" - setPublications("maven") -} \ No newline at end of file +signing { + val signingKey: String? by project + val signingPassword: String? by project + + useGpgCmd() + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys(signingKey, signingPassword) + } + + sign((extensions.getByName("publishing") as PublishingExtension).publications) +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44e7c4d..442d913 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/upload-bintray.sh b/upload-bintray.sh deleted file mode 100755 index be5355a..0000000 --- a/upload-bintray.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./gradlew clean build bintrayUpload -PbintrayUser=${BINTRAY_USER} -PbintrayKey=${BINTRAY_KEY} -PdryRun=false