@@ -38,7 +38,9 @@ RC_NAME=${RC_NAME:-rc2}
38
38
39
39
M2_REPO=~ /.m2/repository
40
40
SPARK_REPO=$M2_REPO /org/apache/spark
41
- NEXUS_REPOSITORY=https://repository.apache.org/service/local/staging/deploy/maven2
41
+ NEXUS_ROOT=https://repository.apache.org/service/local/staging
42
+ NEXUS_UPLOAD=$NEXUS_ROOT /deploy/maven2
43
+ NEXUS_PROFILE=d63f592e7eac0 # Profile for Spark staging uploads
42
44
43
45
if [ -z " $JAVA_HOME " ]; then
44
46
echo " Error: JAVA_HOME is not set, cannot proceed."
@@ -78,10 +80,16 @@ if [[ ! "$@" =~ --package-only ]]; then
78
80
git push origin $GIT_TAG
79
81
git push origin HEAD:$GIT_BRANCH
80
82
git checkout -f $GIT_TAG
81
-
82
- # TODO: Programatically create and close Maven repo:
83
- # curl -X POST -d @file.xml -u USER:PASS -H "Content-Type:application/xml" -v https://repository.apache.org/service/local/staging/profiles/d63f592e7eac0/start
83
+
84
+ # Using Nexus API documented here:
84
85
# https://support.sonatype.com/entries/39720203-Uploading-to-a-Staging-Repository-via-REST-API
86
+ echo " Creating Nexus staging repository"
87
+ repo_request=" <promoteRequest><data><description>Apache Spark $GIT_TAG </description></data></promoteRequest>"
88
+ out=$( curl -X POST -d " $repo_request " -u $ASF_USERNAME :$ASF_PASSWORD \
89
+ -H " Content-Type:application/xml" -v \
90
+ $NEXUS_ROOT /profiles/$NEXUS_PROFILE /start)
91
+ staged_repo_id=$( echo $out | sed -e " s/.*\(orgapachespark-[0-9]\{4\}\).*/\1/" )
92
+ echo " Created Nexus staging repository: $staged_repo_id "
85
93
86
94
rm -rf $SPARK_REPO
87
95
@@ -110,17 +118,24 @@ if [[ ! "$@" =~ --package-only ]]; then
110
118
gpg --print-md SHA1 $file > $file .sha1
111
119
done
112
120
113
- echo " Uplading files to $NEXUS_REPOSITORY "
121
+ echo " Uplading files to $NEXUS_UPLOAD "
114
122
for file in $( find . -type f)
115
123
do
116
124
# strip leading ./
117
125
file_short=$( echo $file | sed -e " s/\.\///" )
118
- dest_url=" $NEXUS_REPOSITORY /org/apache/spark/$file_short "
126
+ dest_url=" $NEXUS_UPLOAD /org/apache/spark/$file_short "
119
127
echo " Uploading $file_short "
120
128
curl -u $ASF_USERNAME :$ASF_PASSWORD --upload-file $file_short $dest_url
121
129
done
122
- popd
123
130
131
+ echo " Closing nexus staging repository"
132
+ repo_request=" <promoteRequest><data><stagedRepositoryId>$staged_repo_id </stagedRepositoryId><description>Apache Spark $GIT_TAG </description></data></promoteRequest>"
133
+ out=$( curl -X POST -d " $repo_request " -u $ASF_USERNAME :$ASF_PASSWORD \
134
+ -H " Content-Type:application/xml" -v \
135
+ $NEXUS_ROOT /profiles/$NEXUS_PROFILE /finish)
136
+ echo " Closed Nexus staging repository: $staged_repo_id "
137
+
138
+ popd
124
139
popd
125
140
rm -rf spark
126
141
fi
0 commit comments