|
| 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} |
0 commit comments