Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 1ea0a69

Browse files
authored
#461 Automatically release to Maven Central
Restore automatic release of FreeBuilder tags to Maven Central, which was lost when Bintray went offline.
2 parents 460ca58 + 3c764ee commit 1ea0a69

File tree

5 files changed

+58
-89
lines changed

5 files changed

+58
-89
lines changed

.github/workflows/publish.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
maven-central:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 11
14+
uses: actions/setup-java@v2
15+
with:
16+
java-version: '11'
17+
distribution: 'temurin'
18+
- name: Set $JAVA_11_HOME
19+
run: echo "JAVA_11_HOME=$JAVA_HOME" >> $GITHUB_ENV
20+
- name: Set up JDK 8
21+
uses: actions/setup-java@v2
22+
with:
23+
java-version: '8'
24+
distribution: 'temurin'
25+
- name: Set $JAVA_8_HOME
26+
run: echo "JAVA_8_HOME=$JAVA_HOME" >> $GITHUB_ENV
27+
- name: Validate gradle wrapper
28+
uses: gradle/wrapper-validation-action@v1
29+
- name: Run checks
30+
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
31+
with:
32+
arguments: check
33+
- name: Publish to Maven Central
34+
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
35+
with:
36+
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
37+
env:
38+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
39+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
40+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
41+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}

.travis.yml

-37
This file was deleted.

build.gradle

+6-8
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ buildscript {
1010
plugins {
1111
id 'checkstyle'
1212
id 'eclipse'
13+
id 'signing'
1314
id 'java'
1415
id 'java-library'
1516
id 'maven-publish'
1617
id 'com.github.johnrengelman.shadow' version '4.0.3'
17-
id 'com.jfrog.bintray' version '1.8.4'
18+
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
1819
}
1920

2021
apply from: "gradle/java-compatibility.gradle"
2122
apply from: "gradle/publication.gradle"
22-
apply from: "gradle/travis-keep-alive.gradle"
2323

2424
repositories {
2525
mavenCentral()
@@ -522,10 +522,8 @@ tasks.register("lambdaTest", Test) {
522522
group = 'org.inferred'
523523
archivesBaseName = 'freebuilder'
524524

525-
if (System.env.TRAVIS_TAG != null && !System.env.TRAVIS_TAG.isEmpty()) {
526-
version = System.env.TRAVIS_TAG.replaceAll('^v','')
527-
} else if (System.env.TRAVIS_BRANCH != null && !System.env.TRAVIS_BRANCH.isEmpty()) {
528-
version = System.env.TRAVIS_BRANCH + '-alpha.' + System.env.TRAVIS_BUILD_NUMBER
525+
if (System.env.GITHUB_REF_TYPE == 'tag') {
526+
version = System.env.GITHUB_REF_NAME.replaceAll('^v','')
529527
} else {
530528
version = 'UNKNOWN-SNAPSHOT'
531529
}
@@ -546,9 +544,9 @@ pom {
546544

547545
developers {
548546
developer {
549-
id = 'chrisalice'
547+
id = 'alicederyn'
550548
name = 'Alice Purcell'
551-
email = 'Alice.Purcell.39@gmail.com'
549+
email = 'alicederyn@gmail.com'
552550
timezone = 'Europe/London'
553551
}
554552
}

gradle/publication.gradle

+11-32
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
if (System.env.TRAVIS_TAG != null && !System.env.TRAVIS_TAG.isEmpty()) {
2-
version = System.env.TRAVIS_TAG.replaceAll('^v','')
3-
} else if (System.env.TRAVIS_BRANCH != null && !System.env.TRAVIS_BRANCH.isEmpty()) {
4-
version = System.env.TRAVIS_BRANCH + '-alpha.' + System.env.TRAVIS_BUILD_NUMBER
5-
}
6-
71
class PomConvention {
82

93
class ProjectData {
@@ -134,6 +128,12 @@ artifacts {
134128
archives javadocJar
135129
}
136130

131+
nexusPublishing {
132+
repositories {
133+
sonatype()
134+
}
135+
}
136+
137137
afterEvaluate {
138138
group = pom.project.groupId
139139
archivesBaseName = pom.project.artifactId
@@ -162,31 +162,10 @@ afterEvaluate {
162162
}
163163
}
164164

165-
if (project.pom.scm.connection != null) {
166-
bintray {
167-
user = System.env.BINTRAY_USER
168-
key = System.env.BINTRAY_KEY
169-
publications = ['JarPublication']
170-
publish = true
171-
pkg {
172-
name = project.pom.project.groupId + ':' + project.pom.project.artifactId
173-
repo = 'maven'
174-
userOrg = System.env.BINTRAY_ORG ?: System.env.BINTRAY_USER
175-
vcsUrl = project.pom.scm.connection.replaceAll('^scm:[^:]*:', '')
176-
licenses = [project.pom.project.license.shortName]
177-
version {
178-
name = project.version
179-
desc = "$project.archivesBaseName $project.version"
180-
released = new Date()
181-
vcsTag = System.env.TRAVIS_TAG
182-
if (System.env.OSS_USER != null) {
183-
mavenCentralSync {
184-
user = System.env.OSS_USER
185-
password = System.env.OSS_PASSWORD
186-
}
187-
}
188-
}
189-
}
190-
}
165+
signing {
166+
def signingKey = findProperty('signingKey')
167+
def signingPassword = findProperty('signingPassword')
168+
useInMemoryPgpKeys(signingKey, signingPassword)
169+
sign publishing.publications.JarPublication
191170
}
192171
}

gradle/travis-keep-alive.gradle

-12
This file was deleted.

0 commit comments

Comments
 (0)