From 18e86906969ee403ed32108958365c6fd9301e63 Mon Sep 17 00:00:00 2001 From: tanner Date: Tue, 3 Mar 2020 13:39:03 -0600 Subject: [PATCH] publish to bintray again --- .github/workflows/publish.yml | 5 ++- build.gradle | 31 +++++-------- gradle.properties | 2 +- publishing.gradle | 82 +++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 22 deletions(-) create mode 100644 publishing.gradle diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fb76f1e..447f799 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,8 @@ jobs: java-version: 1.8 - name: Publish to Github registry env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BINTRAY_USER: ${{ secrets.BINTRAY_USER }} + BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} run: | # Strip git ref prefix from version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') @@ -25,4 +26,4 @@ jobs: # Strip "v" prefix from tag name [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - ./gradlew -Pversion=$VERSION publish + ./gradlew -Pversion=$VERSION bintrayUpload diff --git a/build.gradle b/build.gradle index 16a25bf..a1688f7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,17 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+' + } +} + plugins { id 'java-library' - id("maven-publish") id 'org.jetbrains.kotlin.jvm' version '1.3.41' + id 'maven-publish' + id "com.jfrog.bintray" version "1.8.4" } java { @@ -16,6 +26,7 @@ repositories { apply plugin: 'kotlin' apply plugin: 'idea' +apply from: 'publishing.gradle' dependencies { platform('org.jetbrains.kotlin:kotlin-bom') @@ -64,21 +75,3 @@ artifacts { sourcesJar } -publishing { - repositories { - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/dtanner/env-override") - credentials { - username = project.findProperty("gpr.user") ?: "dtanner" - password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") - } - } - } - publications { - gpr(MavenPublication) { - from(components.kotlin) - } - } -} - diff --git a/gradle.properties b/gradle.properties index 5cf5115..bce4cad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ project_description=Override an object with environment values project_url=https://github.com/dtanner/env-override project_scm=https://github.com/dtanner/env-override.git project_issues=https://github.com/dtanner/env-override/issues -project_bintray_repo=github +project_bintray_repo=maven diff --git a/publishing.gradle b/publishing.gradle new file mode 100644 index 0000000..b455627 --- /dev/null +++ b/publishing.gradle @@ -0,0 +1,82 @@ +import java.text.SimpleDateFormat + +Date buildTimeAndDate = new Date() +ext { + buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) + buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) +} + +jar { + manifest { + attributes( + 'Built-By': System.properties['user.name'], + 'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")", + 'Build-Date': project.buildDate, + 'Build-Time': project.buildTime, + 'Specification-Title': project.name, + 'Specification-Version': project.version, + 'Implementation-Title': project.name, + 'Implementation-Version': project.version, + ) + } +} + +def pomConfig = { + name project.name + description project.project_description + url project.project_url + inceptionYear '2017' + licenses { + license([:]) { + name 'MIT' + distribution 'repo' + } + } + scm { + url project.project_scm + } + developers { + [ + dtanner : 'Dan Tanner' + ].each { devId, devName -> + developer { + id devId + name devName + roles { + role 'Developer' + } + } + } + } +} + +publishing { + publications { + mavenCustom(MavenPublication) { + from components.kotlin + pom.withXml { + asNode().children().last() + pomConfig + } + } + } +} + +bintray { + user = System.getenv('BINTRAY_USER') + key = System.getenv('BINTRAY_KEY') + publications = ['mavenCustom'] + publish = true + pkg { + repo = project.project_bintray_repo + // userOrg = project.project_bintray_org + name = project.name + desc = project.project_description + licenses = ['MIT'] + labels = [] + websiteUrl = project.project_url + issueTrackerUrl = project.project_issues + vcsUrl = project.project_scm + publicDownloadNumbers = true + } +} +