Skip to content

Commit

Permalink
chore(dev/release): decouple version numbers (apache#1762)
Browse files Browse the repository at this point in the history
Start refactoring our release process so that we can theoretically
handle different version numbers in different language subprojects.

Fixes apache#1490.

---------

Co-authored-by: Sutou Kouhei <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
  • Loading branch information
3 people authored and cocoa-xu committed May 8, 2024
1 parent a6a3be3 commit 8bec518
Show file tree
Hide file tree
Showing 20 changed files with 423 additions and 378 deletions.
99 changes: 36 additions & 63 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,51 +74,22 @@ jobs:
git fetch --tags --force origin
- name: Prepare version
id: version
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
VERSION=${GITHUB_REF_NAME#apache-arrow-adbc-}
VERSION=${VERSION%-rc*}
else
VERSION=$(grep 'set(ADBC_VERSION' c/cmake_modules/AdbcVersion.cmake | \
grep -E -o '[0-9]+\.[0-9]+\.[0-9]+')
description=$(git describe \
--always \
--dirty \
--long \
--match "apache-arrow-adbc-[0-9]*.*" \
--tags)
case "${description}" in
# apache-arrow-adbc-0.1.0-10-1234567-dirty
apache-arrow-adbc-*)
# 10-1234567-dirty
distance="${description#apache-arrow-adbc-*.*.*-}"
# 10-1234567
distance="${distance%-dirty}"
# 10
distance="${distance%-*}"
;;
*)
distance=$(git log --format=oneline | wc -l)
;;
esac
VERSION="${VERSION}.dev${distance}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
source dev/release/versions.env
echo "VERSION=${RELEASE}" | tee -a $GITHUB_ENV
- name: Create archive
run: |
ci/scripts/source_build.sh \
apache-arrow-adbc-${{ steps.version.outputs.VERSION }} \
apache-arrow-adbc-${VERSION} \
$(git log -n 1 --format=%h)
- uses: actions/upload-artifact@v4
with:
name: source
retention-days: 7
path: |
apache-arrow-adbc-${{ steps.version.outputs.VERSION }}.tar.gz
apache-arrow-adbc-*.tar.gz
go-binaries:
name: "Go ${{ matrix.os }}"
Expand Down Expand Up @@ -235,13 +206,11 @@ jobs:
name: source

- name: Extract source archive
id: version
run: |
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "VERSION=${VERSION}" | tee -a $GITHUB_ENV
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
Expand All @@ -256,7 +225,7 @@ jobs:
run: |
pushd adbc
docker compose run \
-e SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.version.outputs.VERSION }} \
-e SETUPTOOLS_SCM_PRETEND_VERSION=$VERSION \
docs
popd
Expand Down Expand Up @@ -340,7 +309,6 @@ jobs:
path: arrow

