Skip to content

Commit 7fe108b

Browse files
authored
Added Jreleaser (#174)
* Added Jreleaser
1 parent 683811a commit 7fe108b

File tree

2 files changed

+88
-92
lines changed

2 files changed

+88
-92
lines changed

.github/workflows/release.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ jobs:
2626
fetch-depth: 0
2727
- uses: ./.github/actions/setup
2828
- uses: ./.github/actions/configure-git
29-
- name: Release with Gradle
30-
run: ./gradlew clean release -Dorg.gradle.daemon=false --stacktrace -x test -x integrationTest
29+
- name: Release with JReleaser
30+
run: ./gradlew jreleaserFullRelease -Dorg.gradle.daemon=false --stacktrace -x test -x integrationTest
31+
env:
32+
RELEASE_BUILD: 'true'
33+
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
34+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
35+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
36+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

build.gradle

+80-90
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
id 'net.researchgate.release' version '3.0.0'
66
id 'io.codearte.nexus-staging' version '0.30.0'
77
id 'com.gradle.plugin-publish' version '0.21.0'
8+
id 'org.jreleaser' version '1.15.0'
89
}
910

1011
apply from: 'gradle/integration-test.gradle'
@@ -86,110 +87,99 @@ test {
8687
}
8788

8889
publishing {
89-
afterEvaluate {
90-
def pluginUrl = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
91-
92-
pluginBundle {
93-
website = pluginUrl
94-
vcsUrl = pluginUrl
95-
description = pluginDescription
96-
tags = ['sonatype', 'scan', 'dependencies', 'ossindex', 'iq server']
97-
System.setProperty('gradle.publish.key', System.getenv('GRADLE_PUBLISH_KEY') ?: '')
98-
System.setProperty('gradle.publish.secret', System.getenv('GRADLE_PUBLISH_SECRET') ?: '')
99-
}
100-
101-
release {
102-
// avoid infinite CircleCI builds triggered by release commits
103-
preCommitText = '[skip ci] '
104-
buildTasks = ['assemble']
105-
}
106-
107-
def sonatypeUsername = System.getenv('SONATYPE_USERNAME')
108-
def sonatypePassword = System.getenv('SONATYPE_PASSWORD')
109-
110-
def serverUrlBase = 'https://repository.sonatype.org:443/service/local/'
111-
112-
repositories {
113-
maven {
114-
name = 'rso'
115-
url = serverUrlBase + 'staging/deploy/maven2/'
116-
credentials {
117-
username = sonatypeUsername
118-
password = sonatypePassword
90+
publications {
91+
maven(MavenPublication) {
92+
from components.java
93+
groupId = 'org.sonatype.gradle.plugins'
94+
artifactId = project.name
95+
version = project.version.toString()
96+
97+
pom {
98+
name = project.name
99+
description = pluginDescription
100+
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
101+
organization {
102+
name = 'Sonatype'
103+
url = 'https://www.sonatype.com'
119104
}
120-
}
121-
}
122-
123-
nexusStaging {
124-
serverUrl = serverUrlBase
125-
stagingProfileId = '97306992c3c7ca'
126-
username = sonatypeUsername
127-
password = sonatypePassword
128-
numberOfRetries = 40
129-
delayBetweenRetriesInMillis = 5000
130-
}
131-
132-
publications {
133-
withType(MavenPublication) {
134-
pom {
135-
name = project.name
136-
description = pluginDescription
137-
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
138-
organization {
139-
name = 'Sonatype'
140-
url = 'https://www.sonatype.org'
141-
}
142-
issueManagement {
143-
system = 'GitHub'
144-
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin/issues'
145-
}
146-
licenses {
147-
license {
148-
name = 'The Apache Software License, Version 2.0'
149-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
150-
distribution = 'repo'
151-
}
105+
issueManagement {
106+
system = 'GitHub'
107+
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin/issues'
108+
}
109+
licenses {
110+
license {
111+
name = 'The Apache Software License, Version 2.0'
112+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
113+
distribution = 'repo'
152114
}
153-
scm {
154-
connection = 'scm:git:git://github.com/sonatype-nexus-community/scan-gradle-plugin.git'
155-
developerConnection = 'scm:git:ssh://[email protected]:sonatype-nexus-community/scan-gradle-plugin.git'
156-
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
115+
}
116+
scm {
117+
connection = 'scm:git:git://github.com/sonatype-nexus-community/scan-gradle-plugin.git'
118+
developerConnection = 'scm:git:ssh://[email protected]:sonatype-nexus-community/scan-gradle-plugin.git'
119+
url = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
120+
}
121+
developers {
122+
developer {
123+
name = 'Guillermo Varela'
157124
}
158-
developers {
159-
developer {
160-
name = 'Guillermo Varela'
161-
}
162-
developer {
163-
name = 'Usman Shaikh'
164-
}
125+
developer {
126+
name = 'Usman Shaikh'
165127
}
166128
}
167-
168-
artifactId = project.name
169129
}
170130
}
131+
}
132+
repositories {
133+
maven {
134+
url = layout.buildDirectory.dir('staging-deploy')
135+
}
136+
}
137+
}
171138

172-
// configure signing if performing release
173-
if ('do-release' == System.getenv('CIRCLE_JOB')) {
174-
signing {
175-
def final encodedKey = System.getenv('SECRING_GPG_ASC_BASE64')
176-
def final signingKey = new String(encodedKey.decodeBase64())
177-
178-
allprojects {
179-
println 'setup gpg signing with in-memory key'
180-
useInMemoryPgpKeys(
181-
signingKey,
182-
System.getenv('GPG_PASSPHRASE')
183-
)
184-
}
139+
// Plugin publishing configuration
140+
def pluginUrl = 'https://github.com/sonatype-nexus-community/scan-gradle-plugin'
141+
pluginBundle {
142+
website = pluginUrl
143+
vcsUrl = pluginUrl
144+
description = pluginDescription
145+
tags = ['sonatype', 'scan', 'dependencies', 'ossindex', 'iq server']
146+
System.setProperty('gradle.publish.key', System.getenv('GRADLE_PUBLISH_KEY') ?: '')
147+
System.setProperty('gradle.publish.secret', System.getenv('GRADLE_PUBLISH_SECRET') ?: '')
148+
}
185149

186-
sign publishing.publications.pluginMaven
187-
sign publishing.publications.scanPluginMarkerMaven
150+
jreleaser {
151+
signing {
152+
active = 'ALWAYS'
153+
armored = true
154+
}
155+
deploy {
156+
maven {
157+
mavenCentral {
158+
sonatype {
159+
active = 'ALWAYS'
160+
url = 'https://central.sonatype.com/api/v1/publisher'
161+
stagingRepository('build/staging-deploy')
162+
}
188163
}
189164
}
190165
}
191166
}
192167

168+
if (System.getenv('RELEASE_BUILD') == 'true') {
169+
signing {
170+
def final encodedKey = System.getenv('GPG_SIGNING_KEY')
171+
def final signingKey = new String(encodedKey.decodeBase64())
172+
allprojects {
173+
println 'setup gpg signing with in-memory key'
174+
useInMemoryPgpKeys(
175+
signingKey,
176+
System.getenv('GPG_PASSPHRASE')
177+
)
178+
}
179+
sign publishing.publications.maven
180+
}
181+
}
182+
193183
afterReleaseBuild.dependsOn publish
194184
publish.finalizedBy closeAndReleaseRepository
195185
publish.finalizedBy publishPlugins

0 commit comments

Comments
 (0)