Skip to content

Commit 18fd2c4

Browse files
authored
Merge pull request #57 from Shopify/central-migration
Add support for publishing to Maven Central
2 parents 163f64b + 99c1db8 commit 18fd2c4

File tree

6 files changed

+84
-64
lines changed

6 files changed

+84
-64
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish package to the Maven Central Repository
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish:
7+
environment:
8+
name: Central Repository Deployment
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Java
13+
uses: actions/setup-java@v2
14+
with:
15+
java-version: '8'
16+
distribution: 'adopt'
17+
- name: Publish package
18+
working-directory: ./support
19+
run: ./gradlew uploadArchives
20+
env:
21+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
22+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
23+
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
24+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
25+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/tmp/
55
.idea
66
/*.gem
7+
.gradle

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ And then execute:
2323

2424
The generated code depends on the com.shopify.graphql.support java
2525
package. This can be added to a gradle project by adding the following
26-
jCenter dependancy to you `build.gradle` file:
26+
dependancy to you `build.gradle` file:
2727

28-
compile 'com.shopify.graphql.support:support:0.2.0'
28+
implementation 'com.shopify.graphql.support:support:0.2.1'
2929

3030
## Usage
3131

support/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
buildscript {
22
repositories {
3-
jcenter()
4-
}
5-
dependencies {
6-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
3+
mavenCentral()
74
}
85
}
96

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.8.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

support/graphql.java.gen.build.gradle

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
def VERSION_NAME = '0.2.0'
2-
3-
buildscript {
4-
repositories {
5-
jcenter()
6-
}
7-
}
1+
def VERSION_NAME = '0.2.1'
82

93
repositories {
10-
jcenter()
4+
mavenCentral()
115
}
126

137
apply plugin: 'java'
148
apply plugin: 'maven'
15-
apply plugin: 'com.jfrog.bintray'
9+
apply plugin: 'signing'
1610

1711
dependencies {
1812
implementation 'com.google.code.gson:gson:2.8.5'
@@ -35,8 +29,6 @@ test {
3529
}
3630
}
3731

38-
version = VERSION_NAME
39-
4032
task sourcesJar(type: Jar) {
4133
from sourceSets.main.allSource
4234
classifier = 'sources'
@@ -65,60 +57,65 @@ ext {
6557
licenseName = 'The MIT License'
6658
licenseUrl = 'https://opensource.org/licenses/MIT'
6759
allLicenses = ["MIT"]
60+
61+
author = 'Shopify Inc.'
6862
}
6963

7064
group = publishedGroupId
65+
archivesBaseName = artifact
66+
version = VERSION_NAME
67+
68+
signing {
69+
required { gradle.taskGraph.hasTask("uploadArchives") }
70+
def signingKeyId = findProperty("signingKeyId")
71+
def signingKey = findProperty("signingKey")
72+
def signingPassword = findProperty("signingPassword")
73+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
74+
sign configurations.archives
75+
}
76+
77+
uploadArchives {
78+
repositories {
79+
mavenDeployer {
80+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
81+
82+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
83+
authentication(userName: System.getenv("OSSRH_USERNAME"), password: System.getenv("OSSRH_PASSWORD"))
84+
}
85+
86+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
87+
authentication(userName: System.getenv("OSSRH_USERNAME"), password: System.getenv("OSSRH_PASSWORD"))
88+
}
89+
90+
pom {
91+
project {
92+
groupId project.ext.publishedGroupId
93+
artifactId project.ext.artifact
7194

72-
install {
73-
repositories.mavenInstaller {
74-
// Generates POM.xml with proper parameters
75-
pom {
76-
project {
77-
groupId publishedGroupId
78-
artifactId artifact
79-
80-
name libraryName
81-
description libraryDescription
82-
url siteUrl
83-
84-
licenses {
85-
license {
86-
name licenseName
87-
url licenseUrl
95+
name project.ext.libraryName
96+
description project.ext.libraryDescription
97+
url project.ext.siteUrl
98+
99+
developers {
100+
developer {
101+
name project.ext.author
102+
}
88103
}
89-
}
90104

91-
scm {
92-
connection gitUrl
93-
developerConnection gitUrl
94-
url siteUrl
105+
licenses {
106+
license {
107+
name project.ext.licenseName
108+
url project.ext.licenseUrl
109+
}
110+
}
111+
112+
scm {
113+
connection = project.ext.gitUrl
114+
developerConnection = project.ext.gitUrl
115+
url = project.ext.siteUrl
116+
}
95117
}
96118
}
97119
}
98120
}
99121
}
100-
101-
bintray {
102-
/*
103-
These values can be found on https://bintray.com/profile/edit
104-
BINTRAY_USER : your personal profile name (from "Your Profile")
105-
BINTRAY_KEY : found on the left menu, under "API Key"
106-
*/
107-
user = System.getenv('BINTRAY_USER')
108-
key = System.getenv('BINTRAY_KEY')
109-
110-
configurations = ['archives']
111-
publish = true
112-
pkg {
113-
userOrg = 'shopify'
114-
repo = 'shopify-java'
115-
name = libraryName
116-
desc = libraryDescription
117-
websiteUrl = siteUrl
118-
vcsUrl = gitUrl
119-
licenses = allLicenses
120-
version {
121-
name = VERSION_NAME
122-
}
123-
}
124-
}

0 commit comments

Comments
 (0)