Skip to content

Commit 34f4ffe

Browse files
authored
GH-529: [Release] Add support for uploading binary artifacts to repository.apache.org (#530)
Fixes GH-529.
1 parent aee890f commit 34f4ffe

File tree

4 files changed

+151
-20
lines changed

4 files changed

+151
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
/apache-arrow-java-*
1717
/apache-arrow-java.tar.gz
1818
/build/
19+
/dev/release/.env
1920
/dev/release/apache-rat-0.16.1.jar
2021
/dev/release/filtered_rat.txt
2122
/dev/release/rat.xml

dev/release/.env.example

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# The GPG key ID to sign artifacts. The GPG key ID must be registered
19+
# to both of the followings:
20+
#
21+
# * https://dist.apache.org/repos/dist/dev/arrow/KEYS
22+
# * https://dist.apache.org/repos/dist/release/arrow/KEYS
23+
#
24+
# See these files how to import your GPG key ID to these files.
25+
#
26+
# You must set this.
27+
#GPG_KEY_ID=08D3564B7C6A9CAFBFF6A66791D18FCF079F8007

dev/release/README.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,13 @@ RC without merging the pull request, the script to cut a RC is failed.
5656

5757
### Prepare RC and vote
5858

59-
Run `dev/release/release_rc.sh` on a working copy of
60-
`[email protected]:apache/arrow-java` not your fork:
61-
62-
```console
63-
$ git clone [email protected]:apache/arrow-java.git
64-
$ cd arrow-java
65-
$ GH_TOKEN=${YOUR_GITHUB_TOKEN} dev/release/release_rc.sh ${RC}
66-
(Send a vote email to [email protected].
67-
You can use a draft shown by release_rc.sh for the email.)
68-
```
69-
70-
Here is an example to release RC1:
71-
72-
```console
73-
$ GH_TOKEN=${YOUR_GITHUB_TOKEN} dev/release/release_rc.sh 1
74-
```
75-
76-
The argument of `release_rc.sh` is the RC number. If RC1 has a
77-
problem, we'll increment the RC number such as RC2, RC3 and so on.
59+
You can use `dev/release/release_rc.sh`.
7860

7961
Requirements to run `release_rc.sh`:
8062

8163
* You must be an Apache Arrow committer or PMC member
8264
* You must prepare your PGP key for signing
65+
* You must configure Maven
8366

8467
If you don't have a PGP key,
8568
https://infra.apache.org/release-signing.html#generate may be helpful.
@@ -102,6 +85,37 @@ $ head KEYS
10285
$ svn ci KEYS
10386
```
10487

88+
Configure Maven to publish artifacts to Apache repositories. You will
89+
need to setup a master password at `~/.m2/settings-security.xml` and
90+
`~/.m2/settings.xml` as specified on [the Apache
91+
guide](https://infra.apache.org/publishing-maven-artifacts.html). It
92+
can be tested with the following command:
93+
94+
```bash
95+
# You might need to export GPG_TTY=$(tty) to properly prompt for a passphrase
96+
mvn clean install -Papache-release
97+
```
98+
99+
Run `dev/release/release_rc.sh` on a working copy of
100+
`[email protected]:apache/arrow-java` not your fork:
101+
102+
```console
103+
$ git clone [email protected]:apache/arrow-java.git
104+
$ cd arrow-java
105+
$ GH_TOKEN=${YOUR_GITHUB_TOKEN} dev/release/release_rc.sh ${RC}
106+
(Send a vote email to [email protected].
107+
You can use a draft shown by release_rc.sh for the email.)
108+
```
109+
110+
Here is an example to release RC1:
111+
112+
```console
113+
$ GH_TOKEN=${YOUR_GITHUB_TOKEN} dev/release/release_rc.sh 1
114+
```
115+
116+
The argument of `release_rc.sh` is the RC number. If RC1 has a
117+
problem, we'll increment the RC number such as RC2, RC3 and so on.
118+
105119
### Publish
106120

107121
We need to do the followings to publish a new release:

dev/release/release_rc.sh

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ artifacts_dir="apache-arrow-java-${version}-rc${rc}"
8484
signed_artifacts_dir="${artifacts_dir}-signed"
8585

8686
if [ "${RELEASE_SIGN}" -gt 0 ]; then
87+
if [ ! -f "${SOURCE_DIR}/.env" ]; then
88+
echo "You must create ${SOURCE_DIR}/.env"
89+
echo "You can use ${SOURCE_DIR}/.env.example as template"
90+
exit 1
91+
fi
92+
. "${SOURCE_DIR}/.env"
93+
8794
git_origin_url="$(git remote get-url origin)"
8895
repository="${git_origin_url#*github.com?}"
8996
repository="${repository%.git}"
@@ -120,21 +127,103 @@ if [ "${RELEASE_SIGN}" -gt 0 ]; then
120127
continue
121128
;;
122129
esac
123-
gpg --armor \
130+
gpg \
131+
--armor \
124132
--detach-sig \
133+
--local-user "${GPG_KEY_ID}" \
125134
--output "${signed_artifacts_dir}/$(basename "${artifact}").asc" \
126135
"${artifact}"
127136
done
128137
fi
129138

139+
# arrow-c-data-18.2.0-sources.jar ->
140+
# jar
141+
extract_type() {
142+
local path="$1"
143+
echo "${path}" | grep -o "[^.]*$"
144+
}
145+
146+
# arrow-c-data-18.2.0-sources.jar arrow-c-data-18.2.0 ->
147+
# sources
148+
extract_classifier() {
149+
local path="$1"
150+
local base="$2"
151+
basename "${path}" | sed -e "s/^${base}-//g" -e "s/\.[^.]*$//g"
152+
}
153+
130154
if [ "${RELEASE_UPLOAD}" -gt 0 ]; then
131155
echo "Uploading signature"
132156
gh release upload "${rc_tag}" \
133157
--clobber \
134158
--repo "${repository}" \
135159
"${signed_artifacts_dir}"/*.asc
160+
161+
echo "Uploading packages"
162+
for pom in "${artifacts_dir}"/*.pom; do
163+
base=$(basename "${pom}" .pom)
164+
files=()
165+
types=()
166+
classifiers=()
167+
args=()
168+
args+=(deploy:deploy-file)
169+
args+=(-Durl=https://repository.apache.org/service/local/staging/deploy/maven2)
170+
args+=(-DrepositoryId=apache.releases.https)
171+
args+=(-DretryFailedDeploymentCount=10)
172+
args+=(-DpomFile="${pom}")
173+
if [ -f "${artifacts_dir}/${base}.jar" ]; then
174+
jar="${artifacts_dir}/${base}.jar"
175+
args+=(-Dfile="${jar}")
176+
files+=("${signed_artifacts_dir}/${base}.jar.asc")
177+
types+=("jar.asc")
178+
classifiers+=("")
179+
else
180+
args+=(-Dfile="${pom}")
181+
fi
182+
files+=("${signed_artifacts_dir}/${base}.pom.asc")
183+
types+=("pom.asc")
184+
classifiers+=("")
185+
if [ "$(echo "${artifacts_dir}/${base}"-*)" != "${artifacts_dir}/${base}-*" ]; then
186+
for other_file in "${artifacts_dir}/${base}"-*; do
187+
type="$(extract_type "${other_file}")"
188+
case "${type}" in
189+
sha256 | sha512)
190+
continue
191+
;;
192+
esac
193+
classifier=$(extract_classifier "${other_file}" "${base}")
194+
files+=("${other_file}")
195+
types+=("${type}")
196+
classifiers+=("${classifier}")
197+
other_file_base="$(basename "${other_file}")"
198+
files+=("${signed_artifacts_dir}/${other_file_base}.asc")
199+
types+=("${type}.asc")
200+
classifiers+=("${classifier}")
201+
done
202+
fi
203+
args+=(-Dfiles="$(
204+
IFS=,
205+
echo "${files[*]}"
206+
)")
207+
args+=(-Dtypes="$(
208+
IFS=,
209+
echo "${types[*]}"
210+
)")
211+
args+=(-Dclassifiers="$(
212+
IFS=,
213+
echo "${classifiers[*]}"
214+
)")
215+
mvn "${args[@]}"
216+
done
217+
218+
echo
219+
echo "Success!"
220+
echo "Press the 'Close' button manually by Web interface:"
221+
echo " https://repository.apache.org/#stagingRepositories"
222+
echo "It publishes the artifacts to the staging repository:"
223+
echo " https://repository.apache.org/content/repositories/staging/org/apache/arrow/"
136224
fi
137225

226+
echo
138227
echo "Draft email for [email protected] mailing list"
139228
echo ""
140229
echo "---------------------------------------------------------"

0 commit comments

Comments
 (0)