|
| 1 | + |
| 2 | +# Deploying |
| 3 | + |
| 4 | +## Introduction |
| 5 | + |
| 6 | +There are currently two steps to the deployment, travis + sonatype, with a few random extra bits of knowledge. |
| 7 | + |
| 8 | +Travis will either deploy a snapshot or a release based on the version in build.gradle. If you deploy a release build, you will need to manually go to sonatype to release it. Those builds are found in the staging area. (We need to try to automate this in the future.) |
| 9 | + |
| 10 | +## Important note about release repositories |
| 11 | + |
| 12 | +The gradle close and release process will fail if there is more than one repository staged. You may need to manually drop repositories from staging during testing on a single version number. |
| 13 | + |
| 14 | +## Manually Deploying |
| 15 | + |
| 16 | +You can deploy manually by setting up your gradle.properties to have: |
| 17 | + |
| 18 | +```ascii |
| 19 | +signing.keyId=<TRAVIS_GPG_KEY_ID> |
| 20 | +signing.password=<TRAVIS_KEY_PASSPHRASE> |
| 21 | +signing.secretKeyRingFile=<PATH TO THE KEYRING> |
| 22 | +
|
| 23 | +ossrhUsername=<YOUR_JIRA_USER_NAME> |
| 24 | +ossrhPassword=<YOUR_JIRA_PASSWORD> |
| 25 | +
|
| 26 | +#local_archives=true |
| 27 | +``` |
| 28 | + |
| 29 | +the last line, if uncommented, will cause the deploy to go to your build folder, so that you can manually check it. Once you have the properties set up, simple type |
| 30 | + |
| 31 | +```bash |
| 32 | +> ./gradlew uploadArchives |
| 33 | +``` |
| 34 | + |
| 35 | +to upload to the repo. |
| 36 | + |
| 37 | +## Automating the travis deploy |
| 38 | + |
| 39 | +See [https://rishikeshdarandale.github.io/build/deploying-to-oss-sonatype-using-travis/](https://rishikeshdarandale.github.io/build/deploying-to-oss-sonatype-using-travis/) and [https://central.sonatype.org/pages/gradle.html](https://central.sonatype.org/pages/gradle.html) |
| 40 | + |
| 41 | +The global/secure values are used to deploy, they can be regenerated/created by someone with access to |
| 42 | +the sonatype repository |
| 43 | + |
| 44 | +You can use --add or copy and paste to the global section manually. |
| 45 | +I had issues with the repo, so you may want to add -r nats-io/java-nats |
| 46 | + |
| 47 | +```bash |
| 48 | +> cd java-nats |
| 49 | +> travis encrypt SONATYPE_USERNAME="<YOUR_JIRA_USER_NAME>" --add |
| 50 | +> travis encrypt SONATYPE_PASSWORD="<YOUR_JIRA_PASSWORD>" --add |
| 51 | +> travis encrypt GPG_KEY_ID="<TRAVIS_GPG_KEY_ID>" --add |
| 52 | +> travis encrypt GPG_KEY_PASSPHRASE="<TRAVIS_KEY_PASSPHRASE>" --add |
| 53 | +``` |
| 54 | + |
| 55 | +or use |
| 56 | + |
| 57 | +```bash |
| 58 | +> travis encrypt -i |
| 59 | +``` |
| 60 | + |
| 61 | +to avoid passwords in shell history. |
| 62 | + |
| 63 | +To get the signing key to travis, export it and put it in the .travis folder |
| 64 | + |
| 65 | +```bash |
| 66 | +> gpg --export-secret-key <TRAVIS_KEY_ID> > nats.travis.gpg |
| 67 | +> travis encrypt-file .travis/nats.travis.gpg |
| 68 | +``` |
| 69 | + |
| 70 | +Update the before install as instructed |
| 71 | + |
| 72 | +NOTE - if your password has special characters to BASH - which may be required by sonatype, you need to escape them before you encrypt them. If you do not then bash will mess them up when Travis tries to set them. |
| 73 | + |
| 74 | +## Releasing |
| 75 | + |
| 76 | +### Using Gradle |
| 77 | + |
| 78 | +I found the [gradle-nexus-staging-plugin](https://github.com/Codearte/gradle-nexus-staging-plugin/) which can release from staging. |
| 79 | + |
| 80 | +From the readme, you can use the three tasks: |
| 81 | + |
| 82 | +* closeRepository - closes an open repository with the uploaded artifacts. There should be just one open repository available in the staging profile (possible old/broken repositories can be dropped with Nexus GUI) |
| 83 | +* releaseRepository - releases a closed repository (required to put artifacts to Maven Central aka The Central Repository) |
| 84 | +* closeAndReleaseRepository - closes and releases a repository (an equivalent to closeRepository releaseRepository) |
| 85 | + |
| 86 | +This last one will fail if the repo already exists using the specified version number |
| 87 | + |
| 88 | +### Manual release |
| 89 | + |
| 90 | +Once the uploadArchives completes, your artifact will be staged with Sonatype, but you need to verify it all looks good before it’s released from the staging area. To do this, you need to follow these steps: |
| 91 | + |
| 92 | +1. Log into Sonatype Pro |
| 93 | +2. Click “Staging Repositories” and scroll to the bottom of the list, look for ionats |
| 94 | +3. Check the contents in the tab |
| 95 | +4. Click “Close” at the top of the list |
| 96 | +5. Click “Release”! at the top of the list |
| 97 | + |
| 98 | +## The signing key |
| 99 | + |
| 100 | +The key is encrypted into github using the above instructions. The public key was uploaded to a central site by exporting it: |
| 101 | + |
| 102 | +```bash |
| 103 | +gpg --export -a "nats.io" > public.key |
| 104 | +``` |
| 105 | + |
| 106 | +then manually uploading at `http://keys.gnupg.net:11371/`. So that sonatype can find it. You can also upload to `http://keyserver.ubuntu.com/` and `http://pool.sks-keyservers.net/pks/add`. You can also do this on the command line: |
| 107 | + |
| 108 | +```bash |
| 109 | +> gpg --keyserver keyserver.ubuntu.com --send-keys <keyid> |
| 110 | +> gpg --keyserver pool.sks-keyservers.net --send-keys <keyid> |
| 111 | +> gpg --keyserver keys.gnupg.net --send-keys <keyid> |
| 112 | +> gpg --keyserver pgp.mit.edu --send-keys <keyid> |
| 113 | + ``` |
| 114 | + |
| 115 | + The entire key process is very very painful, and seems to take time to propagate |
0 commit comments