Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gradle] Reworking publishing pipeline #2886

Merged
merged 6 commits into from
May 31, 2019
Merged

Conversation

jimschubert
Copy link
Member

@jimschubert jimschubert commented May 14, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

TravisCI proxies separate external requests with different orginating IP
addresses, while Sonatype associates artifacts for auto-generated
repositories by IP address. This leads to many gradle deploys from CI
resulting in "split" staging repositories with no way to combine in
Sonatype Nexus.

This introduces a workflow which should resolve this issue on the next
revision release. Specifically, nexus-publish-plugin is included to
create singular staging repositories from TravisCI and
gradle-nexus-staging-plugin is included to auto-release and promote
this repository.

NOTE:
We need to publish via publishPluginMavenPublicationToNexusRepository,
because publishToNexus will publish all publish-related tasks,
including the one intended only for the Gradle Plugin Portal.

Tested in standalone open source Nexus Repo Manager, which doesn't
support the staging plugin. So, only SNAPSHOT workflow has been
validated locally.

The enableFeaturePreview('STABLE_PUBLISHING') option in settings.gradle is a warning presented by the new nexus-publish-plugin:

As part of making the publishing plugins stable, the 'deferred configurable' behavior of the 'publishing {}' block has been deprecated. In Gradle 5.0 the 'enableFeaturePreview('STABLE_PUBLISHING')' flag will be removed and the new behavior will become the default. Please add 'enableFeaturePreview('STABLE_PUBLISHING')' to your settings file and do a test run by publishing to a local repository. If all artifacts are published as expected, there is nothing else to do. If the published artifacts change unexpectedly, please see the migration guide for more details: https://docs.gradle.org/4.10.2/userguide/publishing_maven.html#publishing_maven:deferred_configuration.

This PR is an attempt at resolving #411
cc @OpenAPITools/generator-core-team

TravisCI proxies separate external requests with different orginating IP
addresses, while Sonatype associates artifacts for auto-generated
repositories by IP address. This leads to many gradle deploys from CI
resulting in "split" staging repositories with no way to combine in
Sonatype Nexus.

This introduces a workflow which should resolve this issue on the next
revision release. Specifically, nexus-publish-plugin is included to
create singular staging repositories from TravisCI and
gradle-nexus-staging-plugin is included to auto-release and promote
this repository.

NOTE:
We need to publish via publishPluginMavenPublicationToNexusRepository,
because publishToNexus will publish _all_ publish-related tasks,
including the one intended only for the Gradle Plugin Portal.

Tested in standalone open source Nexus Repo Manager, which doesn't
support the staging plugin. So, only SNAPSHOT workflow has been
validated locally.
@auto-labeler
Copy link

auto-labeler bot commented May 14, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@@ -136,8 +136,8 @@ after_success:
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";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the 4.0.1 release fails, we may consider reverting to the uploadArchives and maven publishing plugin.

.travis.yml Outdated
./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";
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToNexusRepository --no-daemon;
echo "Finished ./gradlew publishPluginMavenPublicationToNexusRepository";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to see how this goes, but I guess that calling the task closeAndReleaseRepository would also be necessary. (the maven nexus plugin is doing something like this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the SNAPSHOT path (master), but your comment made me realize that I had completely missed updating the uploadArchives in the following conditional block which is used for releases. I believe the releases branch is the only one that requires closing.

@jmini
Copy link
Member

jmini commented May 15, 2019

Because of the change maven to maven-publish I have updated the helper-pom to use the task publishToMavenLocal, see 6b0c3fa

@jmini
Copy link
Member

jmini commented May 15, 2019

Now it is failing because of this error:

Cannot perform signing task ':signMavenJavaPublication' because it has no configured signatory

I think there is a way to say that signing is only for release version:
https://docs.gradle.org/current/userguide/signing_plugin.html#sec:conditional_signing

@jimschubert
Copy link
Member Author

@jmini thanks for also looking into this. Seems I'll need to work out the release signing for maven-publish. I'll try and get to that on the next day or so.

@jimschubert
Copy link
Member Author

In digging a little more, it seems we will need to call closeRepository on master (for snapshots) and closeAndReleaseRepository on versioned branches (for releases).

Here's the task graph of the target task:

\--- :publishPluginMavenPublicationToNexusRepository
     +--- :generatePomFileForPluginMavenPublication
     +--- :initializeNexusStagingRepository
     +--- :jar
     |    +--- :classes
     |    |    +--- :compileJava
     |    |    |    \--- :compileKotlin
     |    |    \--- :processResources
     |    |         \--- :pluginDescriptors
     |    +--- :compileKotlin
     |    \--- :inspectClassesForKotlinIC
     |         +--- :classes
     |         |    +--- :compileJava
     |         |    |    \--- :compileKotlin
     |         |    \--- :processResources
     |         |         \--- :pluginDescriptors
     |         \--- :compileKotlin
     \--- :signPluginMavenPublication
          +--- :generatePomFileForPluginMavenPublication
          \--- :jar
               +--- :classes
               |    +--- :compileJava
               |    |    \--- :compileKotlin
               |    \--- :processResources
               |         \--- :pluginDescriptors
               +--- :compileKotlin
               \--- :inspectClassesForKotlinIC
                    +--- :classes
                    |    +--- :compileJava
                    |    |    \--- :compileKotlin
                    |    \--- :processResources
                    |         \--- :pluginDescriptors
                    \--- :compileKotlin

initializeNexusStagingRepository will create the repository with our defined staging id. iirc from discussion with an engineer at Sonatype, these repositories are cleaned after 24 hours anyway, but I wouldn't want an open "snapshot" repository to become mixed in anyway with a release repository on the same day.

@wing328 wing328 added this to the 4.0.1 milestone May 31, 2019
@wing328 wing328 merged commit 6a1fc51 into master May 31, 2019
@wing328 wing328 deleted the gradle-plugin-publishing branch May 31, 2019 12:43
jimschubert added a commit to jimschubert/openapi-generator that referenced this pull request Jun 5, 2019
* 4.1.x: (56 commits)
  sync master
  Update compatibility table
  Ruby client: escape path parameters (OpenAPITools#3039)
  [gradle plugin] Release 4.0.1 fixes (OpenAPITools#3051)
  Update version to 4.0.2-SNAPSHOT (OpenAPITools#3047)
  Map number to double time since float is also parsed as double in Qt5 C++ (OpenAPITools#3046)
  Prepare 4.0.1 release (OpenAPITools#3041)
  [gradle] Reworking publishing pipeline (OpenAPITools#2886)
  [typescript-fetch] Fix uploading files (OpenAPITools#2900)
  Resolves OpenAPITools#2962 - Add properties config to Maven parameters (OpenAPITools#2963)
  fix(golang): Check error of xml Encode (OpenAPITools#3027)
  [C++][Restbed] Add handler callback methods (OpenAPITools#2911)
  Remove null checks for C# value types (OpenAPITools#2933)
  [python-server] Support python 3.7 for all server-generators (OpenAPITools#2884)
  Use golang's provided method names (gin) (OpenAPITools#2983)
  [python] Adding constructor parameters to Configuration and improving documentation (OpenAPITools#3002)
  Add new option to maven plugin's readme (OpenAPITools#3025)
  Engine param in maven plugin. (OpenAPITools#2881)
  Added support for patterns on model properties (OpenAPITools#2948)
  [csharp] Make API response headers dictionary case insensitive (OpenAPITools#2998)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants