Skip to content

Commit 891c339

Browse files
authored
Merge pull request #34 from newrelic/gfuller/github-actions
Gfuller/GitHub actions
2 parents aa603d3 + 0d41c3b commit 891c339

File tree

4 files changed

+85
-70
lines changed

4 files changed

+85
-70
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: publish snapshot on main merge
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up JDK 11
13+
uses: actions/[email protected]
14+
with:
15+
java-version: 11
16+
- name: Build with Gradle
17+
env:
18+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
19+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
20+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
21+
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
22+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
23+
run: ./gradlew build publish

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ This generates a jar artifact in the following subdirectory:
112112
java-aws-lambda/build/libs/java-aws-lambda.jar
113113
```
114114

115+
#### Publishing to maven local
116+
If you'd like to publish a version of this project to your
117+
local maven repository run the following command:
118+
```
119+
./gradlew publishToMavenLocal
120+
```
121+
115122
### Testing
116123
Run the following gradle task:
117124
```

build.gradle

Lines changed: 54 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@ buildscript {
1111
}
1212
dependencies {
1313
classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8"
14-
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
1514
}
1615
}
1716

1817
plugins {
1918
id 'java'
19+
id 'maven-publish'
20+
id 'signing'
2021
}
2122

2223
apply plugin: 'com.github.sherter.google-java-format'
23-
apply plugin: 'com.bmuschko.nexus'
2424

2525
repositories {
2626
mavenCentral()
27-
}
28-
29-
project.configurations.configure {
30-
"sonatype"() {
31-
extendsFrom archives
27+
maven {
28+
url 'https://oss.sonatype.org/content/repositories/snapshots'
3229
}
3330
}
3431

@@ -64,72 +61,60 @@ jar {
6461
}
6562
}
6663

67-
task uploadSonatype(type: Upload) {
68-
configuration = configurations.sonatype
69-
uploadDescriptor = true
70-
}
71-
72-
task customSourcesJar(type: Jar) {
73-
classifier = 'sources'
74-
from(projectDir) { include "README.md" }
75-
from(sourceSets.main.allSource)
76-
77-
manifest {
78-
attributes 'Implementation-Title': 'AWS Lambda OpenTracing Java SDK Sources',
79-
'Implementation-Version': project.version,
80-
'Created-By': 'New Relic, Inc',
81-
'Built-Date': new Date(),
82-
'Specification-Version': project.version,
83-
'Build-Id': System.getProperty('BUILD_ID') || "None"
84-
}
85-
}
86-
87-
artifacts {
88-
archives customSourcesJar
89-
}
90-
91-
extraArchive {
92-
sources = false
93-
}
94-
95-
nexus {
96-
sign = true
97-
configuration = "sonatype"
98-
}
99-
100-
uploadSonatype.doFirst {
101-
configuration.artifacts.each {
102-
println(project.name + " uploading: " + it)
103-
}
104-
}
105-
106-
def customizePom(pom, nameIn, descriptionIn) {
107-
pom.project {
108-
url 'https://newrelic.com/'
109-
name nameIn
110-
description descriptionIn
111-
112-
licenses {
113-
license { url 'https://github.com/newrelic/java-aws-lambda/blob/master/LICENSE' }
64+
publishing {
65+
repositories {
66+
maven {
67+
def releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
68+
def snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
69+
if (version.toString().endsWith("SNAPSHOT")) {
70+
url = snapshotsRepoUrl
71+
} else {
72+
url = releasesRepoUrl
73+
}
74+
credentials {
75+
username = System.getenv("SONATYPE_USERNAME")
76+
password = System.getenv("SONATYPE_PASSWORD")
77+
}
11478
}
115-
116-
scm {
117-
url "[email protected]:newrelic/java-aws-lambda.git"
118-
connection "scm:git:[email protected]:newrelic/java-aws-lambda.git"
79+
}
80+
publications {
81+
register("mavenJava", MavenPublication.class) {
82+
from(components["java"])
11983
}
120-
121-
developers {
122-
developer {
123-
id 'newrelic'
124-
name 'New Relic'
125-
84+
// customize all publications here
85+
withType(MavenPublication.class) {
86+
pom {
87+
name.set(project.name)
88+
description.set("SDK that provides open tracing instrumentation for AWS Lambda")
89+
url.set("https://github.com/newrelic/java-aws-lambda")
90+
licenses {
91+
license {
92+
name.set("The Apache License, Version 2.0")
93+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
94+
distribution.set("repo")
95+
}
96+
}
97+
developers {
98+
developer {
99+
id.set("newrelic")
100+
name.set("New Relic")
101+
email.set("[email protected]")
102+
}
103+
}
104+
scm {
105+
url.set("[email protected]:newrelic/java-aws-lambda.git")
106+
connection.set("scm:[email protected]:newrelic/java-aws-lambda.git")
107+
}
126108
}
127109
}
128110
}
129111
}
130112

131-
// For external deploys (e.g. - release)
132-
modifyPom { pom ->
133-
customizePom(pom, 'AWS Lambda OpenTracing Java SDK',
134-
'OpenTracing Java SDK for instrumenting AWS Lambda functions.')
135-
}
113+
signing {
114+
def signingKeyId = findProperty("signingKeyId")
115+
def signingKey = findProperty("signingKey")
116+
def signingPassword = findProperty("signingPassword")
117+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
118+
setRequired({ gradle.taskGraph.hasTask("uploadArchives") })
119+
sign publishing.publications["mavenJava"]
120+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)