1- # TensorFlow for Java using Maven
1+ # Releasing TensorFlow Java
22
33The
44[ TensorFlow Java API] ( https://github.com/tensorflow/java ) is available on Maven Central and JCenter
@@ -20,13 +20,13 @@ Hence, the process for building and uploading release artifacts is not a single
2020
2121## Release process overview
2222
23- The process of releasing TensorFlow for Java is splitted in two major steps:
24- * Build of the native artifacts
25- * Build and deployment of all artifacts consolidated
23+ The process of releasing TensorFlow Java is split in two major steps:
24+ * Building and deploying the native artifacts
25+ * Building and deploying all artifacts consolidated
2626
27- While the first step should be done on different servers, each configured for building the native
28- artifact for a specific architecture and platform, the second step is conducted locally in
29- a [ Docker] ( https://www.docker.com ) container for a more hermetic process.
27+ The first step is executed on different build servers, each responsible to build the native
28+ artifact for a specific architecture and platform. The second step is conducted locally in
29+ a [ Docker] ( https://www.docker.com ) container for a hermetic release process.
3030
3131### Pre-requisites
3232
@@ -36,7 +36,7 @@ a [Docker](https://www.docker.com) container for a more hermetic process.
3636 account does not have permissions, then you'll need to ask someone who does
3737 to [ file a ticket] ( https://issues.sonatype.org/ ) to add to the permissions
3838 ([ sample ticket] ( https://issues.sonatype.org/browse/MVNCENTRAL-1637 ) ).
39- - An account at [ bintray.com] ( https://bintray.com ) that has permissions to
39+ - Optionally, an account at [ bintray.com] ( https://bintray.com ) that has permissions to
4040 update the [ tensorflow repository] ( https://bintray.com/google/tensorflow ) .
4141 If your account does not have permissions, then you'll need to ask one of
4242 the [ organization administrators] ( https://bintray.com/google ) to give you
@@ -51,56 +51,82 @@ a [Docker](https://www.docker.com) container for a more hermetic process.
5151
5252#### Major or minor release
5353
54- 1 . Clone a clean version of the
54+ 1 . Get a clean version of the source code by cloning the
5555 [ TensorFlow Java GitHub repository] ( https://github.com/tensorflow-java )
56-
57- 2 . Switch to a new branch named to the version of the release (only major and minor digits), prefixed
58- by the letter ` r ` . For example, for releasing 1.0.0, ` git checkout -b ` r1.0`
59-
60- 3 . Update the version of the Maven artifacts in the branch to match the three-digit version of the
61- release. Normally, that should result in removing the suffix ` -SNAPSHOT ` of the actual version of
62- the master branch. This could be done using the Maven version plugin: ` mvn versions:use-releases `
63- (it is always possible to use ` mvn versions:set ` to force a specific version).
64-
65- 4 . Commit the changes and push the new branch to the GitHub repository.
56+ ```
57+ git clone https://github.com/tensorflow/java
58+ ```
59+ 2. Create a new branch for the release named `r<MajorVersion>.<MinorVersion>`
60+ ```
61+ git checkout -b r1.0
62+ ```
63+ 3. Update the version of the Maven artifacts to the full version of the release
64+ ```
65+ mvn versions:set -DnewVersion=1.0.0
66+ ```
67+ 4. Commit the changes and push the new branch to the GitHub repository
68+ ```
69+ git add .
70+ git commit -m "Releasing 1.0.0"
71+ git push --set-upstream upstream r1.0
72+ ```
6673
6774#### Patch release
6875
69- 1 . Clone a clean version of the
76+ 1. Get a clean version of the source code by cloning the
7077 [TensorFlow Java GitHub repository](https://github.com/tensorflow-java)
78+ ```
79+ git clone https://github.com/tensorflow/java
80+ ```
81+ 2. Switch to the release branch of the version to patch
82+ ```
83+ git checkout r1.0
84+ ```
85+ 3. Patch the code with your changes. For example, changes could be merged from another branch you
86+ were working on or be applied directly to this branch when the required changes are minimal.
7187
72- 2 . Switch to a release branch to patch. For example, for releasing 1.0.1, ` git checkout ` r1.0`
73-
74- 3 . Update the version of the Maven artifacts in the branch to match the three-digit version of the
75- patched release. Normally, that should result in increasing the last digit of the latest version.
76- This could be done using the Maven version plugin: ` mvn versions:use-next-releases `
77- (it is always possible to use ` mvn versions:set ` to force a specific version)
78-
79- 4 . Commit the changes and push the branch to the GitHub repository.
88+ 4. Update the version of the Maven artifacts to the full version of the release
89+ ```
90+ mvn versions:set -DnewVersion=1.0.1
91+ ```
92+ 4. Commit the changes and push the branch to the GitHub repository
93+ ```
94+ git add .
95+ git commit -m "Releasing 1.0.1"
96+ git push
97+ ```
8098
8199### Building native artifacts
82100
83101Once a release branch (i.e. a branch prefixed by `r`) is pushed on the repository, a workflow will
84- automatically start in GitHub Action to build the native artifacts for all supported
85- architures/platforms and upload them in a cloud storage for the next step (we use for actual cloud
86- storage is the 's3://tensorflow-java/staging' AWS S3 bucket).
102+ automatically start in GitHub Actions to build the native artifacts for all supported
103+ architures/platforms and deploy them temporarily on OSSRH for staging.
87104
88105There is no user action required for this step other than watching the progress of the GitHub
89- Action workflow and making sure that all steps have been completed successfully.
106+ Actions workflow and making sure that all steps have been completed successfully.
90107
91- ### Building and deploying all artifacts to Sonatype and Bintray
108+ #### Build native artifacts manually
109+
110+ Some platforms cannot be build successfully on GitHub Actions, due to some limits to their resources
111+ (e.g. max 6 hours for a job). For this reasons, we need to build manually some of our artifacts on
112+ private servers.
92113
93- 1 . Create a file with your OSSRH credentials and
94- [ Bintray API key ] ( https://bintray.com/docs/usermanual/interacting/interacting_interacting.html#anchorAPIKEY )
95- (or place it in your existing ` ~/.m2/settings.xml ` ):
114+ To do so, follow the same steps as the [CI build](https://github.com/tensorflow/java/.github/workflows/ci.yml)
115+ for the same platform and make sure to checkout the release branch and to provide your Sonatype credentials
116+ for temporary staging.
96117
118+ ### Building and deploying all artifacts to Sonatype and Bintray
119+
120+ 1. At the root of your TensorFlow Java copy, create a Maven settings.xml file with your OSSRH credentials and
121+ [Bintray API key](https://bintray.com/docs/usermanual/interacting/interacting_interacting.html#anchorAPIKEY),
122+ plus your GPG key passphrase:
97123 ```sh
98124 SONATYPE_USERNAME="your_sonatype.org_username_here"
99125 SONATYPE_PASSWORD="your_sonatype.org_password_here"
100126 BINTRAY_USERNAME="your_bintray_username_here"
101127 BINTRAY_API_KEY="your_bintray_api_key_here"
102128 GPG_PASSPHRASE="your_gpg_passphrase_here"
103- cat > /tmp/ settings.xml << EOF
129+ cat > settings.xml <<EOF
104130 <settings>
105131 <servers>
106132 <server>
@@ -128,13 +154,19 @@ Action workflow and making sure that all steps have been completed successfully.
128154 </settings>
129155 EOF
130156 ```
131-
132- 2. Run the ` release.sh` script. This will deploy only on OSSRH by default. To enable Bintray
133- deployment as well, pass the environment variable DEPLOY_BINTRAY=true.
134-
135- This script will fetch back all native artifacts previously uploaded in cloud storage by
136- the GitHub Action workflow so they can be signed and deployed with all the other artifacts.
137-
157+ 2. Execute the `release.sh` script. This will deploy only on OSSRH by default. To enable Bintray
158+ deployment as well, pass the environment variable DEPLOY_BINTRAY=true. All native artifacts
159+ previously temporarily staged by GitHub Actions will be fetched, signed and redeployed with
160+ all the other artifacts.
161+
162+ The script takes in paramater the sequence number of the staging repository created in OSSRH
163+ by the GitHub Actions workflow. You can retrieve this ID by looking in the staging repositories
164+ in OSSRH console directly, or check at the output of the step `Create Staging Repository` of the
165+ `prepare` job in the workflow execution, where the ID is printed.
166+ ```
167+ # Staging repository created: orgtensorflow-1100
168+ sh release.sh 1100
169+ ```
1381703. If the script above succeeds then the artifacts would have been uploaded to
139171 the private staging repository in Sonatype, and as unpublished artifacts in
140172 Bintray. After verifying the release, you should finalize or abort the
@@ -157,13 +189,30 @@ Action workflow and making sure that all steps have been completed successfully.
157189 - For Bintray details, refer to their guide on
158190 [managing uploaded content](https://bintray.com/docs/usermanual/uploads/uploads_managinguploadedcontent.html#_publishing).
159191
160- ### Skip deploying to a repository
192+ #### Skip deploying to a repository
161193
162194Should you need, setting environment variables `DEPLOY_OSSRH=false` or
163195`DEPLOY_BINTRAY=false` when calling `release.sh` will skip deploying to OSSRH or
164196Bintray respectively. Note that snapshots are only uploaded to OSSRH, so you
165197cannot skip deploying to OSSRH for a `-SNAPSHOT` version.
166198
199+ ### Finishing a release
200+
201+ Go to GitHub and create a release tag at the release branch with a summary of what the version includes.
202+
203+ #### Major or minor release
204+
205+ 1. In your local copy, checkout the master branch and increase the next snapshot version.
206+ ```
207+ mvn versions: set -DnewVersion=1.1.0-SNAPSHOT
208+ ```
209+ 2. Commit your changes and push the master branch to the GitHub repository
210+ ```
211+ git add .
212+ git commit -m "Increase version for next iteration"
213+ git push
214+ ```
215+
167216## References
168217
169218- [Sonatype guide](http://central.sonatype.org/pages/ossrh-guide.html) for
0 commit comments