Unverified Commit bd0f990d authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Merge pull request #3337 from NervanaSystems/silee2/release_script

NGCORE-526
parents f23a86aa 97af44b5
......@@ -40,8 +40,9 @@ include(var_functions)
NGRAPH_GET_VERSION_LABEL()
string(REGEX MATCH "([0-9?]+)\\.([0-9?]+)\\.([0-9?]+)(-rc\\.[0-9?]+)?" NGRAPH_VERSION_SHORT "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "([0-9?]+)\\.([0-9?]+)\\.([0-9?]+)(-(rc|dev)\\.[0-9?]+)?" NGRAPH_VERSION_SHORT "${NGRAPH_VERSION_LABEL}")
string(REGEX REPLACE "-rc." "rc" NGRAPH_WHEEL_VERSION "${NGRAPH_VERSION_SHORT}")
string(REGEX REPLACE "-dev." "dev" NGRAPH_WHEEL_VERSION "${NGRAPH_WHEEL_VERSION}")
string(REGEX MATCH "([0-9?]+)\\.([0-9?]+)" NGRAPH_API_VERSION "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "[^v](.*)" NGRAPH_VERSION "${NGRAPH_VERSION_LABEL}")
string(REPLACE "." ";" NGRAPH_VERSION_PARTS "${NGRAPH_VERSION_SHORT}")
......
......@@ -23,6 +23,9 @@ function(NGRAPH_GET_CURRENT_HASH)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
ERROR_QUIET)
if(NOT HASH)
return()
endif()
string(STRIP ${HASH} HASH)
set(NGRAPH_CURRENT_HASH ${HASH} PARENT_SCOPE)
endfunction()
......@@ -75,7 +78,14 @@ function(NGRAPH_GET_VERSION_LABEL)
if (NOT ${NGRAPH_MOST_RECENT_RELEASE_TAG} STREQUAL "")
set(NGRAPH_VERSION_LABEL "${NGRAPH_MOST_RECENT_RELEASE_TAG}+${HASH}" PARENT_SCOPE)
else()
set(NGRAPH_VERSION_LABEL "?.?.?+${HASH}" PARENT_SCOPE)
if(HASH)
set(NGRAPH_VERSION_LABEL "?.?.?+${HASH}" PARENT_SCOPE)
else()
# Not in a git repo
file(READ ${CMAKE_SOURCE_DIR}/TAG NGRAPH_TAG)
string(STRIP ${NGRAPH_TAG} NGRAPH_TAG)
set(NGRAPH_VERSION_LABEL "${NGRAPH_TAG}" PARENT_SCOPE)
endif()
endif()
endif()
endfunction()
# ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# 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.
# ******************************************************************************
import sys
import os
import subprocess
import tempfile
import tarfile
import zipfile
assert sys.version_info >= (3, 4)
swd = os.path.dirname(os.path.realpath(__file__))
swd = swd + '/..'
swd = os.path.realpath(swd)
get_tag = subprocess.Popen(['git', 'describe', '--tags', '--abbrev=0', '--match', 'v*.*.*'],
cwd=swd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
tag = [line.strip().decode() for line in get_tag.stdout.readlines()]
retval = get_tag.wait()
get_files = subprocess.Popen(['git', 'ls-tree', '-r', 'HEAD', '--name-only'],
cwd=swd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
files = [line.strip().decode() for line in get_files.stdout.readlines()]
retval = get_files.wait()
# create tarball for Linux and macOS
with tarfile.open(swd + '/ngraph-' + tag[0] + '.tar.gz', 'w:gz') as tar:
for f in files:
file_path = swd + '/' + f
tar.add(file_path, arcname='ngraph-' + tag[0][1:] + '/' + f)
with tempfile.NamedTemporaryFile() as tag_file:
tag_line = tag[0] + '\n'
tag_file.write(tag_line.encode())
tag_file.flush()
tar.add(tag_file.name, arcname='ngraph-' + tag[0][1:] + '/TAG')
# create zipfile for Windows
TO = b'\r\n'
FROM = b'\n'
with zipfile.ZipFile(swd + '/ngraph-' + tag[0] + '.zip', 'w', zipfile.ZIP_DEFLATED) as zipf:
for f in files:
with open(file_path, 'rb') as unix_file:
win_content = unix_file.read().replace(FROM, TO)
with tempfile.NamedTemporaryFile() as win_file:
win_file.write(win_content)
zipf.write(win_file.name, arcname='ngraph-' + tag[0][1:] + '/' + f)
with tempfile.NamedTemporaryFile() as tag_file:
tag_line = tag[0] + '\r\n'
tag_file.write(tag_line.encode())
tag_file.flush()
zipf.write(tag_file.name, arcname='ngraph-' + tag[0][1:] + '/TAG')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment