Skip to content

Commit ab1b6ee

Browse files
felixcheungsrowen
authored andcommitted
[BUILD] update release scripts
## What changes were proposed in this pull request? Change to dist.apache.org instead of home directory sha512 should have .sha512 extension. From ASF release signing doc: "The checksum SHOULD be generated using SHA-512. A .sha file SHOULD contain a SHA-1 checksum, for historical reasons." NOTE: I *think* should require some changes to work with Jenkins' release build ## How was this patch tested? manually Author: Felix Cheung <[email protected]> Closes #19754 from felixcheung/releasescript.
1 parent 251b2c0 commit ab1b6ee

File tree

2 files changed

+60
-70
lines changed

2 files changed

+60
-70
lines changed

dev/create-release/release-build.sh

Lines changed: 53 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,19 @@ usage: release-build.sh <package|docs|publish-snapshot|publish-release>
2323
Creates build deliverables from a Spark commit.
2424
2525
Top level targets are
26-
package: Create binary packages and copy them to home.apache
27-
docs: Build docs and copy them to home.apache
26+
package: Create binary packages and commit them to dist.apache.org/repos/dist/dev/spark/
27+
docs: Build docs and commit them to dist.apache.org/repos/dist/dev/spark/
2828
publish-snapshot: Publish snapshot release to Apache snapshots
2929
publish-release: Publish a release to Apache release repo
3030
3131
All other inputs are environment variables
3232
3333
GIT_REF - Release tag or commit to build from
34-
SPARK_VERSION - Version of Spark being built (e.g. 2.1.2)
3534
SPARK_PACKAGE_VERSION - Release identifier in top level package directory (e.g. 2.1.2-rc1)
36-
REMOTE_PARENT_DIR - Parent in which to create doc or release builds.
37-
REMOTE_PARENT_MAX_LENGTH - If set, parent directory will be cleaned to only
38-
have this number of subdirectories (by deleting old ones). WARNING: This deletes data.
35+
SPARK_VERSION - (optional) Version of Spark being built (e.g. 2.1.2)
3936
4037
ASF_USERNAME - Username of ASF committer account
4138
ASF_PASSWORD - Password of ASF committer account
42-
ASF_RSA_KEY - RSA private key file for ASF committer account
4339
4440
GPG_KEY - GPG key used to sign release artifacts
4541
GPG_PASSPHRASE - Passphrase for GPG key
@@ -57,7 +53,20 @@ if [[ $@ == *"help"* ]]; then
5753
exit_with_usage
5854
fi
5955

60-
for env in ASF_USERNAME ASF_RSA_KEY GPG_PASSPHRASE GPG_KEY; do
56+
if [[ -z "$ASF_PASSWORD" ]]; then
57+
echo 'The environment variable ASF_PASSWORD is not set. Enter the password.'
58+
echo
59+
stty -echo && printf "ASF password: " && read ASF_PASSWORD && printf '\n' && stty echo
60+
fi
61+
62+
if [[ -z "$GPG_PASSPHRASE" ]]; then
63+
echo 'The environment variable GPG_PASSPHRASE is not set. Enter the passphrase to'
64+
echo 'unlock the GPG signing key that will be used to sign the release!'
65+
echo
66+
stty -echo && printf "GPG passphrase: " && read GPG_PASSPHRASE && printf '\n' && stty echo
67+
fi
68+
69+
for env in ASF_USERNAME GPG_PASSPHRASE GPG_KEY; do
6170
if [ -z "${!env}" ]; then
6271
echo "ERROR: $env must be set to run this script"
6372
exit_with_usage
@@ -71,8 +80,7 @@ export LC_ALL=C
7180
# Commit ref to checkout when building
7281
GIT_REF=${GIT_REF:-master}
7382

74-
# Destination directory parent on remote server
75-
REMOTE_PARENT_DIR=${REMOTE_PARENT_DIR:-/home/$ASF_USERNAME/public_html}
83+
RELEASE_STAGING_LOCATION="https://dist.apache.org/repos/dist/dev/spark"
7684

7785
GPG="gpg -u $GPG_KEY --no-tty --batch"
7886
NEXUS_ROOT=https://repository.apache.org/service/local/staging
@@ -142,50 +150,24 @@ if [ -z "$SPARK_PACKAGE_VERSION" ]; then
142150
SPARK_PACKAGE_VERSION="${SPARK_VERSION}-$(date +%Y_%m_%d_%H_%M)-${git_hash}"
143151
fi
144152

145-
DEST_DIR_NAME="spark-$SPARK_PACKAGE_VERSION"
146-
147-
function LFTP {
148-
SSH="ssh -o ConnectTimeout=300 -o StrictHostKeyChecking=no -i $ASF_RSA_KEY"
149-
COMMANDS=$(cat <<EOF
150-
set net:max-retries 2 &&
151-
set sftp:connect-program $SSH &&
152-
connect -u $ASF_USERNAME,p sftp://home.apache.org &&
153-
$@
154-
EOF
155-
)
156-
lftp --norc -c "$COMMANDS"
157-
}
158-
export -f LFTP
159-
153+
DEST_DIR_NAME="$SPARK_PACKAGE_VERSION"
160154

161155
git clean -d -f -x
162156
rm .gitignore
163157
rm -rf .git
164158
cd ..
165159

166-
if [ -n "$REMOTE_PARENT_MAX_LENGTH" ]; then
167-
old_dirs=$(
168-
LFTP nlist $REMOTE_PARENT_DIR \
169-
| grep -v "^\." \
170-
| sort -r \
171-
| tail -n +$REMOTE_PARENT_MAX_LENGTH)
172-
for old_dir in $old_dirs; do
173-
echo "Removing directory: $old_dir"
174-
LFTP "rm -rf $REMOTE_PARENT_DIR/$old_dir && exit 0"
175-
done
176-
fi
177-
178160
if [[ "$1" == "package" ]]; then
179161
# Source and binary tarballs
180-
echo "Packaging release tarballs"
162+
echo "Packaging release source tarballs"
181163
cp -r spark spark-$SPARK_VERSION
182164
tar cvzf spark-$SPARK_VERSION.tgz spark-$SPARK_VERSION
183165
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --armour --output spark-$SPARK_VERSION.tgz.asc \
184166
--detach-sig spark-$SPARK_VERSION.tgz
185167
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md MD5 spark-$SPARK_VERSION.tgz > \
186168
spark-$SPARK_VERSION.tgz.md5
187169
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
188-
SHA512 spark-$SPARK_VERSION.tgz > spark-$SPARK_VERSION.tgz.sha
170+
SHA512 spark-$SPARK_VERSION.tgz > spark-$SPARK_VERSION.tgz.sha512
189171
rm -rf spark-$SPARK_VERSION
190172

191173
# Updated for each binary build
@@ -238,7 +220,7 @@ if [[ "$1" == "package" ]]; then
238220
$R_DIST_NAME.md5
239221
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
240222
SHA512 $R_DIST_NAME > \
241-
$R_DIST_NAME.sha
223+
$R_DIST_NAME.sha512
242224
else
243225
echo "Creating distribution with PIP package"
244226
./dev/make-distribution.sh --name $NAME --mvn $MVN_HOME/bin/mvn --tgz --pip $FLAGS \
@@ -257,7 +239,7 @@ if [[ "$1" == "package" ]]; then
257239
$PYTHON_DIST_NAME.md5
258240
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
259241
SHA512 $PYTHON_DIST_NAME > \
260-
$PYTHON_DIST_NAME.sha
242+
$PYTHON_DIST_NAME.sha512
261243
fi
262244

263245
echo "Copying and signing regular binary distribution"
@@ -270,7 +252,7 @@ if [[ "$1" == "package" ]]; then
270252
spark-$SPARK_VERSION-bin-$NAME.tgz.md5
271253
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
272254
SHA512 spark-$SPARK_VERSION-bin-$NAME.tgz > \
273-
spark-$SPARK_VERSION-bin-$NAME.tgz.sha
255+
spark-$SPARK_VERSION-bin-$NAME.tgz.sha512
274256
}
275257

276258
# TODO: Check exit codes of children here:
@@ -284,44 +266,45 @@ if [[ "$1" == "package" ]]; then
284266
wait
285267
rm -rf spark-$SPARK_VERSION-bin-*/
286268

