This is an automated email from the ASF dual-hosted git repository. jiayu pushed a commit to branch add-release-script in repository https://gitbox.apache.org/repos/asf/sedona-spatialbench.git
commit 5b62e1fb03776187c3858b5fd265d7264912604e Author: Jia Yu <[email protected]> AuthorDate: Tue Nov 25 20:01:38 2025 -0800 Add release script --- dev/release/README.md | 142 +++++++++++++++++ dev/release/check-rat-report.py | 59 +++++++ dev/release/rat_exclude_files.txt | 11 ++ dev/release/run-rat.sh | 43 ++++++ dev/release/sign-assets.sh | 149 ++++++++++++++++++ dev/release/upload-candidate.sh | 84 ++++++++++ dev/release/upload-release.sh | 55 +++++++ dev/release/verify-release-candidate.sh | 262 ++++++++++++++++++++++++++++++++ 8 files changed, 805 insertions(+) diff --git a/dev/release/README.md b/dev/release/README.md new file mode 100644 index 0000000..745bc93 --- /dev/null +++ b/dev/release/README.md @@ -0,0 +1,142 @@ +<!--- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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. +--> + +# Releasing SpatialBench + +## Verifying a release candidate + +Release candidates are verified using the script `verify-release-candidate.sh <version> <rc_num>`. +For example, to verify SpatialBench 0.1.0 RC1, run: + +```shell +# git clone https://github.com/apache/sedona-spatialbench.git && cd sedona-spatialbench +# or +# cd existing/sedona-spatialbench && git fetch upstream && git switch main && git pull upstream main +dev/release/verify-release-candidate.sh 0.1.0 1 +``` + +Release verification requires a recent Rust toolchain. This toolchain can be installed +by following instructions from <https://rustup.rs/>. + +When verifying via Docker or on a smaller machine it may be necessary to limit the +number of parallel jobs to avoid running out of memory: + +```shell +export CARGO_BUILD_JOBS=4 +``` + +## Creating a release + +Create a release branch on the corresponding remote pointing to the official Apache +repository (i.e., <https://github.com/apache/sedona-spatialbench>). This step must be done by +a committer. + +```shell +git pull upstream main +git branch -b branch-0.1.0 +git push upstream -u branch-0.1.0:branch-0.1.0 +``` + +Before creating a tag, download the tarball from the latest packaging run and +check it locally: + +```shell +dev/release/verify-release-candidate.sh path/to/tarball.tar.gz +``` + +When the state of the `branch-x.x.x` branch is clean and checks are complete, +the release candidate tag can be created: + +```shell +git tag -a sedona-spatialbench-0.1.0-rc1 -m "Tag Apache SpatialBench 0.1.0-rc1" +git push upstream sedona-spatialbench-0.1.0-rc1 +``` + +This will trigger another packaging CI run that, if successful, will create a +pre-release at <https://github.com/apache/sedona-spatialbench/releases> with the release +artifacts uploaded from the CI run. + +After the release has been created with the appropriate artifacts, the assets +need to be signed with signatures uploaded as release assets. Please create +dev/release/.env from dev/release/.env.example and set the GPG_KEY_ID variable. +The GPG_KEY_ID in dev/release/.env must have its public component listed in the +[Apache Sedona KEYS file](https://dist.apache.org/repos/dist/dev/sedona/KEYS). + +```shell +# sign-assets.sh <version> <rc_number> +dev/release/sign-assets.sh 0.1.0 1 +``` + +After the assets are signed, they can be committed and uploaded to the +dev/sedona directory of the Apache distribution SVN. A helper script +is provided: + +```shell +# upload-candidate.sh <version> <rc_number> +APACHE_USERNAME=your_apache_username dev/release/upload-candidate.sh 0.1.0 1 +``` + +## Vote + +An email must now be sent to `[email protected]` calling on developers to follow +the release verification instructions and vote appropriately on the source release. + +## Publish + +### Upload/tag source release + +After a successful release vote, the tarball needs to be uploaded to the official +Apache release repository. A helper script is provided: + +```shell +# upload-release.sh <version> <rc_number> +APACHE_USERNAME=your_apache_username dev/release/upload-release.sh 0.1.0 1 +``` + +An official GitHub tag must also be created: + +```shell +git tag -a sedona-spatialbench-0.1.0 -m "SpatialBench 0.1.0" sedona-spatialbench-0.1.0-rc1 +git push upstream sedona-spatialbench-0.1.0 +``` + +The prerelease located at <https://github.com/apache/sedona-spatialbench/releases/tag/sedona-spatialbench-0.1.0-rc1> +can now be edited to point to the official release tag and the GitHub release published +from the UI. + +## Bump versions + +After a successful release, versions on the `main` branch need to be updated. These +are currently all derived from `Cargo.toml`, which can be updated to: + +``` +[workspace.package] +version = "0.2.0" +``` + +Development versions and the changelog are derived from the presence of a development +tag on the main branch signifying where development of that version "started". After +the version bump PR merges, that commit should be tagged with the appropriate +development tag: + +```shell +git tag -a sedona-spatialbench-0.2.0.dev -m "tag dev 0.2.0" +git push upstream sedona-spatialbench-0.2.0.dev +``` + diff --git a/dev/release/check-rat-report.py b/dev/release/check-rat-report.py new file mode 100644 index 0000000..b9fd85a --- /dev/null +++ b/dev/release/check-rat-report.py @@ -0,0 +1,59 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 fnmatch +import re +import sys +import xml.etree.ElementTree as ET + +if len(sys.argv) != 3: + sys.stderr.write("Usage: %s exclude_globs.lst rat_report.xml\n" % sys.argv[0]) + sys.exit(1) + +exclude_globs_filename = sys.argv[1] +xml_filename = sys.argv[2] + +globs = [line.strip() for line in open(exclude_globs_filename, "r")] + +tree = ET.parse(xml_filename) +root = tree.getroot() +resources = root.findall("resource") + +all_ok = True +for r in resources: + approvals = r.findall("license-approval") + if not approvals or approvals[0].attrib["name"] == "true": + continue + clean_name = re.sub("^[^/]+/", "", r.attrib["name"]) + excluded = False + for g in globs: + if fnmatch.fnmatch(clean_name, g): + excluded = True + break + if not excluded: + sys.stdout.write( + "NOT APPROVED: %s (%s): %s\n" + % (clean_name, r.attrib["name"], approvals[0].attrib["name"]) + ) + all_ok = False + +if not all_ok: + sys.exit(1) + +print("OK") +sys.exit(0) + diff --git a/dev/release/rat_exclude_files.txt b/dev/release/rat_exclude_files.txt new file mode 100644 index 0000000..c3a17d7 --- /dev/null +++ b/dev/release/rat_exclude_files.txt @@ -0,0 +1,11 @@ +Cargo.lock +*.ipynb +*.json +*.svg +site/** +docs-overrides/** +raster/output/** +spatialbench/data/sf-v1/*.tbl.gz +spatialbench/data/sf-v1/*.parquet +dev/release/rat_exclude_files.txt + diff --git a/dev/release/run-rat.sh b/dev/release/run-rat.sh new file mode 100755 index 0000000..78eba22 --- /dev/null +++ b/dev/release/run-rat.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +RAT_VERSION=0.13 + +# download apache rat +if [ ! -f apache-rat-${RAT_VERSION}.jar ]; then + curl -s https://repo1.maven.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar > apache-rat-${RAT_VERSION}.jar +fi + +RAT="java -jar apache-rat-${RAT_VERSION}.jar -x " + +RELEASE_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd) + +# generate the rat report +$RAT $1 > rat.txt +python $RELEASE_DIR/check-rat-report.py $RELEASE_DIR/rat_exclude_files.txt rat.txt > filtered_rat.txt +cat filtered_rat.txt +UNAPPROVED=`cat filtered_rat.txt | grep "NOT APPROVED" | wc -l` + +if [ "0" -eq "${UNAPPROVED}" ]; then + echo "No unapproved licenses" +else + echo "${UNAPPROVED} unapproved licences. Check rat report: rat.txt" + exit 1 +fi + diff --git a/dev/release/sign-assets.sh b/dev/release/sign-assets.sh new file mode 100755 index 0000000..18f56c8 --- /dev/null +++ b/dev/release/sign-assets.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -eu + +main() { + local -r source_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + local -r source_top_dir="$( cd "${source_dir}/../../" && pwd )" + pushd "${source_top_dir}" + + if [ "$#" -ne 2 ]; then + echo "Usage: $0 <version> <rc-num>" + exit 1 + fi + + local -r version="$1" + local -r rc_number="$2" + local -r tag="sedona-spatialbench-${version}-rc${rc_number}" + local -r tarball="apache-sedona-spatialbench-${version}" + + : ${REPOSITORY:="apache/sedona-spatialbench"} + + if [[ ! -f "${source_dir}/.env" ]]; then + echo "You must create ${source_dir}/.env" + echo "You can use ${source_dir}/.env.example as a template" + fi + + source "${source_dir}/.env" + + header "Looking for GitHub Actions workflow on ${REPOSITORY}:${tag}" + local run_id="" + while [[ -z "${run_id}" ]] + do + echo "Waiting for run to start..." + run_id=$(gh run list \ + --repo "${REPOSITORY}" \ + --workflow=packaging \ + --json 'databaseId,event,headBranch,status' \ + --jq ".[] | select(.event == \"push\" and .headBranch == \"${tag}\") | .databaseId" | \ + head -n 1) + sleep 1 + done + + header "Found GitHub Actions workflow with ID: ${run_id}" + gh run watch --repo "${REPOSITORY}" --exit-status ${run_id} + gh run view --repo "${REPOSITORY}" "${run_id}" + + header "Downloading assets from release" + local -r download_dir="packages/${tag}" + mkdir -p "${download_dir}" + gh release download \ + "${tag}" \ + --repo "${REPOSITORY}" \ + --dir "${download_dir}" \ + --skip-existing + + header "Upload signatures for source" + upload_asset_signatures "${tag}" $(find "${download_dir}" -type f \( -name 'apache-sedona-spatialbench-*.tar.gz' \)) + + header "Upload signatures for docs" + upload_asset_signatures "${tag}" "${download_dir}/docs.tgz" + + popd +} + +header() { + echo "============================================================" + echo "${1}" + echo "============================================================" +} + +sign_asset() { + local -r asset="$1" + local -r sigfile="${asset}.asc" + + if [[ -f "${sigfile}" ]]; then + if env LANG=C gpg --verify "${sigfile}" "${asset}" >/dev/null 2>&1; then + echo "Valid signature at $(basename "${sigfile}"), skipping" + return + fi + rm "${sigfile}" + fi + + gpg \ + --armor \ + --detach-sign \ + --local-user "${GPG_KEY_ID}" \ + --output "${sigfile}" \ + "${asset}" + echo "Generated $(basename "${sigfile}")" +} + +sum_asset() { + local -r asset="$1" + local -r sumfile="${asset}.sha512" + + local -r digest=$(cd $(dirname "${asset}"); shasum --algorithm 512 $(basename "${asset}")) + if [[ -f "${sumfile}" ]]; then + if [[ "${digest}" = $(cat "${sumfile}") ]]; then + echo "Valid digest at $(basename "${sumfile}"), skipping" + return + fi + fi + + echo "${digest}" > "${sumfile}" + echo "Generated $(basename "${sumfile}")" +} + +upload_asset_signatures() { + local -r tag="${1}" + shift 1 + + local -r assets=("$@") + + for asset in "${assets[@]}"; do + sign_asset "${asset}" + sum_asset "${asset}" + done + + gh release upload \ + --repo "${REPOSITORY}" \ + "${tag}" \ + "${assets[@]/%/.asc}" \ + "${assets[@]/%/.sha512}" + + # Clean up + for asset in "${assets[@]}"; do + rm -f "${asset}" "${asset}.asc" "${asset}.sha512" + done +} + +main "$@" + diff --git a/dev/release/upload-candidate.sh b/dev/release/upload-candidate.sh new file mode 100755 index 0000000..bffba60 --- /dev/null +++ b/dev/release/upload-candidate.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + + +set -eu + +main() { + local -r source_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + local -r source_top_dir="$( cd "${source_dir}/../../" && pwd )" + + if [ "$#" -ne 2 ]; then + echo "Usage: $0 <version> <rc-num>" + exit 1 + fi + local -r version="$1" + local -r rc_number="$2" + local -r tag="sedona-spatialbench-${version}-rc${rc_number}" + local -r tarball="apache-sedona-spatialbench-${version}.tar.gz" + + : ${REPOSITORY:="apache/sedona-spatialbench"} + + if [[ ! -f "${source_dir}/.env" ]]; then + echo "You must create ${source_dir}/.env" + echo "You can use ${source_dir}/.env.example as a template" + fi + + source "${source_dir}/.env" + + header "Downloading assets from release" + local -r download_dir="packages/${tag}" + mkdir -p "${download_dir}" + gh release download \ + "${tag}" \ + --dir "${download_dir}" \ + --pattern "${tarball}*" \ + --repo "${REPOSITORY}" \ + --skip-existing + + echo "Uploading to dist.apache.org" + + # check out the sedona RC folder + svn co --depth=empty https://dist.apache.org/repos/dist/dev/sedona tmp + + # add the release candidate for the tag + mkdir -p "tmp/${tag}" + + # copy the rc tarball into the tmp dir + cp ${download_dir}/${tarball}* "tmp/${tag}" + + # commit to svn + svn add "tmp/${tag}" + svn ci --username=$APACHE_USERNAME -m "Apache SpatialBench ${version} RC${rc_number}" "tmp/${tag}" + + # clean up + rm -rf tmp + rm -rf "${download_dir}" + + echo "Uploaded at https://dist.apache.org/repos/dist/dev/sedona/${tag}" +} + +header() { + echo "============================================================" + echo "${1}" + echo "============================================================" +} + +main "$@" + diff --git a/dev/release/upload-release.sh b/dev/release/upload-release.sh new file mode 100755 index 0000000..71bf530 --- /dev/null +++ b/dev/release/upload-release.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -eu + +main() { + local -r source_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + if [ "$#" -ne 2 ]; then + echo "Usage: $0 <version> <rc-num>" + exit 1 + fi + local -r version="$1" + local -r rc_number="$2" + local -r tag="sedona-spatialbench-${version}-rc${rc_number}" + + if [[ ! -f "${source_dir}/.env" ]]; then + echo "You must create ${source_dir}/.env" + echo "You can use ${source_dir}/.env.example as a template" + fi + + source "${source_dir}/.env" + + rc_id="sedona-spatialbench-${version}-rc${rc_number}" + release_id="apache-sedona-spatialbench-${version}" + echo "Moving dev/ to release/" + svn \ + mv \ + --username=$APACHE_USERNAME \ + -m "Apache SpatialBench ${version}" \ + https://dist.apache.org/repos/dist/dev/sedona/${rc_id} \ + https://dist.apache.org/repos/dist/release/sedona/${release_id} + + echo "Success! The release is available here:" + echo " https://dist.apache.org/repos/dist/release/sedona/${release_id}" +} + +main "$@" + diff --git a/dev/release/verify-release-candidate.sh b/dev/release/verify-release-candidate.sh new file mode 100755 index 0000000..4a55d9b --- /dev/null +++ b/dev/release/verify-release-candidate.sh @@ -0,0 +1,262 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +set -e +set -o pipefail + +if [ ${VERBOSE:-0} -gt 0 ]; then + set -x +fi + +# Check that required dependencies are installed +check_dependencies() { + local missing_deps=0 + + local required_deps=("curl" "git" "gpg" "cargo") + for dep in "${required_deps[@]}"; do + if ! command -v $dep &> /dev/null; then + echo "Error: $dep is not installed or not in PATH" + missing_deps=1 + fi + done + + # Check for either shasum or sha256sum/sha512sum + local has_sha_tools=0 + if command -v shasum &> /dev/null; then + has_sha_tools=1 + elif command -v sha256sum &> /dev/null && command -v sha512sum &> /dev/null; then + has_sha_tools=1 + else + echo "Error: Neither shasum nor sha256sum/sha512sum are installed or in PATH" + missing_deps=1 + fi + + if [ $missing_deps -ne 0 ]; then + echo "Please install missing dependencies and try again" + echo "Rust toolchain can be installed from https://rustup.rs/" + exit 1 + fi +} + +case $# in + 0) VERSION="HEAD" + SOURCE_KIND="local" + ;; + 1) VERSION="TARBALL" + SOURCE_KIND="local_tarball" + LOCAL_TARBALL="$(realpath $1)" + ;; + 2) VERSION="$1" + RC_NUMBER="$2" + SOURCE_KIND="tarball" + ;; + *) echo "Usage:" + echo " Verify release candidate:" + echo " $0 X.Y.Z RC_NUMBER" + echo "" + echo " Run the source verification tasks on this spatialbench checkout:" + echo " $0" + exit 1 + ;; +esac + +# Check dependencies early +check_dependencies + +# Note that these point to the current verify-release-candidate.sh directories +# which is different from the SPATIALBENCH_SOURCE_DIR set in ensure_source_directory() +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" +SPATIALBENCH_DIR="$(cd "${SOURCE_DIR}/../.." && pwd)" + +show_header() { + if [ -z "$GITHUB_ACTIONS" ]; then + echo "" + printf '=%.0s' $(seq ${#1}); printf '\n' + echo "${1}" + printf '=%.0s' $(seq ${#1}); printf '\n' + else + echo "::group::${1}"; printf '\n' + fi +} + +show_info() { + echo "└ ${1}" +} + +SPATIALBENCH_DIST_URL='https://dist.apache.org/repos/dist/dev/sedona' + +download_dist_file() { + curl \ + --silent \ + --show-error \ + --fail \ + --location \ + --remote-name $SPATIALBENCH_DIST_URL/$1 +} + +download_rc_file() { + download_dist_file sedona-spatialbench-${VERSION}-rc${RC_NUMBER}/$1 +} + +import_gpg_keys() { + if [ "${GPGKEYS_ALREADY_IMPORTED:-0}" -gt 0 ]; then + return 0 + fi + download_dist_file KEYS + + if [ "${SPATIALBENCH_ACCEPT_IMPORT_GPG_KEYS_ERROR:-0}" -gt 0 ]; then + gpg --import KEYS || true + else + gpg --import KEYS + fi + + GPGKEYS_ALREADY_IMPORTED=1 +} + +if type shasum >/dev/null 2>&1; then + sha512_verify="shasum -a 512 -c" +else + sha512_verify="sha512sum -c" +fi + +fetch_archive() { + import_gpg_keys + + local dist_name=$1 + download_rc_file ${dist_name}.tar.gz + download_rc_file ${dist_name}.tar.gz.asc + download_rc_file ${dist_name}.tar.gz.sha512 + gpg --verify ${dist_name}.tar.gz.asc ${dist_name}.tar.gz + ${sha512_verify} ${dist_name}.tar.gz.sha512 +} + +verify_dir_artifact_signatures() { + import_gpg_keys + + # verify the signature and the checksums of each artifact + find $1 -name '*.asc' | while read sigfile; do + artifact=${sigfile/.asc/} + gpg --verify $sigfile $artifact || exit 1 + + # go into the directory because the checksum files contain only the + # basename of the artifact + pushd $(dirname $artifact) + base_artifact=$(basename $artifact) + if [ -f $base_artifact.sha512 ]; then + ${sha512_verify} $base_artifact.sha512 || exit 1 + fi + popd + done +} + +setup_tempdir() { + cleanup() { + if [ "${TEST_SUCCESS}" = "yes" ]; then + rm -fr "${SPATIALBENCH_TMPDIR}" + else + echo "Failed to verify release candidate. See ${SPATIALBENCH_TMPDIR} for details." + fi + } + + show_header "Creating temporary directory" + + if [ -z "${SPATIALBENCH_TMPDIR}" ]; then + # clean up automatically if SPATIALBENCH_TMPDIR is not defined + SPATIALBENCH_TMPDIR=$(mktemp -d -t "spatialbench-${VERSION}.XXXXXX") + trap cleanup EXIT + else + # don't clean up automatically + mkdir -p "${SPATIALBENCH_TMPDIR}" + fi + + echo "Working in sandbox ${SPATIALBENCH_TMPDIR}" +} + +test_rust() { + show_header "Build and test Rust libraries" + + pushd "${SPATIALBENCH_SOURCE_DIR}" + cargo test --workspace + popd +} + +ensure_source_directory() { + show_header "Ensuring source directory" + + dist_name="apache-sedona-spatialbench-${VERSION}" + + if [ "${SOURCE_KIND}" = "local" ]; then + # Local repository + if [ -z "$SPATIALBENCH_SOURCE_DIR" ]; then + export SPATIALBENCH_SOURCE_DIR="${SPATIALBENCH_DIR}" + fi + echo "Verifying local spatialbench checkout at ${SPATIALBENCH_SOURCE_DIR}" + elif [ "${SOURCE_KIND}" = "local_tarball" ]; then + # Local tarball + pushd $SPATIALBENCH_TMPDIR + tar xf "$LOCAL_TARBALL" + dist_name=$(ls) + export SPATIALBENCH_SOURCE_DIR="${SPATIALBENCH_TMPDIR}/${dist_name}" + + popd + + echo "Verifying local tarball at $LOCAL_TARBALL" + else + # Release tarball + echo "Verifying official SpatialBench release candidate ${VERSION}-rc${RC_NUMBER}" + export SPATIALBENCH_SOURCE_DIR="${SPATIALBENCH_TMPDIR}/${dist_name}" + if [ ! -d "${SPATIALBENCH_SOURCE_DIR}" ]; then + pushd $SPATIALBENCH_TMPDIR + fetch_archive ${dist_name} + tar xf ${dist_name}.tar.gz + + popd + fi + fi +} + +test_source_distribution() { + pushd $SPATIALBENCH_SOURCE_DIR + + if [ ${TEST_RUST} -gt 0 ]; then + test_rust + fi + + popd +} + +# By default test all functionalities. +# To deactivate one test, deactivate the test and all of its dependents +# To explicitly select one test, set TEST_DEFAULT=0 TEST_X=1 +: ${TEST_DEFAULT:=1} + +: ${TEST_SOURCE:=${TEST_DEFAULT}} +: ${TEST_RUST:=${TEST_SOURCE}} + +TEST_SUCCESS=no + +setup_tempdir +ensure_source_directory +test_source_distribution + +TEST_SUCCESS=yes + +echo "Release candidate ${VERSION}-RC${RC_NUMBER} looks good!" +exit 0 +
