Skip to content

Commit ea46fd3

Browse files
committed
build: move build and publish to mavencentral
1 parent 4e6f557 commit ea46fd3

File tree

7 files changed

+197
-151
lines changed

7 files changed

+197
-151
lines changed

.github/workflows/build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Run build and tests
5+
6+
on:
7+
push:
8+
branches:
9+
- '*'
10+
pull_request:
11+
branches: [ master ]
12+
13+
jobs:
14+
build:
15+
environment: CIRelease
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: 8
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- run: git fetch --all --tags
27+
28+
- name: Create .gradle dir
29+
run: mkdir -p $HOME/.gradle
30+
- name: Install gpg secret key
31+
env:
32+
SIGNINGFILE: ${{ secrets.SIGNINGFILE }}
33+
run: |
34+
cat <(echo -e "${{ secrets.SIGNINGFILE }}") | gpg --batch --import
35+
gpg --list-secret-keys --keyid-format LONG
36+
- name: Export gpg file
37+
env:
38+
SIGNINGKEYID: ${{ secrets.SIGNINGKEYID }}
39+
SIGNINGPASSWORD: ${{ secrets.SIGNINGPASSWORD }}
40+
run: |
41+
gpg --batch --passphrase="$SIGNINGPASSWORD" --pinentry-mode loopback --export-secret-keys $SIGNINGKEYID > $HOME/.gradle/secrets.gpg
42+
- name: Create gradle sproperties
43+
env:
44+
APIKEY: ${{ secrets.APIKEY }}
45+
APISECRET: ${{ secrets.APISECRET }}
46+
SIGNINGKEYID: ${{ secrets.SIGNINGKEYID }}
47+
SIGNINGPASSWORD: ${{ secrets.SIGNINGPASSWORD }}
48+
SONATYPEPASSWORD: ${{ secrets.SONATYPEPASSWORD }}
49+
SONATYPEUSER: ${{ secrets.SONATYPEUSER }}
50+
run: echo -e "gradle.publish.key=$APIKEY\ngradle.publish.secret=$APISECRET\nsigning.keyId=$SIGNINGKEYID\nsigning.password=$SIGNINGPASSWORD\nsigning.secretKeyRingFile=$HOME/.gradle/secrets.gpg\nsonatypeUsername=$SONATYPEUSER\nsonatypePassword=$SONATYPEPASSWORD" > $HOME/.gradle/gradle.properties
51+
- name: Build and test with Gradle
52+
env:
53+
JAVA_OPTS: "-Xmx1024M -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512M"
54+
GRADLE_OPTS: "-Dorg.gradle.daemon=true"
55+
run: ./gradlew test build -s
56+
- name: Post Build
57+
run: rm -f $HOME/.gradle/gradle.properties && rm -f $HOME/.docker/config.json

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Run release build from tag
5+
6+
on:
7+
push:
8+
tags:
9+
- '*'
10+
11+
jobs:
12+
release:
13+
environment: CIRelease
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Set up JDK 8
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: 8
21+
- uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
- run: git fetch --all --tag
25+
- name: Create .gradle dir
26+
run: mkdir -p $HOME/.gradle
27+
- id: install-secret-key
28+
name: Install gpg secret key
29+
env:
30+
SIGNINGFILE: ${{ secrets.SIGNINGFILE }}
31+
run: |
32+
cat <(echo -e "${{ secrets.SIGNINGFILE }}") | gpg --batch --import
33+
gpg --list-secret-keys --keyid-format LONG
34+
- id: export-gpg-file
35+
name: Export gpg file
36+
env:
37+
SIGNINGKEYID: ${{ secrets.SIGNINGKEYID }}
38+
SIGNINGPASSWORD: ${{ secrets.SIGNINGPASSWORD }}
39+
run: |
40+
gpg --batch --passphrase="$SIGNINGPASSWORD" --pinentry-mode loopback --export-secret-keys $SIGNINGKEYID > $HOME/.gradle/secrets.gpg
41+
- name: Create gradle sproperties
42+
env:
43+
APIKEY: ${{ secrets.APIKEY }}
44+
APISECRET: ${{ secrets.APISECRET }}
45+
SIGNINGKEYID: ${{ secrets.SIGNINGKEYID }}
46+
SIGNINGPASSWORD: ${{ secrets.SIGNINGPASSWORD }}
47+
SONATYPEPASSWORD: ${{ secrets.SONATYPEPASSWORD }}
48+
SONATYPEUSER: ${{ secrets.SONATYPEUSER }}
49+
run: echo -e "gradle.publish.key=$APIKEY\ngradle.publish.secret=$APISECRET\nsigning.keyId=$SIGNINGKEYID\nsigning.password=$SIGNINGPASSWORD\nsigning.secretKeyRingFile=$HOME/.gradle/secrets.gpg\nsonatypeUsername=$SONATYPEUSER\nsonatypePassword=$SONATYPEPASSWORD" > $HOME/.gradle/gradle.properties
50+
- name: Run gradle release
51+
env:
52+
JAVA_OPTS: "-Xmx1024M -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512M"
53+
GRADLE_OPTS: "-Dorg.gradle.daemon=true"
54+
run: ./gradlew -PrunOnCI=true test build :publishIntershopMvnPublicationToMavenRepository :publishPlugins -s
55+
- name: Post Build
56+
run: rm -f $HOME/.gradle/gradle.properties

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