- name: Set output variables
id: info
run: |
echo "ARROW_SOURCE=$(pwd)/arrow" >> $GITHUB_ENV
case ${{ matrix.target }} in
Expand All @@ -359,14 +327,16 @@ jobs:
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "VERSION=${VERSION}" | tee -a $GITHUB_ENV
- name: Extract source archive
run: |
tar xf apache-arrow-adbc-${{ steps.info.outputs.VERSION }}.tar.gz
mv apache-arrow-adbc-${{ steps.info.outputs.VERSION }} adbc
mv apache-arrow-adbc-${{ steps.info.outputs.VERSION }}.tar.gz adbc/ci/linux-packages/
tar xf apache-arrow-adbc-$VERSION.tar.gz
source ./apache-arrow-adbc-$VERSION/dev/release/versions.env
mv apache-arrow-adbc-$VERSION adbc
mv apache-arrow-adbc-$VERSION.tar.gz adbc/ci/linux-packages/
- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -469,8 +439,7 @@ jobs:
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "VERSION=${VERSION}" | tee -a $GITHUB_ENV
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
Expand Down Expand Up @@ -536,11 +505,10 @@ jobs:
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "VERSION=${VERSION}" | tee -a $GITHUB_ENV
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
tar xf apache-arrow-adbc-$VERSION.tar.gz
mv apache-arrow-adbc-$VERSION adbc
- name: Show inputs
run: |
Expand Down Expand Up @@ -590,7 +558,8 @@ jobs:
strategy:
fail-fast: false
matrix:
arch: ["amd64", "arm64v8"]
# XXX(lidavidm): disable arm64 build for now while I test things
arch: ["amd64"]
manylinux_version: ["2014"]
is_pr:
- ${{ startsWith(github.ref, 'refs/pull/') }}
Expand All @@ -609,12 +578,13 @@ jobs:
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
source adbc/dev/release/versions.env
echo "VERSION=${VERSION_NATIVE}" | tee -a $GITHUB_ENV
- name: Show inputs
run: |
echo "upload_artifacts: ${{ github.event.inputs.upload_artifacts }}" >> $GITHUB_STEP_SUMMARY
Expand All @@ -631,7 +601,7 @@ jobs:
run: |
pushd adbc
docker compose run \
-e SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.version.outputs.VERSION }} \
-e SETUPTOOLS_SCM_PRETEND_VERSION=$VERSION \
python-wheel-manylinux
popd
Expand Down Expand Up @@ -717,12 +687,14 @@ jobs:
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION}" >> $GITHUB_ENV
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
source adbc/dev/release/versions.env
echo "VERSION=${VERSION_NATIVE}" | tee -a $GITHUB_ENV
echo "SETUPTOOLS_SCM_PRETEND_VERSION=${VERSION_NATIVE}" | tee -a $GITHUB_ENV
- name: Show inputs
run: |
echo "upload_artifacts: ${{ github.event.inputs.upload_artifacts }}" >> $GITHUB_STEP_SUMMARY
Expand All @@ -737,13 +709,13 @@ jobs:
run: |
pushd adbc
vcpkg_version=$(cat ".env" | grep "VCPKG" | cut -d "=" -f2 | tr -d '"')
echo "VCPKG_VERSION=$vcpkg_version" >> "$GITHUB_OUTPUT"
echo "VCPKG_VERSION=$vcpkg_version" | tee -a "$GITHUB_ENV"
popd
- name: Install vcpkg
run: |
pushd adbc
ci/scripts/install_vcpkg.sh $VCPKG_ROOT ${{ steps.vcpkg_version.outputs.VCPKG_VERSION }}
ci/scripts/install_vcpkg.sh $VCPKG_ROOT $VCPKG_VERSION
popd
- uses: actions/setup-go@v5
Expand Down Expand Up @@ -868,12 +840,13 @@ jobs:
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
source adbc/dev/release/versions.env
echo "VERSION=${VERSION_NATIVE}" | tee -a $GITHUB_ENV
(. adbc/.env && echo "GO_VERSION=${GO}") >> $GITHUB_ENV
- name: Show inputs
Expand Down Expand Up @@ -961,17 +934,17 @@ jobs:
name: source

- name: Extract source archive
id: version
run: |
source_archive=$(echo apache-arrow-adbc-*.tar.gz)
VERSION=${source_archive#apache-arrow-adbc-}
VERSION=${VERSION%.tar.gz}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
tar xf apache-arrow-adbc-${VERSION}.tar.gz
mv apache-arrow-adbc-${VERSION} adbc
source adbc/dev/release/versions.env
echo "VERSION=${VERSION_NATIVE}" | tee -a $GITHUB_ENV
- name: Show inputs
run: |
echo "upload_artifacts: ${{ github.event.inputs.upload_artifacts }}"
Expand All @@ -982,7 +955,7 @@ jobs:
run: |
pushd adbc
docker compose run \
-e SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.version.outputs.VERSION }} \
-e SETUPTOOLS_SCM_PRETEND_VERSION=$VERSION \
python-sdist
popd
Expand Down
13 changes: 9 additions & 4 deletions ci/linux-packages/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ module Helper
version_env = ENV["VERSION"]
return version_env if version_env

