Skip to content

Commit 9ec01da

Browse files
committed
ARROW-13051: [Release][Java] Use artifacts built by Crossbow
Closes apache#11696 from kou/release-java-nexus Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 00ba042 commit 9ec01da

9 files changed

+279
-171
lines changed

Diff for: dev/release/05-binary-upload.sh

-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ fi
6868
: ${UPLOAD_AMAZON_LINUX:=${UPLOAD_DEFAULT}}
6969
: ${UPLOAD_CENTOS:=${UPLOAD_DEFAULT}}
7070
: ${UPLOAD_DEBIAN:=${UPLOAD_DEFAULT}}
71-
: ${UPLOAD_JAVA:=${UPLOAD_DEFAULT}}
7271
: ${UPLOAD_NUGET:=${UPLOAD_DEFAULT}}
7372
: ${UPLOAD_PYTHON:=${UPLOAD_DEFAULT}}
7473
: ${UPLOAD_UBUNTU:=${UPLOAD_DEFAULT}}
@@ -92,9 +91,6 @@ if [ ${UPLOAD_DEBIAN} -gt 0 ]; then
9291
rake_tasks+=(apt:rc)
9392
apt_targets+=(debian)
9493
fi
95-
if [ ${UPLOAD_JAVA} -gt 0 ]; then
96-
rake_tasks+=(java:rc)
97-
fi
9894
if [ ${UPLOAD_NUGET} -gt 0 ]; then
9995
rake_tasks+=(nuget:rc)
10096
fi

Diff for: dev/release/06-java-upload.sh

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bash
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+
set -e
21+
set -u
22+
set -o pipefail
23+
24+
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25+
26+
if [ "$#" -ne 2 ]; then
27+
echo "Usage: $0 <version> <rc-num>"
28+
exit
29+
fi
30+
31+
version=$1
32+
rc=$2
33+
34+
pushd "${SOURCE_DIR}"
35+
if [ ! -f .env ]; then
36+
echo "You must create $(pwd)/.env"
37+
echo "You can use $(pwd)/.env.example as template"
38+
exit 1
39+
fi
40+
. .env
41+
popd
42+
43+
version_with_rc="${version}-rc${rc}"
44+
crossbow_job_prefix="release-${version_with_rc}"
45+
crossbow_package_dir="${SOURCE_DIR}/../../packages"
46+
47+
: ${CROSSBOW_JOB_NUMBER:="0"}
48+
: ${CROSSBOW_JOB_ID:="${crossbow_job_prefix}-${CROSSBOW_JOB_NUMBER}"}
49+
artifact_dir="${crossbow_package_dir}/${CROSSBOW_JOB_ID}"
50+
51+
if [ ! -e "${artifact_dir}" ]; then
52+
echo "${artifact_dir} does not exist"
53+
exit 1
54+
fi
55+
56+
if [ ! -d "${artifact_dir}" ]; then
57+
echo "${artifact_dir} is not a directory"
58+
exit 1
59+
fi
60+
61+
cd "${artifact_dir}/java-jars"
62+
63+
files=
64+
types=
65+
classifiers=
66+
67+
sign() {
68+
local path="$1"
69+
local classifier="$2"
70+
local type=$(echo "${path}" | grep -o "[^.]*$")
71+
72+
local asc_path="${path}.asc"
73+
rm -f "${asc_path}"
74+
gpg \
75+
--detach-sig \
76+
--local-user "${GPG_KEY_ID}" \
77+
--output "${asc_path}" \
78+
"${path}"
79+
if [ -n "${files}" ]; then
80+
files="${files},"
81+
types="${types},"
82+
classifiers="${classifiers},"
83+
fi
84+
files="${files}${asc_path}"
85+
types="${types}${type}.asc"
86+
classifiers="${classifiers}${classifier}"
87+
88+
# .md5 and .sha1 are generated automatically on repository side.
89+
# local sha512_path="${path}.sha512"
90+
# shasum --algorithm 512 "${path}" > "${sha512_path}"
91+
# files="${files},${sha512_path}"
92+
# types="${types},${type}.sha512"
93+
# classifiers="${classifiers},${classifier}"
94+
}
95+
96+
for pom in *.pom; do
97+
base=$(basename ${pom} .pom)
98+
args=()
99+
args+=(deploy:deploy-file)
100+
args+=(-Durl=https://repository.apache.org/service/local/staging/deploy/maven2)
101+
args+=(-DrepositoryId=apache.releases.https)
102+
pom="${PWD}/${pom}"
103+
args+=(-DpomFile="${pom}")
104+
if [ -f "${base}.jar" ]; then
105+
jar="${PWD}/${base}.jar"
106+
args+=(-Dfile="${jar}")
107+
sign "${jar}" ""
108+
else
109+
args+=(-Dfile="${pom}")
110+
fi
111+
sign "${pom}" ""
112+
if [ "$(echo ${base}-*)" != "${base}-*" ]; then
113+
for other_file in ${base}-*; do
114+
file="${PWD}/${other_file}"
115+
type=$(echo "${other_file}" | grep -o "[^.]*$")
116+
case "${type}" in
117+
asc|sha256|sha512)
118+
continue
119+
;;
120+
esac
121+
classifier=$(basename "${other_file}" ".${type}" | sed -e "s/${base}-//g")
122+
files="${files},${file}"
123+
types="${types},${type}"
124+
classifiers="${classifiers},${classifier}"
125+
sign "${file}" "${classifier}"
126+
done
127+
fi
128+
args+=(-Dfiles="${files}")
129+
args+=(-Dtypes="${types}")
130+
args+=(-Dclassifiers="${classifiers}")
131+
pushd "${SOURCE_DIR}"
132+
mvn deploy:deploy-file "${args[@]}"
133+
popd
134+
done
135+
136+
echo "Success!"
137+
echo "Press the 'Close' button manually by Web interface:"
138+
echo " https://repository.apache.org/#stagingRepositories"
139+
echo "It publishes the artifacts to the staging repository:"
140+
echo " https://repository.apache.org/content/repositories/staging/org/apache/arrow/"

