Skip to content

Commit

Permalink
chore(dev/release): decouple version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
lidavidm committed Apr 25, 2024
1 parent cd60c0e commit 051d886
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 44 deletions.
36 changes: 16 additions & 20 deletions dev/release/01-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,22 @@
#
set -ue

SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ "$#" -ne 5 ]; then
echo "Usage: $0 <arrow-dir> <prev_veresion> <version> <next_version> <rc-num>"
echo "Usage: $0 ../arrow 0.1.0 0.2.0 0.3.0 0"
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <arrow-dir> <rc_num>"
echo "Usage: $0 ../arrow 0"
exit 1
fi

. $SOURCE_DIR/utils-prepare.sh
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source $SOURCE_DIR/utils-prepare.sh

arrow_dir=$1
prev_version=$2
version=$3
next_version=$4
next_version_snapshot="${next_version}-SNAPSHOT"
rc_number=$5
rc_number=$2

export ARROW_SOURCE="$(cd "${arrow_dir}" && pwd)"

release_candidate_tag="apache-arrow-adbc-${version}-rc${rc_number}"
release_candidate_tag="apache-arrow-adbc-${RELEASE}-rc${rc_number}"

if [[ $(git tag -l "${release_candidate_tag}") ]]; then
next_rc_number=$(($rc_number+1))
Expand All @@ -47,33 +43,33 @@ if [[ $(git tag -l "${release_candidate_tag}") ]]; then
echo "2. Execute the script again with bumped RC number."
echo "Commands:"
echo " git checkout maint-${version}"
echo " dev/release/01-prepare.sh ${version} ${next_version} ${next_rc_number}"
echo " dev/release/01-prepare.sh ${arrow_dir} ${next_rc_number}"
exit 1
fi

############################## Pre-Tag Commits ##############################

echo "Updating changelog for $version"
echo "Updating changelog for ${RELEASE}"
# Update changelog
# XXX: commitizen doesn't respect --tag-format with --incremental, so mimic
# it by hand.
(
echo ;
# Strip trailing blank line
printf '%s\n' "$(cz ch --dry-run --unreleased-version "ADBC Libraries ${version}" --start-rev apache-arrow-adbc-${prev_version})"
printf '%s\n' "$(cz ch --dry-run --unreleased-version "ADBC Libraries ${RELEASE}" --start-rev apache-arrow-adbc-${PREVIOUS_RELEASE})"
) >> ${SOURCE_DIR}/../../CHANGELOG.md
git add ${SOURCE_DIR}/../../CHANGELOG.md
git commit -m "chore: update CHANGELOG.md for $version"
git commit -m "chore: update CHANGELOG.md for ${RELEASE}"

echo "Prepare release ${version} on tag ${release_candidate_tag}"
echo "Prepare release ${RELEASE} on tag ${release_candidate_tag}"

update_versions "${version}" "${next_version}" "release"
update_versions "release"
# --allow-empty required for RCs after the first
git commit -m "chore: update versions for ${version}" --allow-empty
git commit -m "chore: update versions for ${RELEASE}" --allow-empty

######################### Tag the Release Candidate #########################

git tag -a "${release_candidate_tag}" -m "ADBC Libraries ${version} RC ${rc_number}"
git tag -a "${release_candidate_tag}" -m "ADBC Libraries ${RELEASE} RC ${rc_number}"

echo "Created release candidate tag: ${release_candidate_tag}"
echo "Push this tag before continuing!"
23 changes: 23 additions & 0 deletions dev/release/utils-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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.

header() {
echo "============================================================"
echo "${1}"
echo "============================================================"
}
70 changes: 46 additions & 24 deletions dev/release/utils-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,54 @@
# under the License.

ADBC_DIR="${SOURCE_DIR}/../.."
source "${SOURCE_DIR}/utils-common.sh"
source "${SOURCE_DIR}/versions.env"

update_versions() {
local base_version=$1
local next_version=$2
local type=$3
local type=$1

local conda_version="${VERSION_NATIVE}"
local csharp_version="${VERSION_CSHARP}"
local rust_version="${VERSION_CSHARP}"
case ${type} in
release)
local version=${base_version}
local conda_version=${base_version}
local docs_version=${base_version}
local py_version=${base_version}
local r_version=${base_version}
local cmake_version="${VERSION_NATIVE}"
local docs_version="${RELEASE}"
local glib_version="${VERSION_GLIB}"
local java_version="${VERSION_JAVA}"
local linux_version="${VERSION_NATIVE}"
local py_version="${VERSION_NATIVE}"
local r_version="${VERSION_R}"
;;
snapshot)
local version=${next_version}-SNAPSHOT
local conda_version=${next_version}
local docs_version="${next_version} (dev)"
local py_version="${next_version}dev"
local r_version="${base_version}.9000"
local cmake_version="${VERSION_NATIVE}-SNAPSHOT"
local docs_version="${RELEASE} (dev)"
local glib_version="${VERSION_GLIB}-SNAPSHOT"
local java_version="${VERSION_JAVA}-SNAPSHOT"
local linux_version="${VERSION_NATIVE}-SNAPSHOT"
local py_version="${VERSION_NATIVE}dev"
local r_version="${VERSION_R}.9000"
;;
*)
echo "Unknown type: ${type}"
exit 1
;;
esac
local major_version=${version%%.*}

header "Updating versions for release ${RELEASE}"
echo "CMake: ${cmake_version}"
echo "Conda: ${conda_version}"
echo "C#: ${csharp_version}"
echo "Docs: ${docs_version}"
echo "GLib/Ruby: ${glib_version}"
echo "Java: ${java_version}"
echo "Linux: ${linux_version}"
echo "Python: ${py_version}"
echo "R: ${r_version}"
echo "Rust: ${rust_version}"

