-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci-deploy-central-release.sh
executable file
·157 lines (130 loc) · 4.06 KB
/
ci-deploy-central-release.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
#------------------------------------------------------------------------
# A script to deploy releases to Maven Central.
#
#------------------------------------------------------------------------
# Utility methods
fatal()
{
echo "ci-deploy-central-release.sh: fatal: $1" 1>&2
exit 1
}
info()
{
echo "ci-deploy-central-release.sh: info: $1" 1>&2
}
if [ $# -ne 1 ]
then
fatal "usage: version"
fi
if [ ! -f ".ci-local/deploy-maven-central.conf" ]
then
info ".ci-local/deploy-maven-central.conf does not exist, will not deploy binaries"
exit 0
fi
#------------------------------------------------------------------------
# Publish the built artifacts to wherever they need to go.
#
DEPLOY_DIRECTORY="$(pwd)/build/maven"
info "Artifacts will temporarily be deployed to ${DEPLOY_DIRECTORY}"
rm -rf "${DEPLOY_DIRECTORY}" || fatal "Could not ensure temporary directory is clean"
mkdir -p "${DEPLOY_DIRECTORY}" || fatal "Could not create a temporary directory"
info "Executing tagged release deployment"
./gradlew \
-PmavenCentralUsername="${MAVEN_CENTRAL_USERNAME}" \
-PmavenCentralPassword="${MAVEN_CENTRAL_PASSWORD}" \
-Psigning.gnupg.executable=gpg \
-Psigning.gnupg.useLegacyGpg=false \
-Psigning.gnupg.keyName="${MAVEN_CENTRAL_SIGNING_KEY_ID}" \
-Porg.librarysimplified.directory.publish="${DEPLOY_DIRECTORY}" \
-Dorg.gradle.internal.publish.checksums.insecure=true \
publish || fatal "Could not publish"
info "Checking signatures were created"
SIGNATURE_COUNT=$(find "${DEPLOY_DIRECTORY}" -type f -name '*.asc' | wc -l) || fatal "Could not list signatures"
info "Generated ${SIGNATURE_COUNT} signatures"
if [ "${SIGNATURE_COUNT}" -lt 2 ]
then
fatal "Too few signatures were produced! check the Gradle/PGP setup!"
fi
#------------------------------------------------------------------------
# Create a staging repository on Maven Central.
#
info "Creating a staging repository on Maven Central"
(cat <<EOF
create
--baseURI
https://s01.oss.sonatype.org/
--description
ThePalaceProject ${TIMESTAMP}
--stagingProfileId
${MAVEN_CENTRAL_STAGING_PROFILE_ID}
--user
${MAVEN_CENTRAL_USERNAME}
--password
${MAVEN_CENTRAL_PASSWORD}
EOF
) > args.txt || fatal "Could not write argument file"
MAVEN_CENTRAL_STAGING_REPOSITORY_ID=$(java -jar brooklime.jar @args.txt) || fatal "Could not create staging repository"
#------------------------------------------------------------------------
# Upload content to the staging repository on Maven Central.
#
info "Uploading content to repository ${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}"
(cat <<EOF
upload
--verbose
debug
--baseURI
https://s01.oss.sonatype.org/
--stagingProfileId
${MAVEN_CENTRAL_STAGING_PROFILE_ID}
--user
${MAVEN_CENTRAL_USERNAME}
--password
${MAVEN_CENTRAL_PASSWORD}
--directory
${DEPLOY_DIRECTORY}
--repository
${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}
--quiet
EOF
) > args.txt || fatal "Could not write argument file"
java -jar brooklime.jar @args.txt || fatal "Could not upload content"
#------------------------------------------------------------------------
# Close the staging repository.
#
info "Closing repository ${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}. This can take a few minutes."
(cat <<EOF
close
--baseURI
https://s01.oss.sonatype.org/
--stagingProfileId
${MAVEN_CENTRAL_STAGING_PROFILE_ID}
--user
${MAVEN_CENTRAL_USERNAME}
--password
${MAVEN_CENTRAL_PASSWORD}
--repository
${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}
EOF
) > args.txt || fatal "Could not write argument file"
java -jar brooklime.jar @args.txt || fatal "Could not close staging repository"
#------------------------------------------------------------------------
# Release the staging repository.
#
info "Releasing repository ${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}"
(cat <<EOF
release
--baseURI
https://s01.oss.sonatype.org/
--stagingProfileId
${MAVEN_CENTRAL_STAGING_PROFILE_ID}
--user
${MAVEN_CENTRAL_USERNAME}
--password
${MAVEN_CENTRAL_PASSWORD}
--repository
${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}
EOF
) > args.txt || fatal "Could not write argument file"
java -jar brooklime.jar @args.txt || fatal "Could not release staging repository"
info "Release completed"