aws-delivlib 15.0.3 → 15.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,185 +0,0 @@
1
- #!/bin/bash
2
- set -eu # we don't want "pipefail" to implement idempotency
3
-
4
- ###
5
- # Usage: ./publish-mvn.sh
6
- #
7
- # Publishes the content of a release bundle (current directory)to Maven Central.
8
- #
9
- # This script expects the following environment variables to be set to appropriate
10
- # values (which can be achieved by using scripts/with-signing-key.sh):
11
- #
12
- # + GNUPGHOME - A GnuPG home directory containing the signing key
13
- # + KEY_ID - The ID of the GnuPG key that will be used for signing
14
- # + KEY_PASSPHRASE - The passphrase of the provided key.
15
- # + FOR_REAL - Set to "true" to do actual publishing
16
- # + STAGING_PROFILE_ID - The Maven Central (sonatype) staging profile ID (e.g. 68a05363083174)
17
- # + MAVEN_USERNAME - User name for Sonatype
18
- # + MAVEN_PASSWORD - Password for Sonatype
19
- ###
20
-
21
- error() { echo "❌ $@"; exit 1; }
22
-
23
- [ -z "${GNUPGHOME:-}" ] && error "GNUPGHOME is required"
24
- [ -z "${KEY_ID:-}" ] && error "KEY_ID is required"
25
- [ -z "${KEY_PASSPHRASE:-}" ] && echo "KEY_PASSPHRASE is required"
26
- [ -z "${STAGING_PROFILE_ID:-}" ] && echo "STAGING_PROFILE_ID is required"
27
- [ -z "${MAVEN_USERNAME:-}" ] && echo "MAVEN_USERNAME is required"
28
- [ -z "${MAVEN_PASSWORD:-}" ] && echo "MAVEN_PASSWORD is required"
29
-
30
- if [[ "${FOR_REAL:-}" == "true" ]]; then
31
- mvn=mvn
32
- dry_run=false
33
- else
34
- echo "==========================================="
35
- echo " 🏜️ DRY-RUN MODE 🏜️"
36
- echo
37
- echo "Set FOR_REAL=true to do actual publishing!"
38
- echo "==========================================="
39
- mvn="echo mvn"
40
- dry_run=true
41
- fi
42
-
43
- staging=$(mktemp -d)
44
- workdir=$(mktemp -d)
45
-
46
- if [[ ! -d ./java ]]; then
47
- echo "❌ No JARS to publish: 'java/' directory is missing."
48
- exit 1
49
- fi
50
-
51
- echo "📦 Publishing to Maven Central"
52
-
53
- # Create a settings.xml file with the user+password for maven
54
- mvn_settings="${workdir}/mvn-settings.xml"
55
- cat > ${mvn_settings} <<-EOF
56
- <?xml version="1.0" encoding="UTF-8" ?>
57
- <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
58
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
59
- xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
60
- http://maven.apache.org/xsd/settings-1.0.0.xsd">
61
- <servers>
62
- <server>
63
- <id>ossrh</id>
64
- <username>${MAVEN_USERNAME}</username>
65
- <password>${MAVEN_PASSWORD}</password>
66
- </server>
67
- </servers>
68
- </settings>
69
- EOF
70
-
71
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
72
- echo " Preparing repository"
73
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
74
-
75
- # Sign and stage our artifacts into a local directory
76
- found=false
77
- for pom in $(find ./java -name '*.pom'); do
78
- found=true
79
-
80
- source_arg=""
81
- if [[ -f ${pom/.pom/-sources.jar} ]]; then
82
- source_arg="-Dsources=${pom/.pom/-sources.jar}"
83
- fi
84
-
85
- javadoc_arg=""
86
- if [[ -f ${pom/.pom/-javadoc.jar} ]]; then
87
- javadoc_arg="-Djavadoc=${pom/.pom/-javadoc.jar}"
88
- fi
89
-
90
- $mvn --settings=${mvn_settings} gpg:sign-and-deploy-file \
91
- -Durl=file://${staging} \
92
- -DrepositoryId=maven-central \
93
- -Dgpg.homedir=${GNUPGHOME} \
94
- -Dgpg.keyname=0x${KEY_ID} \
95
- -Dgpg.passphrase=${KEY_PASSPHRASE} \
96
- -DpomFile=${pom} \
97
- -Dfile=${pom/.pom/.jar} \
98
- $source_arg \
99
- $javadoc_arg
100
- done
101
-
102
- if ! $found; then
103
- echo "❌ No JARS to publish: no .pom files found in java/ directory."
104
- exit 1
105
- fi
106
-
107
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
108
- echo " Deploying and closing repository..."
109
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
110
-
111
- nexus_staging_maven_plugin_version='1.6.13'
112
- staging_output="${workdir}/deploy-output.txt"
113
- $mvn --settings=${mvn_settings} \
114
- org.sonatype.plugins:nexus-staging-maven-plugin:${nexus_staging_maven_plugin_version}:deploy-staged-repository \
115
- -DrepositoryDirectory=${staging} \
116
- -DnexusUrl=${MAVEN_ENDPOINT:-https://oss.sonatype.org} \
117
- -DserverId=ossrh \
118
- -DautoReleaseAfterClose=true \
119
- -DstagingProgressTimeoutMinutes=10 \
120
- -DstagingProfileId=${STAGING_PROFILE_ID} | tee ${staging_output}
121
-
122
- # we need to consule PIPESTATUS sinec "tee" is the last command
123
- if [ ${PIPESTATUS[0]} -ne 0 ]; then
124
- echo "❌ Repository deployment failed"
125
- exit 1
126
- fi
127
-
128
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
129
- echo " Releasing repository"
130
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
131
-
132
- # Extract the ID of the closed repository from the log output of "deploy-staged-repository"
133
- # This is because "deploy-staged-repository" doesn't seem to support autoReleaseAfterClose
134
- # See https://issues.sonatype.org/browse/OSSRH-42487
135
- if $dry_run; then
136
- echo 'Closing staging repository with ID "dummyrepo"' > ${staging_output}
137
- fi
138
-
139
- repository_id="$(cat ${staging_output} | grep "Closing staging repository with ID" | cut -d'"' -f2)"
140
- if [ -z "${repository_id}" ]; then
141
- echo "❌ Unable to extract repository ID from deploy-staged-repository output."
142
- echo "This means it failed to close or there was an unexpected problem."
143
- echo "At any rate, we can't release it. Sorry"
144
- exit 1
145
- fi
146
-
147
- echo "Repository ID: ${repository_id}"
148
-
149
- # Create a dummy pom.xml because the "release" goal needs one, but it doesn't care about it at all
150
- release_pom="${workdir}/release-pom.xml"
151
- cat > ${release_pom} <<HERE
152
- <?xml version="1.0" encoding="UTF-8"?>
153
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
154
- <modelVersion>4.0.0</modelVersion>
155
- <groupId>dummy</groupId>
156
- <artifactId>dummy</artifactId>
157
- <version>0.0.0</version>
158
- </project>
159
- HERE
160
-
161
- # Release!
162
- release_output="${workdir}/release-output.txt"
163
- export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
164
- $mvn --settings ${mvn_settings} -f ${release_pom} \
165
- org.sonatype.plugins:nexus-staging-maven-plugin:${nexus_staging_maven_plugin_version}:release \
166
- -DserverId=ossrh \
167
- -DnexusUrl=${MAVEN_ENDPOINT:-https://oss.sonatype.org} \
168
- -DstagingProfileId=${STAGING_PROFILE_ID} \
169
- -DstagingRepositoryId=${repository_id} | tee ${release_output}
170
-
171
- # If release failed, check if this was caused because we are trying to publish
172
- # the same version again, which is not an error. The magic string "does not
173
- # allow updating artifact" for a ".pom" file indicates that we are trying to
174
- # override an existing version. Otherwise, fail!
175
- if [ ${PIPESTATUS[0]} -ne 0 ]; then
176
- if cat ${release_output} | grep "does not allow updating artifact" | grep -q ".pom"; then
177
- echo "⚠️ Artifact already published. Skipping"
178
- else
179
- echo "❌ Release failed"
180
- exit 1
181
- fi
182
- fi
183
-
184
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
185
- echo "✅ All Done!"