pushd "${ADBC_DIR}/c/"
sed -i.bak -E "s/set\(ADBC_VERSION \".+\"\)/set(ADBC_VERSION \"${version}\")/g" cmake_modules/AdbcVersion.cmake
sed -i.bak -E "s/set\(ADBC_VERSION \".+\"\)/set(ADBC_VERSION \"${cmake_version}\")/g" cmake_modules/AdbcVersion.cmake
rm cmake_modules/AdbcVersion.cmake.bak
git add cmake_modules/AdbcVersion.cmake
popd
Expand All @@ -52,7 +74,7 @@ update_versions() {
git add meta.yaml
popd

sed -i.bak -E "s|<Version>.+</Version>|<Version>${version}</Version>|" "${ADBC_DIR}/csharp/Directory.Build.props"
sed -i.bak -E "s|<Version>.+</Version>|<Version>${csharp_version}</Version>|" "${ADBC_DIR}/csharp/Directory.Build.props"
rm "${ADBC_DIR}/csharp/Directory.Build.props.bak"
git add "${ADBC_DIR}/csharp/Directory.Build.props"

Expand All @@ -61,22 +83,22 @@ update_versions() {
git add "${ADBC_DIR}/docs/source/conf.py"

pushd "${ADBC_DIR}/java/"
mvn versions:set "-DnewVersion=${version}" '-DoldVersion=*'
mvn -B versions:set "-DnewVersion=${java_version}" '-DoldVersion=*'
find . -type f -name pom.xml.versionsBackup -delete
sed -i.bak -E "s|<adbc\\.version>.+</adbc\\.version>|<adbc.version>${version}</adbc.version>|g" pom.xml
sed -i.bak -E "s|<adbc\\.version>.+</adbc\\.version>|<adbc.version>${java_version}</adbc.version>|g" pom.xml
rm pom.xml.bak
git add "pom.xml" "**/pom.xml"
popd

sed -i.bak -E "s/version: '.+'/version: '${version}'/g" "${ADBC_DIR}/glib/meson.build"
sed -i.bak -E "s/version: '.+'/version: '${glib_version}'/g" "${ADBC_DIR}/glib/meson.build"
rm "${ADBC_DIR}/glib/meson.build.bak"
git add "${ADBC_DIR}/glib/meson.build"

sed -i.bak -E "s/version = \".+\"/version = \"${py_version}\"/g" "${ADBC_DIR}"/python/adbc_*/adbc_*/_static_version.py
rm "${ADBC_DIR}"/python/adbc_*/adbc_*/_static_version.py.bak
git add "${ADBC_DIR}"/python/adbc_*/adbc_*/_static_version.py

sed -i.bak -E "s/VERSION = \".+\"/VERSION = \"${version}\"/g" "${ADBC_DIR}/ruby/lib/adbc/version.rb"
sed -i.bak -E "s/VERSION = \".+\"/VERSION = \"${glib_version}\"/g" "${ADBC_DIR}/ruby/lib/adbc/version.rb"
rm "${ADBC_DIR}/ruby/lib/adbc/version.rb.bak"
git add "${ADBC_DIR}/ruby/lib/adbc/version.rb"

Expand All @@ -86,20 +108,20 @@ update_versions() {
git add "${desc_file}"
done

sed -i.bak -E "s/^version = \".+\"/version = \"${version}\"/" "${ADBC_DIR}/rust/Cargo.toml"
sed -i.bak -E "s/^version = \".+\"/version = \"${rust_version}\"/" "${ADBC_DIR}/rust/Cargo.toml"
rm "${ADBC_DIR}/rust/Cargo.toml.bak"
git add "${ADBC_DIR}/rust/Cargo.toml"

if [ ${type} = "release" ]; then
pushd "${ADBC_DIR}/ci/linux-packages"
rake version:update VERSION=${version}
rake version:update VERSION=${linux_version}
git add debian*/changelog yum/*.spec.in
popd
else
so_version() {
local -r version=$1
local -r major_version=$(echo $version | sed -E -e 's/^([0-9]+)\.[0-9]+\.[0-9]+$/\1/')
local -r minor_version=$(echo $version | sed -E -e 's/^[0-9]+\.([0-9]+)\.[0-9]+$/\1/')
local -r major_version=$(echo $linux_version | sed -E -e 's/^([0-9]+)\.[0-9]+\.[0-9]+$/\1/')
local -r minor_version=$(echo $linux_version | sed -E -e 's/^[0-9]+\.([0-9]+)\.[0-9]+$/\1/')
printf "%0d%02d" ${major_version} ${minor_version}
}
local -r deb_lib_suffix=$(so_version ${base_version})
Expand Down
32 changes: 32 additions & 0 deletions dev/release/versions.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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.

# The release as a whole has a date-based identifier. This is used to
# identify tags, branches, and so on.
RELEASE="2024.05"
PREVIOUS_RELEASE="0.11.0"

# Individual components will have a SemVer.
VERSION_CSHARP="0.12.0"
VERSION_GLIB="1.0.0"
VERSION_JAVA="0.12.0"
# Because C++/Go/Python are effectively tied at the hip, they share a single
# version number. Also covers Conda/Linux packages.
# TODO: untie this so that we can have independent version #s for different drivers (at least for Postgres/SQLite)
VERSION_NATIVE="1.0.0"
VERSION_R="0.12.0"
VERSION_RUST="0.12.0"

0 comments on commit 051d886

Please sign in to comment.