Skip to content

Commit 3c27c4e

Browse files
move from cloudsmith to maven-central
1 parent b54ca2a commit 3c27c4e

2 files changed

Lines changed: 69 additions & 61 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ jobs:
5050
needs: build
5151
environment: publish
5252
runs-on: ubuntu-24.04
53-
if: |
54-
github.ref == 'refs/heads/master' ||
55-
startsWith(github.ref, 'refs/heads/release-') ||
56-
startsWith(github.ref, 'refs/tags/')
53+
if: startsWith(github.ref, 'refs/tags/')
5754
steps:
5855
- name: Checkout
5956
uses: actions/checkout@v6
@@ -62,6 +59,9 @@ jobs:
6259
uses: ConsenSys/github-actions/java-setup-gradle@main
6360
- name: Publish
6461
env:
65-
CLOUDSMITH_USER: ${{ secrets.CLOUDSMITH_USER }}
66-
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
67-
run: ./gradlew --no-daemon --parallel publish
62+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }}
63+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }}
64+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
65+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
66+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
67+
run: ./gradlew --no-daemon --parallel publish jreleaserFullRelease

build.gradle

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,37 @@
22

33
plugins {
44
id 'java-library'
5+
id 'maven-publish'
56
id 'com.diffplug.spotless' version '6.25.0'
67
id 'com.github.ben-manes.versions' version '0.51.0'
78
id 'com.github.hierynomus.license' version '0.16.1'
89
id 'io.spring.dependency-management' version '1.1.5'
910
id 'net.ltgt.errorprone' version '4.0.1'
10-
id 'org.ajoberstar.grgit' version '5.2.2'
11+
id 'me.qoomon.git-versioning' version '6.4.4'
12+
id 'org.jreleaser' version '1.17.0'
1113
}
1214

13-
rootProject.version = calculatePublishVersion()
14-
def specificVersion = calculateVersion()
15+
version = 'UNKNOWN'
16+
17+
gitVersioning.apply {
18+
refs {
19+
tag('.+') {
20+
version = '${ref}'
21+
}
22+
branch('master') {
23+
version = 'develop'
24+
}
25+
branch('release-.+') {
26+
version = '${ref.slug}+develop'
27+
}
28+
branch('.+') {
29+
version = 'develop'
30+
}
31+
}
32+
rev {
33+
version = 'UNKNOWN'
34+
}
35+
}
1536

1637
apply from: "${rootDir}/gradle/versions.gradle"
1738
apply from: "${rootDir}/gradle/check-licenses.gradle"
@@ -135,7 +156,7 @@ tasks.withType(JavaCompile) {
135156
'Specification-Title': project.name,
136157
'Specification-Version': project.version,
137158
'Implementation-Title': project.name,
138-
'Implementation-Version': specificVersion
159+
'Implementation-Version': project.version
139160
)
140161
}
141162
}
@@ -158,9 +179,9 @@ javadoc {
158179
options.encoding = 'UTF-8'
159180
}
160181

