-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci-deploy-central-release.sh
executable file
·144 lines (118 loc) · 3.81 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
#!/bin/bash
#------------------------------------------------------------------------
# A script to deploy releases to Maven Central.
#
#------------------------------------------------------------------------
# Utility methods
fatal()
{
echo "ci-deploy-central-snapshot.sh: fatal: $1" 1>&2
exit 1
}
info()
{
echo "ci-deploy-central-snapshot.sh: info: $1" 1>&2
}
if [ $# -ne 1 ]
then
fatal "usage: version"
fi
#------------------------------------------------------------------------
# Publish the built artifacts to wherever they need to go.
#
DEPLOY_DIRECTORY="$(pwd)/deploy"
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}" \
-Pone.irradia.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
--description
Irradia ${TIMESTAMP}
--stagingProfileId
${MAVEN_CENTRAL_STAGING_PROFILE_ID}
--user
${MAVEN_CENTRAL_USERNAME}
--password
${MAVEN_CENTRAL_PASSWORD}
--outputFile
repository.txt
EOF
) > args.txt || fatal "Could not write argument file"
java -jar brooklime.jar @args.txt || fatal "Could not create staging repository"
MAVEN_CENTRAL_STAGING_REPOSITORY_ID=$(cat repository.txt) || fatal "Could not read staging repository ID"
#------------------------------------------------------------------------
# Upload content to the staging repository on Maven Central.
#
info "Uploading content to repository ${MAVEN_CENTRAL_STAGING_REPOSITORY_ID}"
(cat <<EOF
upload
--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
--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
--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"