remove tensorflow-android deployment from java release script

tensorflow-android is deprecated in favor of TF Lite and will not see any new
releases.

This change also adds the ability to deploy tensorflow artifacts to the local
maven repository for testing. To use this:

DEPLOY_OSSRH=false DEPLOY_BINTRAY=false DEPLOY_LOCAL=true ./release.sh <version>
PiperOrigin-RevId: 259552290
This commit is contained in:
James Ring 2019-07-23 09:34:08 -07:00 committed by TensorFlower Gardener
parent bb27ef8604
commit 1fefe05424
4 changed files with 14 additions and 178 deletions

View File

@ -51,6 +51,7 @@ docker run \
-e TF_VERSION="${TF_VERSION}" \
-e DEPLOY_OSSRH="${DEPLOY_OSSRH:-true}" \
-e DEPLOY_BINTRAY="${DEPLOY_BINTRAY:-true}" \
-e DEPLOY_LOCAL="${DEPLOY_LOCAL:-false}" \
-v ${PWD}:/tensorflow \
-v "${SETTINGS_XML}":/root/.m2/settings.xml \
-v ${HOME}/.gnupg:/root/.gnupg \

View File

@ -25,10 +25,11 @@ TF_ECOSYSTEM_URL="https://github.com/tensorflow/ecosystem.git"
# environment variables can be set to skip either repository.
DEPLOY_BINTRAY="${DEPLOY_BINTRAY:-true}"
DEPLOY_OSSRH="${DEPLOY_OSSRH:-true}"
DEPLOY_LOCAL="${DEPLOY_LOCAL:-false}"
PROTOC_RELEASE_URL="https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip"
if [[ "${DEPLOY_BINTRAY}" != "true" && "${DEPLOY_OSSRH}" != "true" ]]; then
echo "Must deploy to at least one of Bintray or OSSRH" >&2
if [[ "${DEPLOY_BINTRAY}" != "true" && "${DEPLOY_OSSRH}" != "true" && "${DEPLOY_LOCAL}" != "true" ]]; then
echo "Must deploy to at least one of Bintray, OSSRH or local" >&2
exit 2
fi
@ -40,7 +41,7 @@ clean() {
# artifacts lying around)
mvn -q clean
rm -rf libtensorflow_jni/src libtensorflow_jni/target libtensorflow_jni_gpu/src libtensorflow_jni_gpu/target \
libtensorflow/src libtensorflow/target tensorflow-android/target proto/src proto/target \
libtensorflow/src libtensorflow/target proto/src proto/target \
tensorflow-hadoop/src tensorflow-hadoop/target spark-tensorflow-connector/src spark-tensorflow-connector/target
}
@ -71,17 +72,6 @@ download_libtensorflow() {
cd "${DIR}"
}
# Fetch the android aar artifact from the CI build system, and update
# its associated pom file.
update_tensorflow_android() {
TARGET_DIR="${DIR}/tensorflow-android/target"
mkdir -p "${TARGET_DIR}"
python "${DIR}/tensorflow-android/update.py" \
--version "${TF_VERSION}" \
--template "${DIR}/tensorflow-android/pom-android.xml.template" \
--dir "${TARGET_DIR}"
}
download_libtensorflow_jni() {
NATIVE_DIR="${DIR}/libtensorflow_jni/src/main/resources/org/tensorflow/native"
mkdir -p "${NATIVE_DIR}"
@ -211,19 +201,11 @@ download_tf_ecosystem() {
# n/a
deploy_profile() {
local profile="$1"
# Deploy the non-android pieces.
mvn deploy -P"${profile}"
# Determine the correct pom file property to use
# for the repository url.
local rtype
rtype='repository'
local url=$(mvn_property "${profile}" "project.distributionManagement.${rtype}.url")
local repositoryId=$(mvn_property "${profile}" "project.distributionManagement.${rtype}.id")
mvn gpg:sign-and-deploy-file \
-Dfile="${DIR}/tensorflow-android/target/tensorflow.aar" \
-DpomFile="${DIR}/tensorflow-android/target/pom-android.xml" \
-Durl="${url}" \
-DrepositoryId="${repositoryId}"
if [[ ${profile} == "local" ]]; then
mvn install
else
mvn deploy -P"${profile}"
fi
}
# If successfully built, try to deploy.
@ -232,6 +214,10 @@ deploy_profile() {
# ./release.sh ${TF_VERSION} ${SETTINGS_XML} bash
# To get a shell to poke around the maven artifacts with.
deploy_artifacts() {
# Deploy artifacts to local maven repository if requested
if [[ "${DEPLOY_LOCAL}" == "true" ]]; then
deploy_profile 'local'
fi
# Deploy artifacts to ossrh if requested.
if [[ "${DEPLOY_OSSRH}" == "true" ]]; then
deploy_profile 'ossrh'
@ -264,7 +250,6 @@ update_version_in_pom
download_libtensorflow
download_libtensorflow_jni
download_libtensorflow_jni_gpu
update_tensorflow_android
generate_java_protos
download_tf_ecosystem

View File

@ -1,27 +0,0 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-android</artifactId>
<version>${version}</version>
<packaging>aar</packaging>
<name>TensorFlow AAR for Android Inference Library and Java API</name>
<url>https://github.com/tensorflow/tensorflow/</url>
<parent>
<groupId>org.tensorflow</groupId>
<artifactId>parentpom</artifactId>
<version>${version}</version>
<relativePath>../</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.commitid>${build_commit_id}</project.build.commitid>
<project.build.type>${build_type}</project.build.type>
</properties>
</project>

View File

@ -1,123 +0,0 @@
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Fetch android artifacts and update pom properties."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import json
import string
import sys
import urllib2
def get_args():
"""Parse command line args."""
parser = argparse.ArgumentParser()
parser.add_argument(
'--version', required=True, help='Version for the artifact.')
parser.add_argument(
'--dir',
required=True,
help='Directory where the pom and aar artifact will be written.')
parser.add_argument(
'--template', required=True, help='Path to pom template file.')
return parser.parse_args()
def get_json(url):
"""Load the contents of the URL as a json object."""
return json.load(urllib2.urlopen(url))
def get_commit_id(build_info):
"""Fetch the git commit id from the build info json object."""
release_commit_id = build_info.get('build_commit_id')
if release_commit_id:
return release_commit_id
actions = build_info.get('actions')
build_data = next(
a for a in actions
if a.get('_class') == 'hudson.plugins.git.util.BuildData')
if not build_data:
raise ValueError('Missing BuildData: %s' % build_info)
revision_info = build_data.get('lastBuiltRevision')
if not revision_info:
raise ValueError('Missing lastBuiltRevision: %s' % build_info)
return revision_info.get('SHA1')
def get_aar_url(build_info):
"""Given the json build info, find the URL to the tensorflow.aar artifact."""
base_url = build_info.get('url')
if not base_url:
raise ValueError('Missing url: %s' % build_info)
build_class = build_info.get('_class')
if (build_class == 'hudson.model.FreeStyleBuild' or
build_class == 'hudson.matrix.MatrixRun'):
aar_info = next(
a for a in build_info.get('artifacts')
if a.get('fileName') == 'tensorflow.aar')
if not aar_info:
raise ValueError('Missing aar artifact: %s' % build_info)
return '%s/artifact/%s' % (base_url, aar_info.get('relativePath'))
raise ValueError('Unknown build_type %s' % build_info)
def read_template(path):
with open(path) as f:
return string.Template(f.read())
def main():
args = get_args()
release_prefix = 'https://storage.googleapis.com/tensorflow/libtensorflow'
info_url = '%s/android_buildinfo-%s.json' % (release_prefix, args.version)
aar_url = '%s/tensorflow-%s.aar' % (release_prefix, args.version)
build_type = 'release-android'
# Retrieve build information
build_info = get_json(info_url)
# Check all required build info is present
build_commit_id = get_commit_id(build_info)
if not build_commit_id:
raise ValueError('Missing commit id: %s' % build_info)
# Write the pom file updated with build attributes.
template = read_template(args.template)
with open('%s/pom-android.xml' % args.dir, 'w') as f:
f.write(
template.substitute({
'build_commit_id': build_commit_id,
'build_type': build_type,
'version': args.version
}))
# Retrieve the aar location if needed.
if not aar_url:
aar_url = get_aar_url(build_info)
# And download the aar to the desired location.
with open('%s/tensorflow.aar' % args.dir, 'w') as f:
aar = urllib2.urlopen(aar_url)
f.write(aar.read())
if __name__ == '__main__':
sys.exit(main())