diff --git a/dev/release/post-12-bump-versions-test.rb b/dev/release/post-12-bump-versions-test.rb
index 3fac1819d722c..60fd1096ce0ab 100644
--- a/dev/release/post-12-bump-versions-test.rb
+++ b/dev/release/post-12-bump-versions-test.rb
@@ -42,6 +42,23 @@ def bump_type
(data || {})[:bump_type]
end
+ def released_version
+ return @release_version if bump_type.nil?
+
+ previous_version_components = @previous_version.split(".")
+ case bump_type
+ when :minor
+ previous_version_components[1].succ!
+ when :patch
+ previous_version_components[2].succ!
+ end
+ previous_version_components.join(".")
+ end
+
+ def released_compatible_version
+ compute_compatible_version(released_version)
+ end
+
def bump_versions(*targets)
if targets.last.is_a?(Hash)
additional_env = targets.pop
@@ -55,159 +72,70 @@ def bump_versions(*targets)
env = env.merge(additional_env)
case bump_type
when :minor, :patch
- previous_version_components = @previous_version.split(".")
- case bump_type
- when :minor
- previous_version_components[1].succ!
- when :patch
- previous_version_components[2].succ!
- end
sh(env,
"dev/release/post-12-bump-versions.sh",
- previous_version_components.join("."),
+ released_version,
@release_version)
else
sh(env,
"dev/release/post-12-bump-versions.sh",
- @release_version,
+ released_version,
@next_version)
end
end
- data(:next_release_type, [:major, :minor, :patch])
+ data("X.0.0 -> X.0.1", {next_release_type: :patch})
+ data("X.0.0 -> X.1.0", {next_release_type: :minor})
+ data("X.0.0 -> ${X+1}.0.0", {next_release_type: :major})
+ data("X.0.1 -> ${X+1}.0.0", {bump_type: :patch})
+ data("X.1.0 -> ${X+1}.0.0", {bump_type: :minor})
def test_version_post_tag
omit_on_release_branch
- expected_changes = [
- {
- path: "c_glib/meson.build",
- hunks: [
- ["-version = '#{@snapshot_version}'",
- "+version = '#{@next_snapshot_version}'"],
- ],
- },
- {
- path: "c_glib/vcpkg.json",
- hunks: [
- ["- \"version-string\": \"#{@snapshot_version}\",",
- "+ \"version-string\": \"#{@next_snapshot_version}\","],
- ],
- },
- {
- path: "ci/scripts/PKGBUILD",
- hunks: [
- ["-pkgver=#{@previous_version}.9000",
- "+pkgver=#{@release_version}.9000"],
- ],
- },
- {
- path: "cpp/CMakeLists.txt",
- hunks: [
- ["-set(ARROW_VERSION \"#{@snapshot_version}\")",
- "+set(ARROW_VERSION \"#{@next_snapshot_version}\")"],
- ],
- },
- {
- path: "cpp/vcpkg.json",
- hunks: [
- ["- \"version-string\": \"#{@snapshot_version}\",",
- "+ \"version-string\": \"#{@next_snapshot_version}\","],
- ],
- },
- {
- path: "csharp/Directory.Build.props",
- hunks: [
- ["- #{@snapshot_version}",
- "+ #{@next_snapshot_version}"],
- ],
- },
- {
- path: "dev/tasks/homebrew-formulae/apache-arrow-glib.rb",
- hunks: [
- ["- url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@snapshot_version}/apache-arrow-#{@snapshot_version}.tar.gz\"",
- "+ url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@next_snapshot_version}/apache-arrow-#{@next_snapshot_version}.tar.gz\""],
- ],
- },
- {
- path: "dev/tasks/homebrew-formulae/apache-arrow.rb",
- hunks: [
- ["- url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@snapshot_version}/apache-arrow-#{@snapshot_version}.tar.gz\"",
- "+ url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@next_snapshot_version}/apache-arrow-#{@next_snapshot_version}.tar.gz\""],
- ],
- },
- ]
- unless next_release_type == :patch
- expected_changes += [
+ case bump_type
+ when :patch, :minor
+ expected_changes = [
{
- path: "docs/source/_static/versions.json",
+ path: "ci/scripts/PKGBUILD",
hunks: [
- [
- "- \"name\": \"#{@release_compatible_version} (dev)\",",
- "+ \"name\": \"#{@next_compatible_version} (dev)\",",
- "- \"name\": \"#{@previous_compatible_version} (stable)\",",
- "+ \"name\": \"#{@release_compatible_version} (stable)\",",
- "+ {",
- "+ \"name\": \"#{@previous_compatible_version}\",",
- "+ \"version\": \"#{@previous_compatible_version}/\",",
- "+ \"url\": \"https://arrow.apache.org/docs/#{@previous_compatible_version}/\"",
- "+ },",
- ],
+ ["-pkgver=#{@previous_version}.9000",
+ "+pkgver=#{released_version}.9000"],
],
},
]
- end
- expected_changes += [
- {
- path: "js/package.json",
- hunks: [
- ["- \"version\": \"#{@snapshot_version}\"",
- "+ \"version\": \"#{@next_snapshot_version}\""],
- ],
- },
- {
- path: "matlab/CMakeLists.txt",
- hunks: [
- ["-set(MLARROW_VERSION \"#{@snapshot_version}\")",
- "+set(MLARROW_VERSION \"#{@next_snapshot_version}\")"],
- ],
- },
- {
- path: "python/CMakeLists.txt",
- hunks: [
- ["-set(PYARROW_VERSION \"#{@snapshot_version}\")",
- "+set(PYARROW_VERSION \"#{@next_snapshot_version}\")"],
- ],
- },
- {
- path: "python/pyproject.toml",
- hunks: [
- ["-fallback_version = '#{@release_version}a0'",
- "+fallback_version = '#{@next_version}a0'"],
- ],
- },
- {
- path: "r/DESCRIPTION",
- hunks: [
- ["-Version: #{@previous_version}.9000",
- "+Version: #{@release_version}.9000"],
- ],
- },
- {
- path: "r/NEWS.md",
- hunks: [
- ["-# arrow #{@previous_version}.9000",
- "+# arrow #{@release_version}.9000",
- "+",
- "+# arrow #{@release_version}",],
- ],
- },
- ]
- if next_release_type == :major
+ if bump_type == :minor
+ expected_changes += [
+ {
+ path: "docs/source/_static/versions.json",
+ hunks: [
+ [
+ "- \"name\": \"#{@previous_compatible_version} (stable)\",",
+ "+ \"name\": \"#{released_compatible_version} (stable)\",",
+ "+ {",
+ "+ \"name\": \"#{@previous_compatible_version}\",",
+ "+ \"version\": \"#{@previous_compatible_version}/\",",
+ "+ \"url\": \"https://arrow.apache.org/docs/#{@previous_compatible_version}/\"",
+ "+ },",
+ ],
+ ],
+ },
+ ]
+ end
expected_changes += [
{
- path: "c_glib/tool/generate-version-header.py",
+ path: "r/DESCRIPTION",
+ hunks: [
+ ["-Version: #{@previous_version}.9000",
+ "+Version: #{released_version}.9000"],
+ ],
+ },
+ {
+ path: "r/NEWS.md",
hunks: [
- ["+ (#{@next_major_version}, 0),"],
+ ["-# arrow #{@previous_version}.9000",
+ "+# arrow #{released_version}.9000",
+ "+",
+ "+# arrow #{released_version}",],
],
},
{
@@ -216,9 +144,8 @@ def test_version_post_tag
[
"-
#{@previous_version}.9000 (dev)
",
"-#{@previous_r_version} (release)
",
- "+#{@release_version}.9000 (dev)
",
- "+#{@release_version} (release)
",
- "+#{@previous_r_version}
",
+ "+#{released_version}.9000 (dev)
",
+ "+#{released_version} (release)
",
],
],
},
@@ -227,73 +154,231 @@ def test_version_post_tag
hunks: [
[
"- \"name\": \"#{@previous_version}.9000 (dev)\",",
- "+ \"name\": \"#{@release_version}.9000 (dev)\",",
+ "+ \"name\": \"#{released_version}.9000 (dev)\",",
"- \"name\": \"#{@previous_r_version} (release)\",",
- "+ \"name\": \"#{@release_version} (release)\",",
- "+ {",
- "+ \"name\": \"#{@previous_r_version}\",",
- "+ \"version\": \"#{@previous_compatible_version}/\"",
- "+ },",
+ "+ \"name\": \"#{released_version} (release)\",",
],
],
},
]
else
- expected_changes += [
+ expected_changes = [
{
- path: "r/pkgdown/assets/versions.html",
+ path: "c_glib/meson.build",
hunks: [
- [
- "-#{@previous_version}.9000 (dev)
",
- "-#{@previous_r_version} (release)
",
- "+#{@release_version}.9000 (dev)
",
- "+#{@release_version} (release)
",
- ],
+ ["-version = '#{@snapshot_version}'",
+ "+version = '#{@next_snapshot_version}'"],
],
},
{
- path: "r/pkgdown/assets/versions.json",
+ path: "c_glib/vcpkg.json",
hunks: [
- [
- "- \"name\": \"#{@previous_version}.9000 (dev)\",",
- "+ \"name\": \"#{@release_version}.9000 (dev)\",",
- "- \"name\": \"#{@previous_r_version} (release)\",",
- "+ \"name\": \"#{@release_version} (release)\",",
+ ["- \"version-string\": \"#{@snapshot_version}\",",
+ "+ \"version-string\": \"#{@next_snapshot_version}\","],
+ ],
+ },
+ {
+ path: "ci/scripts/PKGBUILD",
+ hunks: [
+ ["-pkgver=#{@previous_version}.9000",
+ "+pkgver=#{@release_version}.9000"],
+ ],
+ },
+ {
+ path: "cpp/CMakeLists.txt",
+ hunks: [
+ ["-set(ARROW_VERSION \"#{@snapshot_version}\")",
+ "+set(ARROW_VERSION \"#{@next_snapshot_version}\")"],
+ ],
+ },
+ {
+ path: "cpp/vcpkg.json",
+ hunks: [
+ ["- \"version-string\": \"#{@snapshot_version}\",",
+ "+ \"version-string\": \"#{@next_snapshot_version}\","],
+ ],
+ },
+ {
+ path: "csharp/Directory.Build.props",
+ hunks: [
+ ["- #{@snapshot_version}",
+ "+ #{@next_snapshot_version}"],
+ ],
+ },
+ {
+ path: "dev/tasks/homebrew-formulae/apache-arrow-glib.rb",
+ hunks: [
+ ["- url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@snapshot_version}/apache-arrow-#{@snapshot_version}.tar.gz\"",
+ "+ url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@next_snapshot_version}/apache-arrow-#{@next_snapshot_version}.tar.gz\""],
+ ],
+ },
+ {
+ path: "dev/tasks/homebrew-formulae/apache-arrow.rb",
+ hunks: [
+ ["- url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@snapshot_version}/apache-arrow-#{@snapshot_version}.tar.gz\"",
+ "+ url \"https://www.apache.org/dyn/closer.lua?path=arrow/arrow-#{@next_snapshot_version}/apache-arrow-#{@next_snapshot_version}.tar.gz\""],
+ ],
+ },
+ ]
+ unless next_release_type == :patch
+ expected_changes += [
+ {
+ path: "docs/source/_static/versions.json",
+ hunks: [
+ [
+ "- \"name\": \"#{@release_compatible_version} (dev)\",",
+ "+ \"name\": \"#{@next_compatible_version} (dev)\",",
+ "- \"name\": \"#{@previous_compatible_version} (stable)\",",
+ "+ \"name\": \"#{@release_compatible_version} (stable)\",",
+ "+ {",
+ "+ \"name\": \"#{@previous_compatible_version}\",",
+ "+ \"version\": \"#{@previous_compatible_version}/\",",
+ "+ \"url\": \"https://arrow.apache.org/docs/#{@previous_compatible_version}/\"",
+ "+ },",
+ ],
],
+ },
+ ]
+ end
+ expected_changes += [
+ {
+ path: "js/package.json",
+ hunks: [
+ ["- \"version\": \"#{@snapshot_version}\"",
+ "+ \"version\": \"#{@next_snapshot_version}\""],
+ ],
+ },
+ {
+ path: "matlab/CMakeLists.txt",
+ hunks: [
+ ["-set(MLARROW_VERSION \"#{@snapshot_version}\")",
+ "+set(MLARROW_VERSION \"#{@next_snapshot_version}\")"],
+ ],
+ },
+ {
+ path: "python/CMakeLists.txt",
+ hunks: [
+ ["-set(PYARROW_VERSION \"#{@snapshot_version}\")",
+ "+set(PYARROW_VERSION \"#{@next_snapshot_version}\")"],
+ ],
+ },
+ {
+ path: "python/pyproject.toml",
+ hunks: [
+ ["-fallback_version = '#{@release_version}a0'",
+ "+fallback_version = '#{@next_version}a0'"],
+ ],
+ },
+ {
+ path: "r/DESCRIPTION",
+ hunks: [
+ ["-Version: #{@previous_version}.9000",
+ "+Version: #{@release_version}.9000"],
+ ],
+ },
+ {
+ path: "r/NEWS.md",
+ hunks: [
+ ["-# arrow #{@previous_version}.9000",
+ "+# arrow #{@release_version}.9000",
+ "+",
+ "+# arrow #{@release_version}",],
],
},
]
- end
-
- Dir.glob("java/**/pom.xml") do |path|
- version = "#{@snapshot_version}"
- lines = File.readlines(path, chomp: true)
- target_lines = lines.grep(/#{Regexp.escape(version)}/)
- hunks = []
- target_lines.each do |line|
- new_line = line.gsub(@snapshot_version) do
- @next_snapshot_version
- end
- hunks << [
- "-#{line}",
- "+#{new_line}",
+ if next_release_type == :major
+ expected_changes += [
+ {
+ path: "c_glib/tool/generate-version-header.py",
+ hunks: [
+ ["+ (#{@next_major_version}, 0),"],
+ ],
+ },
+ {
+ path: "r/pkgdown/assets/versions.html",
+ hunks: [
+ [
+ "-#{@previous_version}.9000 (dev)
",
+ "-#{@previous_r_version} (release)
",
+ "+#{@release_version}.9000 (dev)
",
+ "+#{@release_version} (release)
",
+ "+#{@previous_r_version}
",
+ ],
+ ],
+ },
+ {
+ path: "r/pkgdown/assets/versions.json",
+ hunks: [
+ [
+ "- \"name\": \"#{@previous_version}.9000 (dev)\",",
+ "+ \"name\": \"#{@release_version}.9000 (dev)\",",
+ "- \"name\": \"#{@previous_r_version} (release)\",",
+ "+ \"name\": \"#{@release_version} (release)\",",
+ "+ {",
+ "+ \"name\": \"#{@previous_r_version}\",",
+ "+ \"version\": \"#{@previous_compatible_version}/\"",
+ "+ },",
+ ],
+ ],
+ },
+ ]
+ else
+ expected_changes += [
+ {
+ path: "r/pkgdown/assets/versions.html",
+ hunks: [
+ [
+ "-#{@previous_version}.9000 (dev)
",
+ "-#{@previous_r_version} (release)
",
+ "+#{@release_version}.9000 (dev)
",
+ "+#{@release_version} (release)
",
+ ],
+ ],
+ },
+ {
+ path: "r/pkgdown/assets/versions.json",
+ hunks: [
+ [
+ "- \"name\": \"#{@previous_version}.9000 (dev)\",",
+ "+ \"name\": \"#{@release_version}.9000 (dev)\",",
+ "- \"name\": \"#{@previous_r_version} (release)\",",
+ "+ \"name\": \"#{@release_version} (release)\",",
+ ],
+ ],
+ },
]
end
- expected_changes << {hunks: hunks, path: path}
- end
- Dir.glob("ruby/**/version.rb") do |path|
- version = " VERSION = \"#{@snapshot_version}\""
- new_version = " VERSION = \"#{@next_snapshot_version}\""
- expected_changes << {
- hunks: [
- [
- "-#{version}",
- "+#{new_version}",
+ Dir.glob("java/**/pom.xml") do |path|
+ version = "#{@snapshot_version}"
+ lines = File.readlines(path, chomp: true)
+ target_lines = lines.grep(/#{Regexp.escape(version)}/)
+ hunks = []
+ target_lines.each do |line|
+ new_line = line.gsub(@snapshot_version) do
+ @next_snapshot_version
+ end
+ hunks << [
+ "-#{line}",
+ "+#{new_line}",
]
- ],
- path: path,
- }
+ end
+ expected_changes << {hunks: hunks, path: path}
+ end
+
+ Dir.glob("ruby/**/version.rb") do |path|
+ version = " VERSION = \"#{@snapshot_version}\""
+ new_version = " VERSION = \"#{@next_snapshot_version}\""
+ expected_changes << {
+ hunks: [
+ [
+ "-#{version}",
+ "+#{new_version}",
+ ]
+ ],
+ path: path,
+ }
+ end
end
stdout = bump_versions("VERSION_POST_TAG")
diff --git a/dev/release/test-helper.rb b/dev/release/test-helper.rb
index 82400bae2793b..9cb8315c2f4c1 100644
--- a/dev/release/test-helper.rb
+++ b/dev/release/test-helper.rb
@@ -103,6 +103,10 @@ def next_release_type
(data || {})[:next_release_type] || :major
end
+ def compute_compatible_version(version)
+ version.split(".")[0, 2].join(".")
+ end
+
def detect_versions
top_dir = Pathname(__dir__).parent.parent
cpp_cmake_lists = top_dir + "cpp" + "CMakeLists.txt"
@@ -123,7 +127,7 @@ def detect_versions
raise "unknown release type: #{release_type.inspect}"
end
@release_version = release_version_components.join(".")
- @release_compatible_version = @release_version.split(".")[0, 2].join(".")
+ @release_compatible_version = compute_compatible_version(@release_version)
@so_version = compute_so_version(@release_version)
next_version_components = @release_version.split(".")
case next_release_type
@@ -141,13 +145,13 @@ def detect_versions
end
@next_version = next_version_components.join(".")
@next_major_version = @next_version.split(".")[0]
- @next_compatible_version = @next_version.split(".")[0, 2].join(".")
+ @next_compatible_version = compute_compatible_version(@next_version)
@next_snapshot_version = "#{@next_version}-SNAPSHOT"
@next_so_version = compute_so_version(@next_version)
r_description = top_dir + "r" + "DESCRIPTION"
@previous_version = r_description.read[/^Version: (.+?)\.9000$/, 1]
if @previous_version
- @previous_compatible_version = @previous_version.split(".")[0, 2].join(".")
+ @previous_compatible_version = compute_compatible_version(@previous_version)
else
@previous_compatible_version = nil
end
diff --git a/dev/release/utils-prepare.sh b/dev/release/utils-prepare.sh
index a4c136acdf6e6..1b7ba54e491fb 100644
--- a/dev/release/utils-prepare.sh
+++ b/dev/release/utils-prepare.sh
@@ -43,9 +43,11 @@ update_versions() {
rm -f meson.build.bak
git add meson.build
- # Add a new version entry only when the next release is a new major release
- if [ "${type}" = "snapshot" -a \
- "${next_version}" = "${major_version}.0.0" ]; then
+ # Add a new version entry only when the next release is a new major
+ # release and it doesn't exist yet.
+ if [ "${type}" = "snapshot" ] && \
+ [ "${next_version}" = "${major_version}.0.0" ] && \
+ ! grep -q -F "(${major_version}, 0)" tool/generate-version-header.py; then
sed -i.bak -E -e \
"s/^ALL_VERSIONS = \[$/&\\n (${major_version}, 0),/" \
tool/generate-version-header.py