287-
# Copy data
288-
dest_dir="$REMOTE_PARENT_DIR/${DEST_DIR_NAME}-bin"
289-
echo "Copying release tarballs to $dest_dir"
290-
# Put to new directory:
291-
LFTP mkdir -p $dest_dir || true
292-
LFTP mput -O $dest_dir 'spark-*'
293-
LFTP mput -O $dest_dir 'pyspark-*'
294-
LFTP mput -O $dest_dir 'SparkR_*'
295-
# Delete /latest directory and rename new upload to /latest
296-
LFTP "rm -r -f $REMOTE_PARENT_DIR/latest || exit 0"
297-
LFTP mv $dest_dir "$REMOTE_PARENT_DIR/latest"
298-
# Re-upload a second time and leave the files in the timestamped upload directory:
299-
LFTP mkdir -p $dest_dir || true
300-
LFTP mput -O $dest_dir 'spark-*'
301-
LFTP mput -O $dest_dir 'pyspark-*'
302-
LFTP mput -O $dest_dir 'SparkR_*'
269+
svn co --depth=empty $RELEASE_STAGING_LOCATION svn-spark
270+
rm -rf "svn-spark/${DEST_DIR_NAME}-bin"
271+
mkdir -p "svn-spark/${DEST_DIR_NAME}-bin"
272+
273+
echo "Copying release tarballs"
274+
cp spark-* "svn-spark/${DEST_DIR_NAME}-bin/"
275+
cp pyspark-* "svn-spark/${DEST_DIR_NAME}-bin/"
276+
cp SparkR_* "svn-spark/${DEST_DIR_NAME}-bin/"
277+
svn add "svn-spark/${DEST_DIR_NAME}-bin"
278+
279+
cd svn-spark
280+
svn ci --username $ASF_USERNAME --password "$ASF_PASSWORD" -m"Apache Spark $SPARK_PACKAGE_VERSION"
281+
cd ..
282+
rm -rf svn-spark
303283
exit 0
304284
fi
305285

306286
if [[ "$1" == "docs" ]]; then
307287
# Documentation
308288
cd spark
309289
echo "Building Spark docs"
310-
dest_dir="$REMOTE_PARENT_DIR/${DEST_DIR_NAME}-docs"
311290
cd docs
312291
# TODO: Make configurable to add this: PRODUCTION=1
313292
PRODUCTION=1 RELEASE_VERSION="$SPARK_VERSION" jekyll build
314-
echo "Copying release documentation to $dest_dir"
315-
# Put to new directory:
316-
LFTP mkdir -p $dest_dir || true
317-
LFTP mirror -R _site $dest_dir
318-
# Delete /latest directory and rename new upload to /latest
319-
LFTP "rm -r -f $REMOTE_PARENT_DIR/latest || exit 0"
320-
LFTP mv $dest_dir "$REMOTE_PARENT_DIR/latest"
321-
# Re-upload a second time and leave the files in the timestamped upload directory:
322-
LFTP mkdir -p $dest_dir || true
323-
LFTP mirror -R _site $dest_dir
324293
cd ..
294+
cd ..
295+
296+
svn co --depth=empty $RELEASE_STAGING_LOCATION svn-spark
297+
rm -rf "svn-spark/${DEST_DIR_NAME}-docs"
298+
mkdir -p "svn-spark/${DEST_DIR_NAME}-docs"
299+
300+
echo "Copying release documentation"
301+
cp -R "spark/docs/_site" "svn-spark/${DEST_DIR_NAME}-docs/"
302+
svn add "svn-spark/${DEST_DIR_NAME}-docs"
303+
304+
cd svn-spark
305+
svn ci --username $ASF_USERNAME --password "$ASF_PASSWORD" -m"Apache Spark $SPARK_PACKAGE_VERSION docs"
306+
cd ..
307+
rm -rf svn-spark
325308
exit 0
326309
fi
327310

@@ -399,6 +382,7 @@ if [[ "$1" == "publish-release" ]]; then
399382
find . -type f |grep -v \.jar |grep -v \.pom | xargs rm
400383

401384
echo "Creating hash and signature files"
385+
# this must have .asc, .md5 and .sha1 - it really doesn't like anything else there
402386
for file in $(find . -type f)
403387
do
404388
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --output $file.asc \

dev/create-release/release-tag.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ if [[ $@ == *"help"* ]]; then
4141
exit_with_usage
4242
fi
4343

44+
if [[ -z "$ASF_PASSWORD" ]]; then
45+
echo 'The environment variable ASF_PASSWORD is not set. Enter the password.'
46+
echo
47+
stty -echo && printf "ASF password: " && read ASF_PASSWORD && printf '\n' && stty echo
48+
fi
49+
4450
for env in ASF_USERNAME ASF_PASSWORD RELEASE_VERSION RELEASE_TAG NEXT_VERSION GIT_EMAIL GIT_NAME GIT_BRANCH; do
4551
if [ -z "${!env}" ]; then
4652
echo "$env must be set to run this script"
@@ -52,7 +58,7 @@ ASF_SPARK_REPO="git-wip-us.apache.org/repos/asf/spark.git"
5258
MVN="build/mvn --force"
5359

5460
rm -rf spark
55-
git clone https://$ASF_USERNAME:$ASF_PASSWORD@$ASF_SPARK_REPO -b $GIT_BRANCH
61+
git clone "https://$ASF_USERNAME:$ASF_PASSWORD@$ASF_SPARK_REPO" -b $GIT_BRANCH
5662
cd spark
5763

5864
git config user.name "$GIT_NAME"

0 commit comments

Comments
 (0)