Skip to content

Commit

Permalink
Merge pull request #57 from Shopify/central-migration
Browse files Browse the repository at this point in the history
Add support for publishing to Maven Central
  • Loading branch information
jaredh authored May 1, 2021
2 parents 163f64b + 99c1db8 commit 18fd2c4
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 64 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish package to the Maven Central Repository
on:
release:
types: [created]
jobs:
publish:
environment:
name: Central Repository Deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Publish package
working-directory: ./support
run: ./gradlew uploadArchives
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/tmp/
.idea
/*.gem
.gradle
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ And then execute:

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

compile 'com.shopify.graphql.support:support:0.2.0'
implementation 'com.shopify.graphql.support:support:0.2.1'

## Usage

Expand Down
5 changes: 1 addition & 4 deletions support/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion support/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
111 changes: 54 additions & 57 deletions support/graphql.java.gen.build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
def VERSION_NAME = '0.2.0'

buildscript {
repositories {
jcenter()
}
}
def VERSION_NAME = '0.2.1'

repositories {
jcenter()
mavenCentral()
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'signing'

dependencies {
implementation 'com.google.code.gson:gson:2.8.5'
Expand All @@ -35,8 +29,6 @@ test {
}
}

version = VERSION_NAME

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
Expand Down Expand Up @@ -65,60 +57,65 @@ ext {
licenseName = 'The MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]

author = 'Shopify Inc.'
}

group = publishedGroupId
archivesBaseName = artifact
version = VERSION_NAME

signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
def signingKeyId = findProperty("signingKeyId")
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: System.getenv("OSSRH_USERNAME"), password: System.getenv("OSSRH_PASSWORD"))
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: System.getenv("OSSRH_USERNAME"), password: System.getenv("OSSRH_PASSWORD"))
}

pom {
project {
groupId project.ext.publishedGroupId
artifactId project.ext.artifact

install {
repositories.mavenInstaller {
// Generates POM.xml with proper parameters
pom {
project {
groupId publishedGroupId
artifactId artifact

name libraryName
description libraryDescription
url siteUrl

licenses {
license {
name licenseName
url licenseUrl
name project.ext.libraryName
description project.ext.libraryDescription
url project.ext.siteUrl

developers {
developer {
name project.ext.author
}
}
}

scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
licenses {
license {
name project.ext.licenseName
url project.ext.licenseUrl
}
}

scm {
connection = project.ext.gitUrl
developerConnection = project.ext.gitUrl
url = project.ext.siteUrl
}
}
}
}
}
}

bintray {
/*
These values can be found on https://bintray.com/profile/edit
BINTRAY_USER : your personal profile name (from "Your Profile")
BINTRAY_KEY : found on the left menu, under "API Key"
*/
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')

configurations = ['archives']
publish = true
pkg {
userOrg = 'shopify'
repo = 'shopify-java'
name = libraryName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
version {
name = VERSION_NAME
}
}
}

0 comments on commit 18fd2c4

Please sign in to comment.