diff --git a/.gitignore b/.gitignore index 4db9651afa2..c33eae088e1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ out/ *.ipr *.iws +*.gpg classpath.txt version.properties !modules/openapi-generator-cli/src/main/resources/version.properties diff --git a/.travis.yml b/.travis.yml index 3b4fa068926..bca3beb431d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,9 @@ cache: - $HOME/.ivy2 - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ + - $HOME/samples/client/petstore/javascript/node_modules - $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor - - $HOME/samples/client/petstore/ruby/venodr/bundle + - $HOME/samples/client/petstore/ruby/vendor/bundle - $HOME/samples/client/petstore/python/.venv/ - $HOME/samples/client/petstore/typescript-node/npm/node_modules - $HOME/samples/client/petstore/typescript-node/npm/typings/ @@ -26,6 +27,10 @@ cache: - $HOME/samples/client/petstore/typescript-angular/typings - $HOME/perl5 +# Don't cache artifacts installed by this build. +before_cache: + - rm -rf $HOME/.m2/repository/org/openapitools + services: - docker @@ -72,6 +77,8 @@ before_install: - cat /etc/hosts # show java version - java -version + - openssl aes-256-cbc -K $encrypted_6e2c8bba47c6_key -iv $encrypted_6e2c8bba47c6_iv -in sec.gpg.enc -out sec.gpg -d + - gpg --keyserver pgp.mit.edu --recv-key $SIGNING_KEY install: # Add Godeps dependencies to GOPATH and PATH @@ -93,10 +100,15 @@ script: - mvn --quiet clean install - mvn --quiet verify -Psamples after_success: - # push a snapshot version to maven repo - - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_BRANCH" = "master" ]; then - mvn clean deploy --settings CI/settings.xml; + # push to maven repo + - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml; echo "Finished mvn clean deploy for $TRAVIS_BRANCH"; + pushd . + cd modules/openapi-generator-gradle-plugin + ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon + echo "Finished ./gradlew uploadArchives" + popd fi; ## docker: build and push openapi-generator-online to DockerHub - if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME"; fi; fi diff --git a/CI/settings.xml b/CI/settings.xml index ca9d5bd69eb..027d195c174 100644 --- a/CI/settings.xml +++ b/CI/settings.xml @@ -13,6 +13,18 @@ - + + + release + + true + + + gpg + ${env.SIGNING_KEY} + ${env.SIGNING_PASSPHRASE} + + + diff --git a/modules/openapi-generator-gradle-plugin/build.gradle b/modules/openapi-generator-gradle-plugin/build.gradle index 9392744804b..25fb2b73039 100644 --- a/modules/openapi-generator-gradle-plugin/build.gradle +++ b/modules/openapi-generator-gradle-plugin/build.gradle @@ -21,9 +21,11 @@ This plugin supports common functionality found in Open API Generator CLI as a g This gives you the ability to generate client SDKs, documentation, new generators, and to validate Open API 2.0 and 3.x specifications as part of your build. Other tasks are available as command line tasks. """ +ext.isReleaseVersion = !version.endsWith("SNAPSHOT") apply plugin: 'java-gradle-plugin' -apply plugin: 'maven-publish' +apply plugin: 'maven' +apply plugin: 'signing' apply plugin: 'kotlin' apply plugin: "org.gradle.kotlin.kotlin-dsl" @@ -67,7 +69,6 @@ test { } } - gradlePlugin { plugins { openApiGenerator { @@ -77,6 +78,87 @@ gradlePlugin { } } +// signing will require three keys to be defined: signing.keyId, signing.password, and signing.secretKeyRingFile. +// These can be passed to the gradle command: +// ./gradlew -Psigning.keyId=yourid +// or stored as key=value pairs in ~/.gradle/gradle.properties +// You can also apply them in CI via environment variables. See Gradle's docs for details. +signing { + required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives +} + +task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc +} + +task sourcesJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' +} + +artifacts { + archives javadocJar, sourcesJar +} + +def pomConfig = { + description project.description + name 'OpenAPI-Generator Contributors' + url 'https://openapi-generator.tech' + organization { + name 'org.openapitools' + url 'https://github.com/OpenAPITools' + } + licenses { + license { + name "The Apache Software License, Version 2.0" + url "http://www.apache.org/licenses/LICENSE-2.0.txt" + distribution "repo" + } + } + developers { + developer { + id "openapitools" + name "OpenAPI-Generator Contributors" + email "team@openapitools.org" + } + } + scm { + url 'https://github.com/OpenAPITools/openapi-generator' + connection 'scm:git:git://github.com/OpenAPITools/openapi-generator.git' + developerConnection 'scm:git:ssh://git@github.com:OpenAPITools/openapi-generator.git' + } + issueManagement { + system 'GitHub' + url 'https://github.com/OpenAPITools/openapi-generator/issues' + } +} + +uploadArchives { + repositories { + + // credentials here would need to be passed along with the gradle command: + // ./gradlew -P ossrhUsername=yourUser + // or stored in ~/.gradle/gradle.properties as key=value pairs + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.withXml { + def root = asNode() + root.appendNode('description', project.description) + root.children().last() + pomConfig + } + } + } +} + compileKotlin { kotlinOptions { jvmTarget = "1.8" @@ -86,4 +168,4 @@ compileTestKotlin { kotlinOptions { jvmTarget = "1.8" } -} \ No newline at end of file +} diff --git a/modules/openapi-generator-gradle-plugin/gradle.properties b/modules/openapi-generator-gradle-plugin/gradle.properties index cd288d87a9a..d4f55303ad5 100644 --- a/modules/openapi-generator-gradle-plugin/gradle.properties +++ b/modules/openapi-generator-gradle-plugin/gradle.properties @@ -1 +1,10 @@ openApiGeneratorVersion=3.0.1-SNAPSHOT + +# BEGIN placeholders +# these are just placeholders to allow contributors to build directly +ossrhUsername=user +ossrhPassword=pass +signing.keyId=unset +signing.password=unset +# signing.secretKeyRingFile=unset +# END placeholders diff --git a/modules/openapi-generator-gradle-plugin/pom.xml b/modules/openapi-generator-gradle-plugin/pom.xml index 6f188214b08..23785b6ad0e 100644 --- a/modules/openapi-generator-gradle-plugin/pom.xml +++ b/modules/openapi-generator-gradle-plugin/pom.xml @@ -56,10 +56,10 @@ - + clean - build - publishToMavenLocal + assemble + install diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle b/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle index 52f80315398..a0f00237d8a 100644 --- a/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle +++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle @@ -5,6 +5,12 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } + maven { + url "https://oss.sonatype.org/content/repositories/releases/" + } + maven { + url "https://oss.sonatype.org/content/repositories/snapshots/" + } } dependencies { classpath "org.openapitools:openapi-generator-gradle-plugin:3.0.0-SNAPSHOT" diff --git a/pom.xml b/pom.xml index 27eed456e7c..f1a652a06dc 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,12 @@ github https://github.com/openapitools/openapi-generator/issues + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + Apache License 2.0 @@ -279,6 +285,40 @@ + + + release + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + release-profile diff --git a/sec.gpg.enc b/sec.gpg.enc new file mode 100644 index 00000000000..e5594adbd4d Binary files /dev/null and b/sec.gpg.enc differ