161-
task sourcesJar(type: Jar, dependsOn: classes) {
162-
archiveClassifier = 'sources'
163-
from sourceSets.main.allSource
182+
java {
183+
withJavadocJar()
184+
withSourcesJar()
164185
}
165186

166187
task runTestDiscovery(type:JavaExec) {
@@ -169,41 +190,39 @@ task runTestDiscovery(type:JavaExec) {
169190
systemProperty "log4j.configurationFile", "log4j2-test-discovery.xml"
170191
}
171192

172-
def cloudsmithUser = project.hasProperty('cloudsmithUser') ? project.property('cloudsmithUser') : System.getenv('CLOUDSMITH_USER')
173-
def cloudsmithKey = project.hasProperty('cloudsmithApiKey') ? project.property('cloudsmithApiKey') : System.getenv('CLOUDSMITH_API_KEY')
174-
175-
apply plugin: 'maven-publish'
176193
publishing {
177194
repositories {
178195
maven {
179-
name = "cloudsmith"
180-
url = "https://api-g.cloudsmith.io/maven/consensys/maven/"
181-
credentials {
182-
username = cloudsmithUser
183-
password = cloudsmithKey
184-
}
196+
url = layout.buildDirectory.dir("staging-deploy")
185197
}
186198
}
187199
publications {
188200
mavenJava(MavenPublication) {
189201
groupId "tech.pegasys.discovery"
190202
version project.version
191203
from components.java
192-
artifact sourcesJar
193204

194205
versionMapping {
195206
usage('java-api') { fromResolutionOf('runtimeClasspath') }
196207
usage('java-runtime') { fromResolutionResult() }
197208
}
198209
pom {
199210
name = "${project.name}"
211+
description = "Java implementation of the Ethereum Node Discovery protocol"
200212
url = 'http://github.com/ConsenSys/discovery'
201213
licenses {
202214
license {
203215
name = 'The Apache License, Version 2.0'
204216
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
205217
}
206218
}
219+
developers {
220+
developer {
221+
id = "consensys"
222+
name = "Protocols Team"
223+
email = "devops@consensys.net"
224+
}
225+
}
207226
scm {
208227
connection = 'scm:git:git://github.com/ConsenSys/discovery.git'
209228
developerConnection = 'scm:git:ssh://github.com/ConsenSys/discovery.git'
@@ -214,44 +233,33 @@ publishing {
214233
}
215234
}
216235

217-
218-
// Calculate the version that this build would be published under (if it is published)
219-
// If this exact commit is tagged, use the tag
220-
// If this is on a release-* branch, use the most recent tag appended with +develop (e.g. 0.1.1-RC1+develop)
221-
// Otherwise, use develop
222-
def calculatePublishVersion() {
223-
if (!grgit) {
224-
return 'UNKNOWN'
225-
}
226-
def specificVersion = calculateVersion()
227-
def isReleaseBranch = grgit.branch.current().name.startsWith('release-')
228-
if (specificVersion.contains('+')) {
229-
return isReleaseBranch ? "${specificVersion.substring(0, specificVersion.indexOf('+'))}+develop" : "develop"
230-
}
231-
return specificVersion
232-
}
233-
234-
// Calculate the version that teku --version will report (among other places)
235-
// If this exact commit is tagged, use the tag
236-
// Otherwise use git describe --tags and replace the - after the tag with a +
237-
def calculateVersion() {
238-
if (!grgit) {
239-
return 'UNKNOWN'
236+
jreleaser {
237+
release {
238+
github {
239+
// Creating and tagging a release is done manually
240+
skipRelease = true
241+
skipTag = true
242+
// injecting a fake value to make JReleaser happy
243+
token = "foobar"
244+
}
240245
}
241-
String version = grgit.describe(tags: true)
242-
if (version == null) {
243-
return "UNKNOWN+g${grgit.head().abbreviatedId}"
246+
signing {
247+
active = 'ALWAYS'
248+
armored = true
244249
}
245-
def versionPattern = ~/^(?<lastVersion>.*)-(?<devVersion>[0-9]+-g[a-z0-9]+)$/
246-
def matcher = version =~ versionPattern
247-
if (matcher.find()) {
248-
return "${matcher.group("lastVersion")}+${matcher.group("devVersion")}"
250+
deploy {
251+
maven {
252+
mavenCentral {
253+
sonatype {
254+
active = 'ALWAYS'
255+
url = 'https://central.sonatype.com/api/v1/publisher'
256+
stagingRepository('build/staging-deploy')
257+
retryDelay = 15
258+
maxRetries = 100
259+
}
260+
}
261+
}
249262
}
250-
return version
251263
}
252264

253-
task printVersion() {
254-
doFirst {
255-
print "Specific version: ${specificVersion} Publish version: ${project.version}"
256-
}
257-
}
265+

0 commit comments

Comments
 (0)