-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.sh
executable file
·109 lines (98 loc) · 3.81 KB
/
common.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
#!/usr/bin/env bash
[[ $TRACE_ENABLED == "true" ]] && set -x
if [[ -f "${MAVEN_RELEASE_SETTINGS_XML}" ]]
then
# Use the provided Maven settings.xml
echo
echo "------------------------------------------------------------------------------"
echo "Using the provided Maven settings: ${MAVEN_RELEASE_SETTINGS_XML}"
echo "------------------------------------------------------------------------------"
export MAVEN_CONFIG="-s ${MAVEN_RELEASE_SETTINGS_XML}"
else
# Use the template we provide that resides in the docker image
echo
echo "------------------------------------------------------------------------------"
echo "Using the built-in Maven settings template as ${MAVEN_RELEASE_SETTINGS_XML} does not exist"
echo "------------------------------------------------------------------------------"
export MAVEN_CONFIG="-s ${GITHUB_ACTION_PATH}/settings.xml"
fi
RELEASE_ARGUMENTS="${RELEASE_ARGUMENTS:-}"
if [[ ! -z "${MAVEN_RELEASE_TAG}" ]];
then
RELEASE_ARGUMENTS="${RELEASE_ARGUMENTS} -Dtag=${MAVEN_RELEASE_TAG}"
fi
if [[ ! -z "${MAVEN_RELEASE_VERSION}" ]];
then
RELEASE_ARGUMENTS="${RELEASE_ARGUMENTS} -DreleaseVersion=${MAVEN_RELEASE_VERSION}"
fi
if [[ ! -z "${MAVEN_NEXT_DEVELOPMENT_VERSION}" ]];
then
RELEASE_ARGUMENTS="${RELEASE_ARGUMENTS} -DdevelopmentVersion=${MAVEN_NEXT_DEVELOPMENT_VERSION}"
fi
export RELEASE_ARGUMENTS="${RELEASE_ARGUMENTS}"
function mavenCoordinateToArtifactPath() {
# Standard format for a Maven coordinate:
# <groupId>:<artifactId>[:<extension>[:classifier]]:<version>
# $1 = coordinate
IFS=':' read -ra coordinateParts <<< "$1"
groupId=$(echo ${coordinateParts[0]} | sed 's/\./\//g')
artifactId=${coordinateParts[1]}
if [ ${#coordinateParts[@]} -eq 3 ]; then
# <groupId>:<artifactId>:<version>
version=${coordinateParts[2]}
artifactPath="${groupId}/${artifactId}/${version}/${artifactId}-${version}.jar"
elif [ ${#coordinateParts[@]} -eq 4 ]; then
# <groupId>:<artifactId>:<extension>:<version>
version=${coordinateParts[3]}
extension=${coordinateParts[2]}
artifactPath="${groupId}/${artifactId}/${version}/${artifactId}-${version}.${extension}"
elif [ ${#coordinateParts[@]} -eq 5 ]; then
# <groupId>:<artifactId>:<extension>:<classifier>:<version>
version=${coordinateParts[4]}
extension=${coordinateParts[2]}
classifier=${coordinateParts[3]}
artifactPath="${groupId}/${artifactId}/${version}/${artifactId}-${version}-${classifier}.${extension}"
fi
echo $artifactPath
}
function mavenMetadataPath() {
# Standard format for a Maven coordinate:
# <groupId>:<artifactId>[:<extension>[:classifier]]:<version>
# $1 = coordinate
IFS=':' read -ra coordinateParts <<< "$1"
groupId=$(echo ${coordinateParts[0]} | sed 's/\./\//g')
artifactId=${coordinateParts[1]}
if [ ${#coordinateParts[@]} -eq 3 ]; then
# <groupId>:<artifactId>:<version>
version=${coordinateParts[2]}
metadataPath="${groupId}/${artifactId}/maven-metadata.xml"
elif [ ${#coordinateParts[@]} -eq 4 ]; then
# <groupId>:<artifactId>:<extension>:<version>
version=${coordinateParts[3]}
extension=${coordinateParts[2]}
metadataPath="${groupId}/${artifactId}/${version}/maven-metadata.xml"
elif [ ${#coordinateParts[@]} -eq 5 ]; then
# <groupId>:<artifactId>:<extension>:<classifier>:<version>
version=${coordinateParts[4]}
extension=${coordinateParts[2]}
classifier=${coordinateParts[3]}
metadataPath="${groupId}/${artifactId}/${version}/maven-metadata.xml"
fi
echo $metadataPath
}
function mavenProjectVersion() {
${MAVEN_BIN} -f "${MAVEN_PROJECT_POM}" -q \
help:evaluate \
-Dexpression=project.version \
-DforceStdout
}
function set_output() {
# $1 = key
# $2 = value
delimiter="$(openssl rand -hex 8)"
{
echo "${1}<<${delimiter}"
echo "$2"
echo "${delimiter}"
} >> "$GITHUB_OUTPUT"
}