meson_build = top_source_dir / "c" / "cmake_modules" / "AdbcVersion.cmake"
version = meson_build.read.scan(/ADBC_VERSION "(.+?)"/)[0][0]
formatted_release_time = release_time.strftime("%Y%m%d")
version.gsub(/-SNAPSHOT\z/) {"-dev#{formatted_release_time}"}
versions_env = top_source_dir / "dev" / "release" / "versions.env"
version = versions_env.read[/RELEASE="(.+?)"/, 1]
adbc_version_cmake = top_source_dir / "c" / "cmake_modules" / "AdbcVersion.cmake"
native_version = adbc_version_cmake.read[/ADBC_VERSION "(.+?)"/, 1]
if native_version.end_with?("-SNAPSHOT")
formatted_release_time = release_time.strftime("%Y%m%d")
version += "-dev#{formatted_release_time}"
end
version
end

def detect_release_time
Expand Down
89 changes: 45 additions & 44 deletions dev/release/01-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,61 @@
set -ue

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

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"
exit 1
fi
main() {
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <arrow-dir> <rc_num>"
echo "Usage: $0 ../arrow 0"
exit 1
fi

. $SOURCE_DIR/utils-prepare.sh
local -r arrow_dir="$1"
local -r rc_number="$2"
local -r release_candidate_tag="apache-arrow-adbc-${RELEASE}-rc${rc_number}"

arrow_dir=$1
prev_version=$2
version=$3
next_version=$4
next_version_snapshot="${next_version}-SNAPSHOT"
rc_number=$5
export ARROW_SOURCE="$(cd "${arrow_dir}" && pwd)"

export ARROW_SOURCE="$(cd "${arrow_dir}" && pwd)"
if [[ $(git tag -l "${release_candidate_tag}") ]]; then
local -r next_rc_number=$(($rc_number+1))
echo "Tag ${release_candidate_tag} already exists, so create a new release candidate:"
echo "1. Create or checkout maint-<version>."
echo "2. Execute the script again with bumped RC number."
echo "Commands:"
echo " git checkout maint-${RELEASE}"
echo " dev/release/01-prepare.sh ${arrow_dir} ${next_rc_number}"
exit 1
fi

release_candidate_tag="apache-arrow-adbc-${version}-rc${rc_number}"
############################## Pre-Tag Commits ##############################

if [[ $(git tag -l "${release_candidate_tag}") ]]; then
next_rc_number=$(($rc_number+1))
echo "Tag ${release_candidate_tag} already exists, so create a new release candidate:"
echo "1. Create or checkout maint-<version>."
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}"
exit 1
fi
header "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 ${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 ${RELEASE}"

############################## Pre-Tag Commits ##############################
header "Prepare release ${RELEASE} on tag ${release_candidate_tag}"

echo "Updating changelog for $version"
# 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})"
) >> ${SOURCE_DIR}/../../CHANGELOG.md
git add ${SOURCE_DIR}/../../CHANGELOG.md
git commit -m "chore: update CHANGELOG.md for $version"
update_versions "release"
# --allow-empty required for RCs after the first
git commit -m "chore: update versions for ${RELEASE}" --allow-empty

echo "Prepare release ${version} on tag ${release_candidate_tag}"
######################### Tag the Release Candidate #########################

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

######################### Tag the Release Candidate #########################
git tag -a "${release_candidate_tag}" -m "ADBC Libraries ${RELEASE} RC ${rc_number}"

git tag -a "${release_candidate_tag}" -m "ADBC Libraries ${version} RC ${rc_number}"
echo "Created release candidate tag: ${release_candidate_tag}"
echo "Push this tag before continuing!"
}

echo "Created release candidate tag: ${release_candidate_tag}"
echo "Push this tag before continuing!"
main "$@"
Loading

0 comments on commit 8bec518

Please sign in to comment.