build.gradle

Lines changed: 76 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,19 @@ plugins {
2525
id 'idea'
2626

2727
// intershop test plugin
28-
id 'com.intershop.gradle.test' version '2.1.0'
29-
30-
// plugin for documentation
31-
id 'org.asciidoctor.convert' version '1.5.3'
28+
id 'com.intershop.gradle.test' version '2.2.0'
3229

3330
// publish plugin
3431
id 'maven-publish'
3532

33+
// artifact signing - necessary on Maven Central
34+
id 'signing'
35+
3636
// intershop version plugin
37-
id 'com.intershop.gradle.scmversion' version '2.1.0'
37+
id 'com.intershop.gradle.scmversion' version '2.7.4'
3838

3939
// plugin for publishing to Gradle Portal
40-
id 'com.gradle.plugin-publish' version '0.9.5'
41-
42-
// plugin for publishing to jcenter
43-
id 'com.jfrog.bintray' version '1.7.1'
40+
id 'com.gradle.plugin-publish' version '0.20.0'
4441
}
4542

4643
scm {
@@ -66,49 +63,6 @@ test {
6663
systemProperty 'intershop.gradle.versions', '2.11, 3.1'
6764
}
6865

69-
task copyAsciiDoc {
70-
def outputDir = file("$buildDir/tmp/asciidoctorSrc")
71-
def inputFiles = fileTree(dir: rootDir, include: '**/*.asciidoc')
72-
73-
inputs.files inputFiles
74-
outputs.dir outputDir
75-
76-
doLast {
77-
outputDir.mkdirs()
78-
79-
copy {
80-
from inputFiles
81-
into outputDir
82-
}
83-
}
84-
}
85-
86-
asciidoctorj {
87-
noDefaultRepositories = true
88-
}
89-
90-
asciidoctor {
91-
sourceDir "${buildDir}/tmp/asciidoctorSrc"
92-
sources {
93-
include 'README.asciidoc'
94-
}
95-
96-
backends 'html5', 'docbook'
97-
options doctype : 'article',
98-
ruby : 'erubis'
99-
attributes 'latestRevision' : project.version,
100-
'toc':'left',
101-
'toclevels':'2',
102-
'source-highlighter' : 'coderay',
103-
'icons': 'font',
104-
'setanchors':'true',
105-
'idprefix':'asciidoc_',
106-
'idseparator':'-',
107-
'docinfo1':'true'
108-
}
109-
110-
asciidoctor.dependsOn copyAsciiDoc
111-
11266
jacocoTestReport {
11367
reports {
11468
xml.enabled = true // coveralls plugin depends on xml format report
@@ -127,6 +81,13 @@ task sourceJar(type: Jar) {
12781
from sourceSets.main.allSource
12882
}
12983

84+
85+
artifacts {
86+
archives jar
87+
archives sourceJar
88+
archives groovydocJar
89+
}
90+
13091
publishing {
13192
publications {
13293
intershopMvn(MavenPublication) {
@@ -140,75 +101,89 @@ publishing {
140101
classifier "javadoc"
141102
}
142103

143-
artifact(new File(buildDir, 'asciidoc/html5/README.html')) {
144-
classifier 'reference'
145-
}
146-
147-
artifact(new File(buildDir, 'asciidoc/docbook/README.xml')) {
148-
classifier = 'docbook'
149-
}
150-
151104
pom.withXml {
152-
def Node root = asNode();
105+
def root = asNode();
153106
root.appendNode('name', project.name)
154107
root.appendNode('description', project.description)
155108
root.appendNode('url', "https:/gitlab.intershop.de/IntershopGradlePlugins/${project.name}")
156109

157-
def scm = root.appendNode( 'scm' )
158-
scm.appendNode( 'url', "https://gitlab.intershop.de/IntershopGradlePlugins/${project.name}")
159-
scm.appendNode( 'connection', "scm:git:https://gitlab.intershop.de/IntershopGradlePlugins/${project.name}.git")
110+
def organisation = root.appendNode( 'organization' )
111+
organisation.appendNode("name", "Intershop Communications AG")
112+
organisation.appendNode("url", "http://intershop.com")
160113

161-
def org = root.appendNode( 'organization' )
162-
org.appendNode( 'name', 'Intershop Communications' )
163-
org.appendNode( 'url', 'http://intershop.com' )
114+
def scm = root.appendNode( 'scm' )
115+
scm.appendNode( 'url', "https://github.com/IntershopCommunicationsAG/${project.name}")
116+
scm.appendNode( 'connection', "[email protected]:IntershopCommunicationsAG/${project.name}.git")
117+
scm.appendNode( 'developerConnection', "[email protected]:IntershopCommunicationsAG/${project.name}.git")
164118

165-
def license = root.appendNode( 'licenses' ).appendNode( 'license' );
119+
def license = root.appendNode( 'licenses' ).appendNode( 'license' )
166120
license.appendNode( 'name', 'Apache License, Version 2.0' )
167-
license.appendNode( 'url', 'http://www.apache.org/licenses/LICENSE-2.0' )
121+
license.appendNode( 'url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
168122
license.appendNode( 'distribution', 'repo' )
123+
124+
def developer = root.appendNode('developers').appendNode( 'developer' )
125+
developer.appendNode( 'id', 'm-raab' )
126+
developer.appendNode( 'name', 'M. Raab' )
127+
developer.appendNode( 'email', '[email protected]' )
128+
129+
def pomFile = file("${project.buildDir}/generated-pom.xml")
130+
writeTo(pomFile)
131+
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
132+
artifact(pomAscFile) {
133+
classifier = null
134+
extension = 'pom.asc'
135+
}
136+
}
137+
138+
// create the signed artifacts
139+
project.tasks.signArchives.signatureFiles.each {
140+
artifact(it) {
141+
def matcher = it.file =~ /-(sources|javadoc)\.(jar)\.asc$/
142+
def ref_matcher = it.file =~ /\.html\.asc$/
143+
def doc_matcher = it.file =~ /\.xml\.asc$/
144+
if (matcher.find()) {
145+
classifier = matcher.group(1)
146+
extension = "jar.asc"
147+
} else {
148+
if(ref_matcher.find()) {
149+
classifier = 'reference'
150+
extension = 'html.asc'
151+
}
152+
else if(doc_matcher.find()) {
153+
classifier = 'docbook'
154+
extension = 'xml.asc'
155+
} else {
156+
classifier = null
157+
extension = 'jar.asc'
158+
}
159+
}
160+
161+
}
169162
}
170163
}
171164
}
172-
}
173-
174-
publish.dependsOn asciidoctor
175-
176-
bintray {
177-
user = System.getenv('BINTRAY_USER')
178-
key = System.getenv('BINTRAY_KEY')
179-
pkg {
180-
repo = 'maven'
181-
name = project.name
182-
userOrg = 'intershopcommunicationsag'
183-
184-
licenses = ['Apache-2.0']
185-
vcsUrl = "https://github.com/IntershopCommunicationsAG/${project.name}"
186-
187-
desc = project.description
188-
websiteUrl = "https://github.com/IntershopCommunicationsAG/${project.name}"
189-
issueTrackerUrl = "https://github.com/IntershopCommunicationsAG/${project.name}/issues"
190-
191-
labels = ['intershop', 'gradle', 'plugin', 'build', 'javacc']
192-
publicDownloadNumbers = true
193-
194-
version {
195-
name = project.version
196-
desc = "${project.description} ${project.version}"
197-
released = new Date()
198-
vcsTag = project.version
165+
repositories {
166+
maven {
167+
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
168+
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
169+
url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl)
170+
credentials {
171+
username = sonatypeUsername
172+
password = sonatypePassword
173+
}
199174
}
200-
201-
publications = ['intershopMvn']
202175
}
203176
}
204177

205-
bintrayUpload.dependsOn asciidoctor
178+
signing {
179+
sign configurations.archives
180+
}
206181

207182
pluginBundle {
208183
website = "https://github.com/IntershopCommunicationsAG/${project.name}"
209184
vcsUrl = "https://github.com/IntershopCommunicationsAG/${project.name}"
210185
description = project.description
211-
tags = ['intershop', 'gradle', 'plugin', 'build', 'javacc']
186+
tags = ['intershop', 'build', 'javacc']
212187

213188
plugins {
214189
escrowPlugin {
@@ -226,5 +201,5 @@ dependencies {
226201
}
227202

228203
repositories {
229-
jcenter()
204+
mavenCentral()
230205
}

0 commit comments

Comments
 (0)