From db446d0c55ddc3ca11abdc29a4d88bed990c4de0 Mon Sep 17 00:00:00 2001 From: Jared Hendry Date: Thu, 29 Apr 2021 01:58:38 -0400 Subject: [PATCH 1/4] Add support for publishing to the Central Repository --- .gitignore | 1 + support/build.gradle | 5 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- support/graphql.java.gen.build.gradle | 109 +++++++++--------- 4 files changed, 56 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index cb44d58..9c107b3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /tmp/ .idea /*.gem +.gradle diff --git a/support/build.gradle b/support/build.gradle index 9863ac2..e8ac1e3 100644 --- a/support/build.gradle +++ b/support/build.gradle @@ -1,9 +1,6 @@ buildscript { repositories { - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' + mavenCentral() } } diff --git a/support/gradle/wrapper/gradle-wrapper.properties b/support/gradle/wrapper/gradle-wrapper.properties index 2d80b69..4d9ca16 100644 --- a/support/gradle/wrapper/gradle-wrapper.properties +++ b/support/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/support/graphql.java.gen.build.gradle b/support/graphql.java.gen.build.gradle index a1bcea5..6056393 100644 --- a/support/graphql.java.gen.build.gradle +++ b/support/graphql.java.gen.build.gradle @@ -1,18 +1,12 @@ def VERSION_NAME = '0.2.0' -buildscript { - repositories { - jcenter() - } -} - 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' @@ -35,8 +29,6 @@ test { } } -version = VERSION_NAME - task sourcesJar(type: Jar) { from sourceSets.main.allSource classifier = 'sources' @@ -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 - } - } -} From aecd70bbf27bbb5b982bcd1126b46071ae91d0db Mon Sep 17 00:00:00 2001 From: Jared Hendry Date: Thu, 29 Apr 2021 01:59:09 -0400 Subject: [PATCH 2/4] Bump version for new artifact location --- support/graphql.java.gen.build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/graphql.java.gen.build.gradle b/support/graphql.java.gen.build.gradle index 6056393..59032cb 100644 --- a/support/graphql.java.gen.build.gradle +++ b/support/graphql.java.gen.build.gradle @@ -1,4 +1,4 @@ -def VERSION_NAME = '0.2.0' +def VERSION_NAME = '0.2.1' repositories { mavenCentral() From 0391bd5767ae5dcc3a510f4e10fec2182762194d Mon Sep 17 00:00:00 2001 From: Jared Hendry Date: Thu, 29 Apr 2021 02:06:03 -0400 Subject: [PATCH 3/4] Add Github action for automated release publishing --- .github/workflows/release.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c1d7c74 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} From 99c1db8d224ba5dc73d151eb13895ada8c943b7e Mon Sep 17 00:00:00 2001 From: Jared Hendry Date: Thu, 29 Apr 2021 14:25:16 -0400 Subject: [PATCH 4/4] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ede6181..5047ebf 100644 --- a/README.md +++ b/README.md @@ -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