Skip to content

Commit 7c069c1

Browse files
authored
Adds Gradle configuration to publish over ossrh to maven central (#54)
* Adds pom metadata for publishing to maven central via ossrh according to https://central.sonatype.org/pages/ossrh-guide.html * Configures ossrh repos for publishing and signing capabilities * Removes snapshot releases an adds archivesBaseName * Adds release workflow yaml and changes build.gradle accordingly * workflow now uses gardlew as it should * Fixes syntax error * Fixes syntax error (now for real) * Prepares publishing on main
1 parent 684cac8 commit 7c069c1

3 files changed

Lines changed: 97 additions & 17 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v2
1010
- name: Set up JDK 1.8
1111
uses: actions/setup-java@v1
1212
with:

.github/workflows/pub.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Maven publishing
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v[1-9]+.[0-9]+.[0-9]+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up JDK 1.8
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 1.8
18+
- name: Publish to the Maven Central Repository
19+
run: ./gradlew publish -PcheckoutIfCloned -Prelease
20+
env:
21+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
22+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
23+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
24+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}

build.gradle

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
plugins {
2-
// Apply the java-library plugin to add support for Java Library
32
id 'java-library'
43
id 'maven-publish'
4+
id 'signing'
55
}
66

77
group = 'org.cryptimeleon'
8-
version = '1.0.0' + (Boolean.valueOf(System.getProperty("disablesnapshot")) ? "" : "-SNAPSHOT")
8+
archivesBaseName = project.name
9+
boolean isRelease = project.hasProperty("release")
10+
version = '1.0.0' + (isRelease ? "" : "-SNAPSHOT")
911

10-
description = """"""
12+
description = 'The Math library provides the mathematical foundation for the other Cryptimeleon libraries. ' +
13+
'It provides basics such as mathematical groups, rings and fields, e.g. Z_n , ' +
14+
'as well as implementations of cryptographic pairings.'
1115

1216
sourceCompatibility = 1.8
1317
targetCompatibility = 1.8
@@ -18,12 +22,9 @@ tasks.withType(JavaCompile) {
1822

1923

2024
repositories {
21-
jcenter()
22-
mavenCentral()
2325
mavenLocal()
24-
maven { url "https://nexus.cs.upb.de/repository/sfb901-libs/" }
25-
maven { url "https://nexus.cs.upb.de/repository/sfb901-releases/" }
26-
maven { url "https://nexus.cs.upb.de/repository/sfb901-snapshots/" }
26+
mavenCentral()
27+
jcenter()
2728
}
2829

2930
dependencies {
@@ -94,27 +95,82 @@ java {
9495
registerFeature("tests") {
9596
usingSourceSet(sourceSets.test)
9697
}
98+
withJavadocJar()
99+
withSourcesJar()
97100
}
98101

102+
99103
publishing {
100104
publications {
101105
mavenJava(MavenPublication) {
102106
from components.java
103-
artifact sourcesJar
104-
artifact javadocJar
107+
versionMapping {
108+
usage('java-api') {
109+
fromResolutionOf('runtimeClasspath')
110+
}
111+
usage('java-runtime') {
112+
fromResolutionResult()
113+
}
114+
}
115+
artifacts {
116+
archives javadocJar, sourcesJar
117+
}
118+
119+
pom {
120+
name = 'Math'
121+
url = 'https://cryptimeleon.org'
122+
licenses {
123+
license {
124+
name = 'The Apache License, Version 2.0'
125+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
126+
}
127+
}
128+
developers {
129+
developer {
130+
id = 'jbobolz'
131+
name = 'Jan Bobolz'
132+
email = 'mail@jan-bobolz.de'
133+
organization = 'Paderborn University'
134+
}
135+
developer {
136+
id = 'feidens'
137+
name = 'Fabian Eidens'
138+
email = 'fabianeidens@gmail.com'
139+
organization = 'Paderborn University'
140+
url = 'https://feidens.github.io/'
141+
}
142+
developer {
143+
id = 'rheitjoh'
144+
name = 'Raphael Heitjohann'
145+
email = 'rheitjoh@mail.uni-paderborn.de'
146+
organization = 'Paderborn University'
147+
}
148+
}
149+
scm {
150+
connection = 'scm:git:git://github.com/cryptimeleon/math.git'
151+
developerConnection = 'scm:git:https://github.com/cryptimeleon/math.git'
152+
url = 'https://github.com/cryptimeleon/math/'
153+
}
154+
}
105155
}
106156
}
107-
108157
repositories {
109158
maven {
110159
credentials {
111-
username = System.getProperty('nexus.user')
112-
password = System.getProperty('nexus.key')
160+
username = System.getenv("OSSRH_USERNAME")
161+
password = System.getenv("OSSRH_TOKEN")
113162
}
114-
def releasesRepoUrl = "https://nexus.cs.upb.de/repository/sfb901-releases/"
115-
def snapshotsRepoUrl = "https://nexus.cs.upb.de/repository/sfb901-snapshots/"
116-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
163+
name = 'OSSRH'
164+
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
165+
url = version.endsWith('SNAPSHOT') ? '' : releasesRepoUrl
117166
}
118167
}
119168
}
120169

170+
signing {
171+
required(project.hasProperty("release"))
172+
def signingKey = findProperty("signingKey")
173+
def signingPassword = findProperty("signingPassword")
174+
useInMemoryPgpKeys(signingKey, signingPassword)
175+
sign publishing.publications.mavenJava
176+
}

0 commit comments

Comments
 (0)