1Releasing 2========= 3 4### Prerequisite: Sonatype (Maven Central) Account 5 6Create an account on the [Sonatype issues site][sonatype_issues]. Ask an existing publisher to open 7an issue requesting publishing permissions for `com.squareup` projects. 8 9### Prerequisite: GPG Keys 10 11Generate a GPG key (RSA, 4096 bit, 3650 day) expiry, or use an existing one. You should leave the 12password empty for this key. 13 14``` 15$ gpg --full-generate-key 16``` 17 18Upload the GPG keys to public servers: 19 20``` 21$ gpg --list-keys --keyid-format LONG 22/Users/johnbarber/.gnupg/pubring.kbx 23------------------------------ 24pub rsa4096/XXXXXXXXXXXXXXXX 2019-07-16 [SC] [expires: 2029-07-13] 25 YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY 26uid [ultimate] John Barber <jbarber@squareup.com> 27sub rsa4096/ZZZZZZZZZZZZZZZZ 2019-07-16 [E] [expires: 2029-07-13] 28 29$ gpg --send-keys --keyserver keyserver.ubuntu.com XXXXXXXXXXXXXXXX 30``` 31 32### Prerequisite: Gradle Properties 33 34Define publishing properties in `~/.gradle/gradle.properties`: 35 36``` 37signing.keyId=1A2345F8 38signing.password= 39signing.secretKeyRingFile=/Users/jbarber/.gnupg/secring.gpg 40``` 41 42`signing.keyId` is the GPG key's ID. Get it with this: 43 44 ``` 45 $ gpg --list-keys --keyid-format SHORT 46 ``` 47 48`signing.password` is the password for this key. This might be empty! 49 50`signing.secretKeyRingFile` is the absolute path for `secring.gpg`. You may need to export this 51file manually with the following command where `XXXXXXXX` is the `keyId` above: 52 53 ``` 54 $ gpg --keyring secring.gpg --export-secret-key XXXXXXXX > ~/.gnupg/secring.gpg 55 ``` 56 57 58Cutting a Release 59----------------- 60 611. Update `CHANGELOG.md`. 62 632. Set versions: 64 65 ``` 66 export RELEASE_VERSION=X.Y.Z 67 export NEXT_VERSION=X.Y.Z-SNAPSHOT 68 ``` 69 703. Set environment variables with your [Sonatype credentials][sonatype_issues]. 71 72 ``` 73 export SONATYPE_NEXUS_USERNAME=johnbarber 74 export SONATYPE_NEXUS_PASSWORD=`pbpaste` 75 ``` 76 774. Update, build, and upload: 78 79 ``` 80 sed -i "" \ 81 "s/VERSION_NAME=.*/VERSION_NAME=$RELEASE_VERSION/g" \ 82 gradle.properties 83 sed -i "" \ 84 "s/\"com.squareup.okio:\([^\:]*\):[^\"]*\"/\"com.squareup.okio:\1:$RELEASE_VERSION\"/g" \ 85 `find . -name "README.md"` 86 ./gradlew clean publish 87 ``` 88 895. Visit [Sonatype Nexus][sonatype_nexus] to promote (close then release) the artifact. Or drop it 90 if there is a problem! 91 926. Tag the release, prepare for the next one, and push to GitHub. 93 94 ``` 95 git commit -am "Prepare for release $RELEASE_VERSION." 96 git tag -a parent-$RELEASE_VERSION -m "Version $RELEASE_VERSION" 97 sed -i "" \ 98 "s/VERSION_NAME=.*/VERSION_NAME=$NEXT_VERSION/g" \ 99 gradle.properties 100 git commit -am "Prepare next development version." 101 git push && git push --tags 102 ``` 103 104 [sonatype_issues]: https://issues.sonatype.org/ 105 [sonatype_nexus]: https://oss.sonatype.org/ 106