Skip to content

Commit c973a50

Browse files
authored
Add release tools (#21)
1 parent a34996c commit c973a50

File tree

8 files changed

+309
-7
lines changed

8 files changed

+309
-7
lines changed

dev/build-wheels.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ set -e -x
1919
dev/lint-python.sh -s py_env
2020

2121
PY_ENV_DIR=`pwd`/dev/.conda/envs
22-
py_env=("3.8" "3.9" "3.10" "3.11")
22+
# Don't need to build with different Python version when there are no C-related codes
23+
py_env=("3.11")
2324
## 2. install dependency
2425
for ((i=0;i<${#py_env[@]};i++)) do
2526
echo "Installing dependencies for environment: ${py_env[i]}"

dev/lint-python.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ function check_stage() {
571571
#########################
572572
# Tox check
573573
function tox_check() {
574-
LATEST_PYTHON="py311"
575574
print_function "STAGE" "tox checks"
576575
# Set created py-env in $PATH for tox's creating virtual env
577576
activate
@@ -581,11 +580,11 @@ function tox_check() {
581580
# tox runs codes in virtual env, set var to avoid error
582581
export _PYPAIMON_TOX_TEST="true"
583582

584-
if [[ ${BUILD_REASON} = 'IndividualCI' ]]; then
585-
# Only run test in latest python version triggered by a Git push
586-
$TOX_PATH -vv -c $PAIMON_PYTHON_DIR/tox.ini -e ${LATEST_PYTHON} --recreate 2>&1 | tee -a $LOG_FILE
583+
if [[ -n "$GITHUB_ACTION" ]]; then
584+
# Run tests in all versions triggered by a Git push (tests aren't so many currently)
585+
$TOX_PATH -vv -c $PAIMON_PYTHON_DIR/tox.ini --recreate 2>&1 | tee -a $LOG_FILE
587586
else
588-
# Only run random selected python version in nightly CI.
587+
# Only run random selected python version at local.
589588
ENV_LIST_STRING=`$TOX_PATH -l -c $PAIMON_PYTHON_DIR/tox.ini`
590589
_OLD_IFS=$IFS
591590
IFS=$'\n'

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import os
2121
import shutil
2222
import setup_utils.java_setuputils as java_setuputils
23+
import setup_utils.version
2324

2425
from setuptools import Command, setup
2526

@@ -72,7 +73,7 @@ def run(self):
7273

7374
setup(
7475
name='paimon_python',
75-
version='0.1.0.dev0',
76+
version=setup_utils.version.__version__,
7677
packages=PACKAGES,
7778
include_package_data=True,
7879
package_data=PACKAGE_DATA,

setup_utils/version.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
"""
20+
.. seealso:: https://www.python.org/dev/peps/pep-0440
21+
"""
22+
__version__ = "0.1.dev0"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
##
21+
## Required variables
22+
##
23+
RELEASE_VERSION=${RELEASE_VERSION}
24+
25+
if [ -z "${RELEASE_VERSION}" ]; then
26+
echo "RELEASE_VERSION was not set"
27+
exit 1
28+
fi
29+
30+
# fail immediately
31+
set -o errexit
32+
set -o nounset
33+
34+
CURR_DIR=`pwd`
35+
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
36+
PROJECT_ROOT="${BASE_DIR}/../../"
37+
38+
# Sanity check to ensure that resolved paths are valid; a LICENSE file should always exist in project root
39+
if [ ! -f ${PROJECT_ROOT}/LICENSE ]; then
40+
echo "Project root path ${PROJECT_ROOT} is not valid; script may be in the wrong directory."
41+
exit 1
42+
fi
43+
44+
if [ "$(uname)" == "Darwin" ]; then
45+
SHASUM="shasum -a 512"
46+
else
47+
SHASUM="sha512sum"
48+
fi
49+
50+
###########################
51+
52+
RELEASE_DIR=${PROJECT_ROOT}/release/binary
53+
rm -rf ${RELEASE_DIR}
54+
mkdir -p ${RELEASE_DIR}
55+
56+
# use lint-python.sh script to create a python environment.
57+
dev/lint-python.sh -s basic
58+
source dev/.conda/bin/activate
59+
60+
# build
61+
dev/build-wheels.sh
62+
63+
WHEEL_FILE_NAME="paimon_python-${RELEASE_VERSION}-py3-none-any.whl"
64+
WHEEL_FILE="${RELEASE_DIR}/${WHEEL_FILE_NAME}"
65+
cp "dist/${WHEEL_FILE_NAME}" ${WHEEL_FILE}
66+
67+
# Sign sha the wheel package
68+
gpg --armor --detach-sig ${WHEEL_FILE}
69+
$SHASUM ${WHEEL_FILE} > "${WHEEL_FILE}.sha512"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
##
21+
## Variables with defaults (if not overwritten by environment)
22+
##
23+
RELEASE_CANDIDATE=${RELEASE_CANDIDATE:-none}
24+
25+
##
26+
## Required variables
27+
##
28+
RELEASE_VERSION=${RELEASE_VERSION}
29+
30+
if [ -z "${RELEASE_VERSION}" ]; then
31+
echo "RELEASE_VERSION was not set"
32+
exit 1
33+
fi
34+
35+
# fail immediately
36+
set -o errexit
37+
set -o nounset
38+
39+
CURR_DIR=`pwd`
40+
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
41+
PROJECT_ROOT="${BASE_DIR}/../../"
42+
43+
# Sanity check to ensure that resolved paths are valid; a LICENSE file should always exist in project root
44+
if [ ! -f ${PROJECT_ROOT}/LICENSE ]; then
45+
echo "Project root path ${PROJECT_ROOT} is not valid; script may be in the wrong directory."
46+
exit 1
47+
fi
48+
49+
###########################
50+
51+
TARGET_BRANCH=release-${RELEASE_VERSION}
52+
if [ "${RELEASE_CANDIDATE}" != "none" ]; then
53+
TARGET_BRANCH=${TARGET_BRANCH}-rc${RELEASE_CANDIDATE}
54+
fi
55+
56+
cd ${PROJECT_ROOT}
57+
git checkout -b ${TARGET_BRANCH}
58+
59+
RELEASE_COMMIT_HASH=`git rev-parse HEAD`
60+
echo "Done. Created a new release branch with commit hash ${RELEASE_COMMIT_HASH}."
61+
62+
cd ${CURR_DIR}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
##
21+
## Required variables
22+
##
23+
RELEASE_VERSION=${RELEASE_VERSION}
24+
25+
if [ -z "${RELEASE_VERSION}" ]; then
26+
echo "RELEASE_VERSION is unset"
27+
exit 1
28+
fi
29+
30+
# fail immediately
31+
set -o errexit
32+
set -o nounset
33+
34+
CURR_DIR=`pwd`
35+
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
36+
PROJECT_ROOT="$( cd "$( dirname "${BASE_DIR}/../../../" )" >/dev/null && pwd )"
37+
38+
# Sanity check to ensure that resolved paths are valid; a LICENSE file should always exist in project root
39+
if [ ! -f ${PROJECT_ROOT}/LICENSE ]; then
40+
echo "Project root path ${PROJECT_ROOT} is not valid; script may be in the wrong directory."
41+
exit 1
42+
fi
43+
44+
if [ "$(uname)" == "Darwin" ]; then
45+
SHASUM="shasum -a 512"
46+
TAR="tar --no-xattrs"
47+
else
48+
SHASUM="sha512sum"
49+
TAR="tar"
50+
fi
51+
52+
###########################
53+
54+
RELEASE_DIR=${PROJECT_ROOT}/release/source
55+
CLONE_DIR=${RELEASE_DIR}/paimon-tmp-clone
56+
57+
rm -rf ${RELEASE_DIR}
58+
mkdir -p ${RELEASE_DIR}
59+
60+
# delete the temporary release directory on error
61+
trap 'rm -rf ${RELEASE_DIR}' ERR
62+
63+
echo "Creating source package"
64+
65+
# create a temporary git clone to ensure that we have a pristine source release
66+
git clone ${PROJECT_ROOT} ${CLONE_DIR}
67+
68+
cd ${CLONE_DIR}
69+
JAVA_ROOT="paimon_python_java/paimon-python-java-bridge"
70+
rsync -a \
71+
--exclude ".DS_Store" --exclude ".asf.yaml" --exclude ".git" \
72+
--exclude ".github" --exclude ".gitignore" --exclude ".idea" \
73+
--exclude ".mypy_cache" --exclude ".tox" --exclude "__pycache__" \
74+
--exclude "build" --exclude "dist" --exclude "*.egg-info" \
75+
--exclude "dev/.conda" --exclude "dev/.stage.txt" \
76+
--exclude "dev/download" --exclude "dev/log" --exclude "**/__pycache__" \
77+
--exclude "${JAVA_ROOT}/dependency-reduced-pom.xml" \
78+
--exclude "${JAVA_ROOT}/target" \
79+
. paimon-python-${RELEASE_VERSION}
80+
81+
TAR czf ${RELEASE_DIR}/apache-paimon-python-${RELEASE_VERSION}-src.tgz paimon-python-${RELEASE_VERSION}
82+
gpg --armor --detach-sig ${RELEASE_DIR}/apache-paimon-python-${RELEASE_VERSION}-src.tgz
83+
cd ${RELEASE_DIR}
84+
${SHASUM} apache-paimon-python-${RELEASE_VERSION}-src.tgz > apache-paimon-python-${RELEASE_VERSION}-src.tgz.sha512
85+
86+
rm -rf ${CLONE_DIR}
87+
88+
echo "Done. Source release package and signatures created under ${RELEASE_DIR}/."
89+
90+
cd ${CURR_DIR}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
##
21+
## Required variables
22+
##
23+
NEW_VERSION=${NEW_VERSION}
24+
25+
if [ -z "${NEW_VERSION}" ]; then
26+
echo "NEW_VERSION was not set."
27+
exit 1
28+
fi
29+
30+
# fail immediately
31+
set -o errexit
32+
set -o nounset
33+
34+
CURR_DIR=`pwd`
35+
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
36+
PROJECT_ROOT="${BASE_DIR}/../../"
37+
SETUP_UTILS_DIR="${PROJECT_ROOT}/setup_utils"
38+
39+
# Sanity check to ensure that resolved paths are valid; a LICENSE file should always exist in project root
40+
if [ ! -f ${PROJECT_ROOT}/LICENSE ]; then
41+
echo "Project root path ${PROJECT_ROOT} is not valid; script may be in the wrong directory."
42+
exit 1
43+
fi
44+
45+
###########################
46+
47+
cd ${SETUP_UTILS_DIR}/
48+
49+
# change version
50+
perl -pi -e "s#^__version__ = \".*\"#__version__ = \"${NEW_VERSION}\"#" version.py
51+
git commit -am "[release] Update version to ${NEW_VERSION}"
52+
53+
NEW_VERSION_COMMIT_HASH=`git rev-parse HEAD`
54+
55+
echo "Done. Created a new commit for the new version ${NEW_VERSION}, with hash ${NEW_VERSION_COMMIT_HASH}"
56+
echo "If this is a new version to be released (or a candidate to be voted on), don't forget to create a signed release tag on GitHub and push the changes."
57+
58+
cd ${CURR_DIR}

0 commit comments

Comments
 (0)