Skip to content

Commit 63c642e

Browse files
committed
Update versions
1 parent 815ea8a commit 63c642e

File tree

3 files changed

+150
-4
lines changed

3 files changed

+150
-4
lines changed

cpp/thirdparty/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,19 @@ See the "Build Dependency Management" section in the [C++ Developer
2323
Documentation][1].
2424

2525
[1]: https://github.com/apache/arrow/blob/main/docs/source/developers/cpp/building.rst
26+
27+
## Update versions automatically
28+
29+
There is a convenient script that update versions in `versions.txt` to
30+
the latest version automatically. You can use it like the following:
31+
32+
```console
33+
dev/release/update.rb PRODUCT_PATTERN1 PRODUCT_PATTERN2 ...
34+
```
35+
36+
For example, you can update AWS SDK for C++ related products' versions
37+
by the following command line:
38+
39+
```console
40+
dev/release/update.rb "AWS*" "S2N*"
41+
```

cpp/thirdparty/update.rb

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env ruby
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with 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,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
require "digest/sha2"
21+
require "json"
22+
require "open-uri"
23+
24+
if ARGV.empty?
25+
puts("Usage: #{$0} PRODUCT_PATTERN1 PRODUCT_PATTERN2 ...")
26+
puts(" e.g.: #{$0} 'AWS*' 'S2N*'.")
27+
exit(false)
28+
end
29+
30+
def parse_versions_txt_content(content)
31+
products = {}
32+
content.each_line(chomp: true) do |line|
33+
case line
34+
when /\AARROW_([A-Za-z0-9_-]+)_BUILD_VERSION=(.+?)\z/
35+
product = Regexp.last_match[1]
36+
version = Regexp.last_match[2]
37+
products[product] = {version: version}
38+
when /\AARROW_([A-Za-z0-9_-]+)_BUILD_SHA256_CHECKSUM=(.+?)\z/
39+
product = Regexp.last_match[1]
40+
checksum = Regexp.last_match[2]
41+
products[product][:checksum] = checksum
42+
when /\A "ARROW_([A-Za-z0-9_-]+)_URL (?:\S+) (\S+)"\z/
43+
product = Regexp.last_match[1]
44+
url_template = Regexp.last_match[2]
45+
url_template.gsub!(/\${.+?}/) do |matched|
46+
if matched.end_with?("//./_}")
47+
"%{version_underscore}"
48+
else
49+
"%{version}"
50+
end
51+
end
52+
products[product][:url_template] = url_template
53+
end
54+
end
55+
products
56+
end
57+
58+
def update_product_github(product, metadata, repository)
59+
version = metadata[:version]
60+
tags_url = "https://api.github.com/repos/#{repository}/tags"
61+
tags = URI.open(tags_url) do |response|
62+
JSON.parse(response.read)
63+
end
64+
latest_tag_name = tags[0]["name"]
65+
if latest_tag_name.start_with?("v")
66+
if metadata[:version].start_with?("v")
67+
latest_version = latest_tag_name
68+
else
69+
latest_version = latest_tag_name[1..-1]
70+
end
71+
else
72+
latest_version = latest_tag_name
73+
end
74+
return if version == latest_version
75+
76+
url_template = metadata[:url_template]
77+
url = url_template % {
78+
version: latest_version,
79+
version_underscore: latest_version.gsub(".", "_"),
80+
}
81+
$stderr.puts("Updating #{product}: #{version} -> #{latest_version}")
82+
metadata[:version] = latest_version
83+
URI.open(url, "rb") do |response|
84+
metadata[:checksum] = Digest::SHA256.hexdigest(response.read)
85+
end
86+
$stderr.puts(" Checksum: #{metadata[:checksum]}")
87+
end
88+
89+
def update_product(product, metadata)
90+
url_template = metadata[:url_template]
91+
if url_template.nil?
92+
$stderr.puts("#{product} isn't supported " +
93+
"because there is no associated URL")
94+
return
95+
end
96+
97+
case url_template
98+
when /\Ahttps:\/\/github.com\/((?:[^\/]+)\/(?:[^\/]+))\//
99+
github_repository = Regexp.last_match[1]
100+
update_product_github(product, metadata, github_repository)
101+
else
102+
$stderr.puts("TODO: #{product} isn't supported yet: #{url_template}")
103+
end
104+
end
105+
106+
def update_versions_txt_content!(content, products)
107+
products.each do |product, metadata|
108+
prefix = "ARROW_#{Regexp.escape(product)}"
109+
content.gsub!(/^#{prefix}_BUILD_VERSION=.*$/) do
110+
"ARROW_#{product}_BUILD_VERSION=#{metadata[:version]}"
111+
end
112+
content.gsub!(/^#{prefix}_BUILD_SHA256_CHECKSUM=.*?$/) do
113+
"ARROW_#{product}_BUILD_SHA256_CHECKSUM=#{metadata[:checksum]}"
114+
end
115+
end
116+
end
117+
118+
versions_txt = File.join(__dir__, "versions.txt")
119+
versions_txt_content = File.read(versions_txt)
120+
products = parse_versions_txt_content(versions_txt_content)
121+
ARGV.each do |pattern|
122+
target_products = products.filter do |product, _|
123+
File.fnmatch?(pattern, product)
124+
end
125+
target_products.each do |product, metadata|
126+
update_product(product, metadata)
127+
end
128+
end
129+
update_versions_txt_content!(versions_txt_content, products)
130+
File.write(versions_txt, versions_txt_content)

cpp/thirdparty/versions.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
ARROW_ABSL_BUILD_VERSION=20211102.0
2727
ARROW_ABSL_BUILD_SHA256_CHECKSUM=dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4
28-
ARROW_AWS_C_AUTH_BUILD_VERSION=v0.8.0
29-
ARROW_AWS_C_AUTH_BUILD_SHA256_CHECKSUM=217a0ebf8d7c5ad7e5f5ae814c2a371042164b64b4b9330c1c4bb2c6db1dbd33
28+
ARROW_AWS_C_AUTH_BUILD_VERSION=v0.8.1
29+
ARROW_AWS_C_AUTH_BUILD_SHA256_CHECKSUM=15241d7284aa0ac552589b61d04be455413af76fb2e1f13084a784a41f5faee5
3030
ARROW_AWS_C_CAL_BUILD_VERSION=v0.8.1
3131
ARROW_AWS_C_CAL_BUILD_SHA256_CHECKSUM=4d603641758ef350c3e5401184804e8a6bba4aa5294593cc6228b0dca77b22f5
3232
ARROW_AWS_C_COMMON_BUILD_VERSION=v0.10.6
@@ -51,8 +51,8 @@ ARROW_AWS_CRT_CPP_BUILD_VERSION=v0.29.9
5151
ARROW_AWS_CRT_CPP_BUILD_SHA256_CHECKSUM=d445ab7a26c03a0c0cbb9d82203ee32a56c762a3cef1874783783431b8eb015a
5252
ARROW_AWS_LC_BUILD_VERSION=v1.42.0
5353
ARROW_AWS_LC_BUILD_SHA256_CHECKSUM=8537025ebfd3884830f494166ae5f72f8aaa203d49abe650a0560a7ffedf359e
54-
ARROW_AWSSDK_BUILD_VERSION=1.11.488
55-
ARROW_AWSSDK_BUILD_SHA256_CHECKSUM=e3729c68c07724566a7e25cc68430b57af18dee421dcbc7cda0e9ad2ba0b486e
54+
ARROW_AWSSDK_BUILD_VERSION=1.11.489
55+
ARROW_AWSSDK_BUILD_SHA256_CHECKSUM=89ce525c735243a043c5a31eee5dc082fc976b9b5a4b0b66813eed48c97abbfa
5656
# Despite the confusing version name this is still the whole Azure SDK for C++ including core, keyvault, storage-common, etc.
5757
ARROW_AZURE_SDK_BUILD_VERSION=azure-identity_1.9.0
5858
ARROW_AZURE_SDK_BUILD_SHA256_CHECKSUM=97065bfc971ac8df450853ce805f820f52b59457bd7556510186a1569502e4a1

0 commit comments

Comments
 (0)