Diff for: dev/release/binary-task.rb

-11
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ def upload
739739
def define
740740
define_apt_tasks
741741
define_yum_tasks
742-
define_java_tasks
743742
define_nuget_tasks
744743
define_python_tasks
745744
define_summary_tasks
@@ -1857,14 +1856,6 @@ def define_generic_data_tasks(label,
18571856
define_generic_data_release_tasks(label, id, release_dir)
18581857
end
18591858

1860-
def define_java_tasks
1861-
define_generic_data_tasks("Java",
1862-
:java,
1863-
"#{rc_dir}/java/#{full_version}",
1864-
"#{release_dir}/java/#{full_version}",
1865-
"java-jars/**/*")
1866-
end
1867-
18681859
def define_nuget_tasks
18691860
define_generic_data_tasks("NuGet",
18701861
:nuget,
@@ -1893,7 +1884,6 @@ def define_summary_tasks
18931884
https://apache.jfrog.io/artifactory/arrow/amazon-linux#{suffix}-rc/
18941885
https://apache.jfrog.io/artifactory/arrow/centos#{suffix}-rc/
18951886
https://apache.jfrog.io/artifactory/arrow/debian#{suffix}-rc/
1896-
https://apache.jfrog.io/artifactory/arrow/java#{suffix}-rc/#{version}
18971887
https://apache.jfrog.io/artifactory/arrow/nuget#{suffix}-rc/#{full_version}
18981888
https://apache.jfrog.io/artifactory/arrow/python#{suffix}-rc/#{full_version}
18991889
https://apache.jfrog.io/artifactory/arrow/ubuntu#{suffix}-rc/
@@ -1910,7 +1900,6 @@ def define_summary_tasks
19101900
https://apache.jfrog.io/artifactory/arrow/amazon-linux#{suffix}/
19111901
https://apache.jfrog.io/artifactory/arrow/centos#{suffix}/
19121902
https://apache.jfrog.io/artifactory/arrow/debian#{suffix}/
1913-
https://apache.jfrog.io/artifactory/arrow/java#{suffix}/#{version}
19141903
https://apache.jfrog.io/artifactory/arrow/nuget#{suffix}/#{version}
19151904
https://apache.jfrog.io/artifactory/arrow/python#{suffix}/#{version}
19161905
https://apache.jfrog.io/artifactory/arrow/ubuntu#{suffix}/

Diff for: dev/release/download_rc_binaries.py

+38-22
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,31 @@
2525
import urllib.request
2626

2727

28-
ARTIFACTORY_ROOT = "https://apache.jfrog.io/artifactory/arrow"
2928
DEFAULT_PARALLEL_DOWNLOADS = 8
3029

3130

32-
class Artifactory:
31+
class Downloader:
3332

34-
def get_file_list(self, prefix):
33+
def get_file_list(self, prefix, filter=None):
3534
def traverse(directory, files, directories):
36-
url = f'{ARTIFACTORY_ROOT}/{directory}'
35+
url = f'{self.URL_ROOT}/{directory}'
3736
response = urllib.request.urlopen(url).read().decode()
3837
paths = re.findall('<a href="(.+?)"', response)
3938
for path in paths:
39+
path = re.sub(f'^{re.escape(url)}',
40+
'',
41+
path)
4042
if path == '../':
4143
continue
4244
resolved_path = f'{directory}{path}'
45+
if filter and not filter(path):
46+
continue
4347
if path.endswith('/'):
4448
directories.append(resolved_path)
4549
else:
4650
files.append(resolved_path)
4751
files = []
48-
if not prefix.endswith('/'):
52+
if prefix != '' and not prefix.endswith('/'):
4953
prefix += '/'
5054
directories = [prefix]
5155
while len(directories) > 0:
@@ -98,7 +102,7 @@ def _download_file(self, dest, path):
98102

99103
print("Downloading {} to {}".format(path, dest_path))
100104

101-
url = f'{ARTIFACTORY_ROOT}/{path}'
105+
url = f'{self.URL_ROOT}/{path}'
102106

103107
cmd = [
104108
'curl', '--fail', '--location', '--retry', '5',
@@ -112,6 +116,15 @@ def _download_file(self, dest, path):
112116
.format(path, stdout, stderr))
113117

114118

119+
class Artifactory(Downloader):
120+
URL_ROOT = "https://apache.jfrog.io/artifactory/arrow"
121+
122+
123+
class Maven(Downloader):
124+
URL_ROOT = "https://repository.apache.org" + \
125+
"/content/repositories/staging/org/apache/arrow"
126+
127+
115128
def parallel_map_terminate_early(f, iterable, num_parallel):
116129
tasks = []
117130
with cf.ProcessPoolExecutor(num_parallel) as pool:
@@ -133,38 +146,41 @@ def parallel_map_terminate_early(f, iterable, num_parallel):
133146
'debian',
134147
'ubuntu',
135148
]
136-
ARROW_STANDALONE_PACKAGE_TYPES = ['java', 'nuget', 'python']
149+
ARROW_STANDALONE_PACKAGE_TYPES = ['nuget', 'python']
137150
ARROW_PACKAGE_TYPES = \
138151
ARROW_REPOSITORY_PACKAGE_TYPES + \
139152
ARROW_STANDALONE_PACKAGE_TYPES
140153

141154

142155
def download_rc_binaries(version, rc_number, re_match=None, dest=None,
143156
num_parallel=None, target_package_type=None):
144-
artifactory = Artifactory()
145-
146157
version_string = '{}-rc{}'.format(version, rc_number)
158+
version_pattern = re.compile(r'\d+\.\d+\.\d+')
147159
if target_package_type:
148160
package_types = [target_package_type]
149161
else:
150162
package_types = ARROW_PACKAGE_TYPES
151163
for package_type in package_types:
152-
if package_type in ARROW_REPOSITORY_PACKAGE_TYPES:
164+
def is_target(path):
165+
match = version_pattern.search(path)
166+
if not match:
167+
return True
168+
return match[0] == version
169+
filter = is_target
170+
171+
if package_type == 'jars':
172+
downloader = Maven()
173+
prefix = ''
174+
elif package_type in ARROW_REPOSITORY_PACKAGE_TYPES:
175+
downloader = Artifactory()
153176
prefix = f'{package_type}-rc'
154177
else:
178+
downloader = Artifactory()
155179
prefix = f'{package_type}-rc/{version_string}'
156-
files = artifactory.get_file_list(prefix)
157-
if package_type in ARROW_REPOSITORY_PACKAGE_TYPES:
158-
version_pattern = re.compile(r'\d+\.\d+\.\d+')
159-
160-
def is_old_release(path):
161-
match = version_pattern.search(path)
162-
if not match:
163-
return False
164-
return match[0] != version
165-
files = [x for x in files if not is_old_release(x)]
166-
artifactory.download_files(files, re_match=re_match, dest=dest,
167-
num_parallel=num_parallel)
180+
filter = None
181+
files = downloader.get_file_list(prefix, filter=filter)
182+
downloader.download_files(files, re_match=re_match, dest=dest,
183+
num_parallel=num_parallel)
168184

169185

170186
if __name__ == '__main__':

Diff for: dev/release/post-03-binary.sh

-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ fi
4949
: ${DEPLOY_AMAZON_LINUX:=${DEPLOY_DEFAULT}}
5050
: ${DEPLOY_CENTOS:=${DEPLOY_DEFAULT}}
5151
: ${DEPLOY_DEBIAN:=${DEPLOY_DEFAULT}}
52-
: ${DEPLOY_JAVA:=${DEPLOY_DEFAULT}}
5352
: ${DEPLOY_NUGET:=${DEPLOY_DEFAULT}}
5453
: ${DEPLOY_PYTHON:=${DEPLOY_DEFAULT}}
5554
: ${DEPLOY_UBUNTU:=${DEPLOY_DEFAULT}}
@@ -73,9 +72,6 @@ if [ ${DEPLOY_DEBIAN} -gt 0 ]; then
7372
rake_tasks+=(apt:release)
7473
apt_targets+=(debian)
7574
fi
76-
if [ ${DEPLOY_JAVA} -gt 0 ]; then
77-
rake_tasks+=(java:release)
78-
fi
7975
if [ ${DEPLOY_NUGET} -gt 0 ]; then
8076
rake_tasks+=(nuget:release)
8177
fi
File renamed without changes.

0 commit comments

Comments
 (0)