forked from NVIDIA/spark-rapids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·124 lines (111 loc) · 4.99 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
#
# Copyright (c) 2020-2024, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Argument(s):
# SIGN_FILE: true/false, whether to sign the jar/pom file to de deployed
#
# Used environment(s):
# SQL_PL: The path of module 'sql-plugin', relative to project root path.
# DIST_PL: The path of module 'dist', relative to project root path.
# SERVER_ID: The repository id for this deployment.
# SERVER_URL: The url where to deploy artifacts.
# GPG_PASSPHRASE: The passphrase used to sign files, only required when <SIGN_FILE> is true.
# SIGN_TOOL: Tool to sign files, e.g., gpg, nvsec, only required when $1 is 'true'
# GPG_PASSPHRASE: gpg passphrase to sign artifacts, only required when <SIGN_TOOL> is gpg
# MVN_SETTINGS: Maven configuration file
# POM_FILE: Project pom file to be deployed
# OUT_PATH: The path where jar files are
# CUDA_CLASSIFIERS: Comma separated classifiers, e.g., "cuda11,cuda12"
# CLASSIFIERS: Comma separated classifiers, e.g., "cuda11,cuda12,cuda11-arm64,cuda12-arm64"
# DEFAULT_CUDA_CLASSIFIER: The default cuda classifer, will get from project's pom.xml if not set
###
set -ex
SIGN_FILE=${1:-"false"}
DIST_PL=${DIST_PL:-"dist"}
###### Build the path of jar(s) to be deployed ######
MVN_SETTINGS=${MVN_SETTINGS:-"jenkins/settings.xml"}
MVN="mvn -B -Dmaven.wagon.http.retryHandler.count=3 -DretryFailedDeploymentCount=3 -s $MVN_SETTINGS"
function mvnEval {
$MVN help:evaluate -q -DforceStdout -pl $1 -Dexpression=$2
}
ART_ID=$(mvnEval $DIST_PL project.artifactId)
ART_GROUP_ID=$(mvnEval $DIST_PL project.groupId)
ART_VER=$(mvnEval $DIST_PL project.version)
DEFAULT_CUDA_CLASSIFIER=${DEFAULT_CUDA_CLASSIFIER:-$(mvnEval $DIST_PL cuda.version)}
CUDA_CLASSIFIERS=${CUDA_CLASSIFIERS:-"$DEFAULT_CUDA_CLASSIFIER"}
CLASSIFIERS=${CLASSIFIERS:-"$CUDA_CLASSIFIERS"} # default as CUDA_CLASSIFIERS for compatibility
SERVER_ID=${SERVER_ID:-"snapshots"}
SERVER_URL=${SERVER_URL:-"file:/tmp/local-release-repo"}
# Save to be deployed artifact list into the file, e.g.
ARTIFACT_FILE=${ARTIFACT_FILE:-"/tmp/artifact-file"}
# Clean rtifact list file befor saving
rm -rf $ARTIFACT_FILE
SQL_PL=${SQL_PL:-"sql-plugin"}
POM_FILE=${POM_FILE:-"$DIST_PL/target/parallel-world/META-INF/maven/${ART_GROUP_ID}/${ART_ID}/pom.xml"}
OUT_PATH=${OUT_PATH:-"$DIST_PL/target"}
SIGN_TOOL=${SIGN_TOOL:-"gpg"}
FPATH="$OUT_PATH/$ART_ID-$ART_VER"
DEPLOY_TYPES=''
DEPLOY_FILES=''
DEPLOY_TYPES=$(echo $CLASSIFIERS | sed -e 's;[^,]*;jar;g')
DEPLOY_FILES=$(echo $CLASSIFIERS | sed -e "s;\([^,]*\);${FPATH}-\1.jar;g")
# dist does not have javadoc and sources jars, use 'sql-plugin' instead
SQL_ART_ID=$(mvnEval $SQL_PL project.artifactId)
SQL_ART_VER=$(mvnEval $SQL_PL project.version)
JS_FPATH="$(echo -n ${SQL_PL}/target/spark*)/${SQL_ART_ID}-${SQL_ART_VER}"
cp $JS_FPATH-sources.jar $FPATH-sources.jar
cp $JS_FPATH-javadoc.jar $FPATH-javadoc.jar
echo "Plan to deploy ${FPATH}.jar to $SERVER_URL (ID:$SERVER_ID)"
GPG_PLUGIN="org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file"
###### Choose the deploy command ######
if [ "$SIGN_FILE" == true ]; then
case $SIGN_TOOL in
nvsec)
DEPLOY_CMD="$MVN $GPG_PLUGIN -Dgpg.executable=nvsec_sign"
;;
gpg)
DEPLOY_CMD="$MVN $GPG_PLUGIN -Dgpg.passphrase=$GPG_PASSPHRASE "
;;
*)
echo "Error unsupported sign type : $SIGN_TYPE !"
echo "Please set variable SIGN_TOOL 'nvsec'or 'gpg'"
exit -1
;;
esac
else
DEPLOY_CMD="$MVN -B deploy:deploy-file -s jenkins/settings.xml"
fi
DEPLOY_CMD="$DEPLOY_CMD -Durl=$SERVER_URL -DrepositoryId=$SERVER_ID"
echo "Deploy CMD: $DEPLOY_CMD"
###### Deploy the parent pom file ######
$DEPLOY_CMD -Dfile=./pom.xml -DpomFile=./pom.xml
###### Deploy the jdk-profile pom file ######
JDK_PROFILES=${JDK_PROFILES:-"jdk-profiles"}
$DEPLOY_CMD -Dfile=$JDK_PROFILES/pom.xml -DpomFile=$JDK_PROFILES/pom.xml
###### Deploy the artifact jar(s) ######
$DEPLOY_CMD -DpomFile=$POM_FILE \
-Dfile=$FPATH-$DEFAULT_CUDA_CLASSIFIER.jar \
-Dsources=$FPATH-sources.jar \
-Djavadoc=$FPATH-javadoc.jar \
-Dfiles=$DEPLOY_FILES \
-Dtypes=$DEPLOY_TYPES \
-Dclassifiers=$CLASSIFIERS
echo "$ART_GROUP_ID:$ART_ID:$ART_VER:jar" >> $ARTIFACT_FILE
CLASSLIST="$CLASSIFIERS,sources,javadoc"
CLASSLIST=(${CLASSLIST//','/' '})
for class in ${CLASSLIST[@]}; do
echo "$ART_GROUP_ID:$ART_ID:$ART_VER:jar:$class" >> $ARTIFACT_FILE
done