|
| 1 | +# Releasing NdArray Java Library |
| 2 | + |
| 3 | +The |
| 4 | +[NdArray Java Library](https://github.com/tensorflow/java-ndarray) is available on Maven Central and JCenter |
| 5 | +through artifacts uploaded to |
| 6 | +[OSS Sonatype](https://oss.sonatype.org/content/repositories/releases/org/tensorflow/). This |
| 7 | +document describes the process of updating the release artifacts. It does _not_ describe how to use |
| 8 | +the artifacts, for which the reader is referred to the |
| 9 | +[NdArray Java Library installation instructions](https://github.com/tensorflow/java-ndarray/blob/main/README.md). |
| 10 | + |
| 11 | +## Release process overview |
| 12 | + |
| 13 | +NdArray Java Library must be conducted locally in a [Docker](https://www.docker.com) container for a hermetic release process. |
| 14 | + |
| 15 | +It is important to note that any change pushed to a release branch (i.e. a branch prefixed |
| 16 | +by `r`) will start a new release workflow. Therefore, these changes should always increment the |
| 17 | +version number. |
| 18 | + |
| 19 | +### Pre-requisites |
| 20 | + |
| 21 | +- `docker` |
| 22 | +- An account at [oss.sonatype.org](https://oss.sonatype.org/), that has |
| 23 | + permissions to update artifacts in the `org.tensorflow` group. If your |
| 24 | + account does not have permissions, then you'll need to ask someone who does |
| 25 | + to [file a ticket](https://issues.sonatype.org/) to add to the permissions |
| 26 | + ([sample ticket](https://issues.sonatype.org/browse/MVNCENTRAL-1637)). |
| 27 | +- A GPG signing key, required |
| 28 | + [to sign the release artifacts](http://central.sonatype.org/pages/apache-maven.html#gpg-signed-components). |
| 29 | + |
| 30 | +### Preparing a release |
| 31 | + |
| 32 | +#### Major or minor release |
| 33 | + |
| 34 | +1. Get a clean version of the source code by cloning the |
| 35 | + [NdArray Java Library GitHub repository](https://github.com/tensorflow/java-ndarray) |
| 36 | + ``` |
| 37 | + git clone https://github.com/tensorflow/java-ndarray |
| 38 | + ``` |
| 39 | +2. Create a new branch for the release named `r<MajorVersion>.<MinorVersion>` |
| 40 | + ``` |
| 41 | + git checkout -b r1.0 |
| 42 | + ``` |
| 43 | +3. Update the version of the Maven artifacts to the full version of the release |
| 44 | + ``` |
| 45 | + mvn versions:set -DnewVersion=1.0.0 |
| 46 | + ``` |
| 47 | +4. Update the NdArray Java Library version to reflect the new release at the following locations: |
| 48 | + - https://github.com/tensorflow/java-ndarray/blob/main/README.md#introduction |
| 49 | +
|
| 50 | +5. Commit the changes and push the branch to the GitHub repository |
| 51 | + ``` |
| 52 | + git add . |
| 53 | + git commit -m "Releasing 1.0.0" |
| 54 | + git push --set-upstream origin r1.0 |
| 55 | + ``` |
| 56 | +
|
| 57 | +#### Patch release |
| 58 | +
|
| 59 | +1. Get a clean version of the source code by cloning the |
| 60 | + [NdArray Java Library GitHub repository](https://github.com/tensorflow/java-ndarray) |
| 61 | + ``` |
| 62 | + git clone https://github.com/tensorflow/java-ndarray |
| 63 | + ``` |
| 64 | +2. Switch to the release branch of the version to patch |
| 65 | + ``` |
| 66 | + git checkout r1.0 |
| 67 | + ``` |
| 68 | +3. Patch the code with your changes. For example, changes could be merged from another branch you |
| 69 | + were working on or be applied directly to this branch when the required changes are minimal. |
| 70 | +
|
| 71 | +4. Update the version of the Maven artifacts to the full version of the release |
| 72 | + ``` |
| 73 | + mvn versions:set -DnewVersion=1.0.1 |
| 74 | + ``` |
| 75 | +5. Update the NdArray Java Library version to reflect the new release at the following locations: |
| 76 | + - https://github.com/tensorflow/java-ndarray/blob/main/README.md#introduction |
| 77 | +
|
| 78 | +6. Commit the changes and push the branch to the GitHub repository |
| 79 | + ``` |
| 80 | + git add . |
| 81 | + git commit -m "Releasing 1.0.1" |
| 82 | + git push |
| 83 | + ``` |
| 84 | +
|
| 85 | +### Performing the release |
| 86 | +
|
| 87 | +1. At the root of your repository copy, create a Maven settings.xml file with your OSSRH credentials and |
| 88 | + your GPG key passphrase: |
| 89 | + ```sh |
| 90 | + SONATYPE_USERNAME="your_sonatype.org_username_here" |
| 91 | + SONATYPE_PASSWORD="your_sonatype.org_password_here" |
| 92 | + GPG_PASSPHRASE="your_gpg_passphrase_here" |
| 93 | + cat > settings.xml <<EOF |
| 94 | + <settings> |
| 95 | + <servers> |
| 96 | + <server> |
| 97 | + <id>ossrh</id> |
| 98 | + <username>${SONATYPE_USERNAME}</username> |
| 99 | + <password>${SONATYPE_PASSWORD}</password> |
| 100 | + </server> |
| 101 | + <server> |
| 102 | + <id>ossrh-staging</id> |
| 103 | + <username>${SONATYPE_USERNAME}</username> |
| 104 | + <password>${SONATYPE_PASSWORD}</password> |
| 105 | + </server> |
| 106 | + </servers> |
| 107 | + <profiles> |
| 108 | + <profile> |
| 109 | + <activation> |
| 110 | + <activeByDefault>true</activeByDefault> |
| 111 | + </activation> |
| 112 | + <properties> |
| 113 | + <gpg.executable>gpg2</gpg.executable> |
| 114 | + <gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase> |
| 115 | + </properties> |
| 116 | + </profile> |
| 117 | + <profiles> |
| 118 | + </settings> |
| 119 | + EOF |
| 120 | + ``` |
| 121 | +2. Execute the `release.sh` script. This will sign and deploy artifacts on OSS Sonatype. |
| 122 | +
|
| 123 | + On success, the released artifacts are uploaded to the private staging repository in OSS Sonatype (check at the Maven |
| 124 | + build output to know the exact location of the staging repository). After inspecting the artifacts in OSS Sonatype, you |
| 125 | + should release or drop them. |
| 126 | + |
| 127 | + Visit https://oss.sonatype.org/#stagingRepositories, find the `orgtensorflow-*` |
| 128 | + of your release and click `Close` and `Release` to finalize the release. You always have the option |
| 129 | + to `Drop` it to abort and restart if something went wrong. |
| 130 | +
|
| 131 | +3. Go to GitHub and create a release tag on the release branch with a summary of what the version includes. |
| 132 | +
|
| 133 | +Some things of note: |
| 134 | + - For details, look at the [Sonatype guide](http://central.sonatype.org/pages/releasing-the-deployment.html). |
| 135 | + - Syncing with [Maven Central](http://repo1.maven.org/maven2/org/tensorflow/) |
| 136 | + can take 10 minutes to 2 hours (as per the [OSSRH guide](http://central.sonatype.org/pages/ossrh-guide.html#releasing-to-central)). |
| 137 | +
|
| 138 | +### Finishing a release |
| 139 | +
|
| 140 | +#### Major or minor release |
| 141 | +
|
| 142 | +1. Checkout the main branch and merge back changes from the released branch |
| 143 | + ``` |
| 144 | + git checkout main |
| 145 | + git merge r1.0 |
| 146 | + ``` |
| 147 | +2. In your local copy, checkout the main branch and increase the next snapshot version. |
| 148 | + ``` |
| 149 | + mvn versions:set -DnewVersion=1.1.0-SNAPSHOT |
| 150 | + ``` |
| 151 | +3. Update the NdArray Java Library version to reflect the new release at the following locations: |
| 152 | + - https://github.com/tensorflow/java-ndarray/blob/main/README.md#introduction |
| 153 | +
|
| 154 | +4. Commit your changes and push the main branch to the GitHub repository |
| 155 | + ``` |
| 156 | + git add . |
| 157 | + git commit -m "Increase version for next iteration" |
| 158 | + git push |
| 159 | + ``` |
| 160 | +
|
| 161 | +#### Patch release |
| 162 | +
|
| 163 | +1. Checkout the main branch and merge back changes from the released branch, preserving current snapshot version |
| 164 | + ``` |
| 165 | + git checkout main |
| 166 | + git merge r1.0 |
| 167 | + ``` |
| 168 | +2. Commit the main and push the main branch to the GitHub repository |
| 169 | + ``` |
| 170 | + git add . |
| 171 | + git commit -m "Merge release 1.0.1" |
| 172 | + git push |
| 173 | + ``` |
| 174 | +
|
| 175 | +## References |
| 176 | +
|
| 177 | +- [Sonatype guide](http://central.sonatype.org/pages/ossrh-guide.html) for |
| 178 | + hosting releases. |
| 179 | +- [Ticket that created the `org/tensorflow` configuration](https://issues.sonatype.org/browse/OSSRH-28072) on OSSRH. |
0 commit comments