Skip to content

Commit

Permalink
Merge pull request #164 from ajoberstar/central
Browse files Browse the repository at this point in the history
Publish to maven central
  • Loading branch information
ajoberstar authored Dec 6, 2021
2 parents f4a4608 + 5a4fd6c commit 2e04042
Show file tree
Hide file tree
Showing 30 changed files with 495 additions and 425 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Build
on:
push:
branches:
- main
branches: [main]
pull_request:
jobs:
check:
Expand All @@ -12,27 +11,28 @@ jobs:
java: [8, 11, 15]
fail-fast: false
steps:
- name: "Checkout repo"
uses: "actions/checkout@v2"
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Setup Java ${{ matrix.java }}"
uses: "actions/setup-java@v1"
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: ${{ matrix.java }}
- name: "Validate Gradle Wrapper"
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: "Cache Gradle wrapper"
uses: "actions/cache@v2"
- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/wrapper
~/.gradle/notifications
key: "gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}"
- name: "Cache Gradle dependencies"
uses: "actions/cache@v2"
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: "~/.gradle/caches"
key: "gradle-caches-${{ runner.os }}-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}"
- name: "Gradle check"
run: "./gradlew check --continue"
path: ~/.gradle/caches
key: gradle-caches-${{ runner.os }}-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}
- name: Gradle check
run: ./gradlew check --continue
65 changes: 34 additions & 31 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Release
on:
push:
tags:
- "*"
tags: ["*"]
jobs:
check:
runs-on: ubuntu-latest
Expand All @@ -11,57 +10,61 @@ jobs:
java: [8, 11, 15]
fail-fast: false
steps:
- name: "Checkout repo"
uses: "actions/checkout@v2"
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Setup Java ${{ matrix.java }}"
uses: "actions/setup-java@v1"
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: ${{ matrix.java }}
- name: "Validate Gradle Wrapper"
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: "Cache Gradle wrapper"
uses: "actions/cache@v2"
- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/wrapper
~/.gradle/notifications
key: "gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}"
- name: "Cache Gradle dependencies"
uses: "actions/cache@v2"
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: "~/.gradle/caches"
key: "gradle-caches-${{ runner.os }}-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}"
- name: "Gradle check"
run: "./gradlew check --continue"
path: ~/.gradle/caches
key: gradle-caches-${{ runner.os }}-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}
- name: Gradle check
run: ./gradlew check --continue
publish:
runs-on: ubuntu-latest
needs: check
steps:
- name: "Checkout repo"
uses: "actions/checkout@v2"
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Setup Java"
uses: "actions/setup-java@v1"
- name: Setup Java 8
uses: actions/setup-java@v1
with:
distribution: zulu
java-version: 8
- name: "Cache Gradle wrapper"
uses: "actions/cache@v2"
- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/wrapper
~/.gradle/notifications
key: "gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}"
- name: "Cache Gradle dependencies"
uses: "actions/cache@v2"
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: "~/.gradle/caches"
key: "gradle-caches-${{ runner.os }}-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}"
- name: "Gradle publish"
path: ~/.gradle/caches
key: gradle-caches-${{ runner.os }}-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}
- name: Gradle publish
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.PGP_SIGNING_PASSPHRASE }}
GRADLE_OPTS: "-Dorg.gradle.project.gradle.publish.key=${{ secrets.GRADLE_PLUGIN_KEY }} -Dorg.gradle.project.gradle.publish.secret=${{ secrets.GRADLE_PLUGIN_SECRET }}"
run: "./gradlew publish publishPlugins"
run: ./gradlew publishAllPublicationsToCentralReleasesRepository publishPlugins
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## Project News

### Newest versions are on Maven Central

As of 0.13.1, reckon is published to Maven Central and the Gradle Plugin Portal.

### Retirement of Bintray/JCenter

This project was previously uploaded to JCenter, which is being retired by JFrog on May 1st 2021.
Expand Down
43 changes: 0 additions & 43 deletions build.gradle

This file was deleted.

9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("org.ajoberstar.grgit")
id("org.ajoberstar.reckon")
}

reckon {
scopeFromProp()
stageFromProp("alpha", "beta", "rc", "final")
}
11 changes: 11 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.0.0")
}
91 changes: 91 additions & 0 deletions buildSrc/src/main/kotlin/java-library-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
plugins {
`java-library`
`maven-publish`
`signing`
id("locking-convention")
id("spotless-convention")
}

group = "org.ajoberstar.grgit"
description = "The Groovy way to use Git."

repositories {
mavenCentral()
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}

publishing {
repositories {
maven {
name = "CentralReleases"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}

maven {
name = "CentralSnapshots"
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}

publications {
create<MavenPublication>("main") {
from(components["java"])

versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}

pom {
name.set("Reckon")
description.set("Infer a project's version from your Git repository.")
url.set("https://github.com/ajoberstar/reckon")

developers {
developer {
name.set("Andrew Oberstar")
email.set("[email protected]")
}
}

licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0")
}
}

scm {
url.set("https://github.com/ajoberstar/reckon")
connection.set("scm:git:[email protected]:ajoberstar/reckon.git")
developerConnection.set("scm:git:ssh:[email protected]:ajoberstar/reckon.git")
}
}
}
}
}

signing {
setRequired(System.getenv("CI"))
val signingKey: String? by project
val signingPassphrase: String? by project
useInMemoryPgpKeys(signingKey, signingPassphrase)
sign(publishing.publications["main"])
}
28 changes: 28 additions & 0 deletions buildSrc/src/main/kotlin/locking-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
`java-base`
}

java {
sourceSets.configureEach {
val confNames = listOf(compileClasspathConfigurationName, runtimeClasspathConfigurationName)
confNames.forEach { confName ->
val conf = configurations.named(confName)
conf.resolutionStrategy.activateDependencyLocking()
}
}
}

tasks.register("lock") {
doFirst {
require(gradle.startParameter.isWriteDependencyLocks)
}
doLast {
sourceSets.configureEach {
val confNames = listOf(compileClasspathConfigurationName, runtimeClasspathConfigurationName)
confNames.forEach { confName ->
val conf = configurations.named(confName)
conf.resolve()
}
}
}
}
27 changes: 27 additions & 0 deletions buildSrc/src/main/kotlin/spotless-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
id("com.diffplug.spotless")
}

spotless {
plugins.withId("java") {
java {
importOrder("java", "javax", "")
removeUnusedImports()
eclipse().configFile(project.rootProject.file("gradle/eclipse-java-formatter.xml"))
}
}
plugins.withId("groovy") {
format("groovy") {
target("src/**/*.groovy")
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
format("gradle") {
target("**/*.gradle")
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
16 changes: 0 additions & 16 deletions gradle/bintray.gradle

This file was deleted.

Loading

0 comments on commit 2e04042

Please sign in to comment.