1+ #! /bin/bash
2+
3+ # # set variables/constants required by the script
4+
5+ # The version of the package that will be build and will be visible in maven central
6+ # For Approov SDK release 3.3.0 (library 7257) the version was 3.3.0
7+ # This is also used to rename the folder where the package is stored by replacing the TAG-RENAME-DIR
8+ # THE POM FILE MUST BE UPDATED WITH THE CORRECT VERSION WHICH MUST MATCH THIS VARIABLE
9+ VERSION=" 3.3.0"
10+
11+ # Constant: current package name
12+ CURRENT_PACKAGE_NAME=" service.httpsurlconn"
13+
14+ # Constant: Required package subdir structure
15+ PACKAGE_DIR_STRUCTURE=" io/approov/${CURRENT_PACKAGE_NAME} "
16+
17+ # Constant: The file prefix for each file placed in the above directory
18+ # NOTE: This is also the name of the binary SDK file expected by Maven
19+ FILE_PREFIX=" ${CURRENT_PACKAGE_NAME} -${VERSION} "
20+
21+ # The PGP Key ID to use for signing the package; set by CI/CD
22+ # export PGP_KEY_ID=""
23+ # Verify that the PGP_KEY_ID is set
24+ if [ -z " $PGP_KEY_ID " ]; then
25+ echo " Error: PGP_KEY_ID is not set. This script requires a PGP key ID to be set."
26+ exit 1
27+ fi
28+ # Password for the GPG key; set by CI/CD
29+ # export GPG_PASSWORD=""
30+ # Verify that the GPG_PASSWORD is set
31+ if [ -z " $GPG_PASSWORD " ]; then
32+ echo " Error: GPG_PASSWORD is not set. This script requires a GPG password to be set."
33+ exit 1
34+ fi
35+
36+ # The full path to the service aar package generated by gradle build.
37+ AAR_PATH=" ../approov-service/build/outputs/aar/approov-service-release.aar"
38+
39+
40+ # The path to the javadoc.jar file that will be uploaded to maven central
41+ JAVADOC_JAR_PATH=" ../approov-service/docs/javadoc.jar"
42+
43+ # Path to the POM file: YOU MUST UPDATE THIS FILE WITH THE CORRECT <version
44+ # which MUST match the VERSION variable above
45+ POM_FILE_PATH=" ../approov-service/pom.xml"
46+
47+ # Check if the above files exist before proceeding further
48+ if [ ! -f ${AAR_PATH} ]; then
49+ echo " File not found: ${AAR_PATH} "
50+ echo " Please make sure the file exists or change the location in the script and try again"
51+ exit 1
52+ fi
53+
54+ if [ ! -f ${JAVADOC_JAR_PATH} ]; then
55+ echo " File not found: ${JAVADOC_JAR_PATH} "
56+ echo " Please make sure the file exists or change the location in the script and try again"
57+ exit 1
58+ fi
59+
60+ if [ ! -f ${POM_FILE_PATH} ]; then
61+ echo " File not found: ${POM_FILE_PATH} "
62+ echo " Please make sure the file exists or change the location in the script and try again"
63+ exit 1
64+ fi
65+
66+
67+ # The destination directory to place all the files
68+ DESTINATION_DIR=" ${PACKAGE_DIR_STRUCTURE} /${VERSION} "
69+
70+ echo " Will create destination directory: ${DESTINATION_DIR} "
71+ # Create destination directory in current location
72+ mkdir -p ${DESTINATION_DIR}
73+ # Check if the command was successful
74+ if [ $? -eq 0 ]; then
75+ echo " File successfully created: ${DESTINATION_DIR} "
76+ else
77+ echo " Failed to create directory ${DESTINATION_DIR} "
78+ exit 1
79+ fi
80+
81+ # Copy operations to destination directory
82+ # 1. Copy javadoc.jar file and rename to destination:
83+ # Maven expects for version 3.2.2 of the javadoc.jar the following file
84+ # service.httpsurlconn-3.2.2-javadoc.jar
85+ cp ${JAVADOC_JAR_PATH} ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar
86+
87+ # Check if the command was successful
88+ if [ $? -eq 0 ]; then
89+ echo " File successfully copied: ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar"
90+ else
91+ echo " Failed to copy file as ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar"
92+ exit 1
93+ fi
94+
95+ # Sign the target javadoc file
96+ OUTPUT_SIGNATURE=" ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.asc"
97+ gpg --batch --yes --passphrase " $GPG_PASSWORD " --pinentry-mode loopback --output " $OUTPUT_SIGNATURE " --detach-sign --local-user " $PGP_KEY_ID " " ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar"
98+
99+ # Check if the command was successful
100+ if [ $? -eq 0 ]; then
101+ echo " File successfully signed: ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.asc"
102+ else
103+ echo " Failed to sign file as ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.asc"
104+ exit 1
105+ fi
106+ # Compute hashes for the javadoc file
107+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.sha1"
108+ # Compute SHA-1 and extract only the hash
109+ shasum " ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar" | awk ' {print $1}' > " $OUTPUT_FILE "
110+ # sha256
111+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.sha256"
112+ shasum -a 256 " ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar" | awk ' {print $1}' > " $OUTPUT_FILE "
113+ # sha512
114+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.sha512"
115+ shasum -a 512 " ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar" | awk ' {print $1}' > " $OUTPUT_FILE "
116+ # md5
117+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar.md5"
118+ md5sum " ${DESTINATION_DIR} /${FILE_PREFIX} -javadoc.jar" | awk ' {print $1}' > " $OUTPUT_FILE "
119+
120+
121+ # 2. Copy the aar file and rename to destination:
122+ # Maven expects for version 3.2.2 of the aar file the following file
123+ # service.httpsurlconn-3.2.2.aar
124+ cp ${AAR_PATH} ${DESTINATION_DIR} /${FILE_PREFIX} .aar
125+
126+ # Check if the command was successful
127+ if [ $? -eq 0 ]; then
128+ echo " File successfully copied: ${DESTINATION_DIR} /${FILE_PREFIX} .aar"
129+ else
130+ echo " Failed to copy file as ${DESTINATION_DIR} /${FILE_PREFIX} .aar"
131+ exit 1
132+ fi
133+
134+ # Sign the android SDK aar file
135+ OUTPUT_SIGNATURE=" ${DESTINATION_DIR} /${FILE_PREFIX} .aar.asc"
136+ gpg --batch --yes --passphrase " $GPG_PASSWORD " --pinentry-mode loopback --output " $OUTPUT_SIGNATURE " --detach-sign --local-user " $PGP_KEY_ID " " ${DESTINATION_DIR} /${FILE_PREFIX} .aar"
137+
138+ # Check if the command was successful
139+ if [ $? -eq 0 ]; then
140+ echo " File successfully signed: ${DESTINATION_DIR} /${FILE_PREFIX} .aar.asc"
141+ else
142+ echo " Failed to sign file as ${DESTINATION_DIR} /${FILE_PREFIX} .aar.asc"
143+ exit 1
144+ fi
145+
146+ # Compute hashes for the aar file
147+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .aar.sha1"
148+ # Compute SHA-1 and extract only the hash
149+ shasum " ${DESTINATION_DIR} /${FILE_PREFIX} .aar" | awk ' {print $1}' > " $OUTPUT_FILE "
150+ # sha256
151+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .aar.sha256"
152+ shasum -a 256 " ${DESTINATION_DIR} /${FILE_PREFIX} .aar" | awk ' {print $1}' > " $OUTPUT_FILE "
153+ # sha512
154+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .aar.sha512"
155+ shasum -a 512 " ${DESTINATION_DIR} /${FILE_PREFIX} .aar" | awk ' {print $1}' > " $OUTPUT_FILE "
156+ # md5
157+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .aar.md5"
158+ md5sum " ${DESTINATION_DIR} /${FILE_PREFIX} .aar" | awk ' {print $1}' > " $OUTPUT_FILE "
159+
160+
161+ # 3. Copy the pom file and rename to destination:
162+ # Maven expects for version 3.2.2 of the pom file the following file
163+ # service.httpsurlconn-3.2.2.pom
164+ cp ${POM_FILE_PATH} ${DESTINATION_DIR} /${FILE_PREFIX} .pom
165+
166+ # Check if the command was successful
167+ if [ $? -eq 0 ]; then
168+ echo " File successfully copied: ${DESTINATION_DIR} /${FILE_PREFIX} .pom"
169+ else
170+ echo " Failed to copy file as ${DESTINATION_DIR} /${FILE_PREFIX} .pom"
171+ exit 1
172+ fi
173+
174+ # Sign the pom file
175+ OUTPUT_SIGNATURE=" ${DESTINATION_DIR} /${FILE_PREFIX} .pom.asc"
176+ gpg --batch --yes --passphrase " $GPG_PASSWORD " --pinentry-mode loopback --output " $OUTPUT_SIGNATURE " --detach-sign --local-user " $PGP_KEY_ID " " ${DESTINATION_DIR} /${FILE_PREFIX} .pom"
177+
178+ # Check if the command was successful
179+ if [ $? -eq 0 ]; then
180+ echo " File successfully signed: ${DESTINATION_DIR} /${FILE_PREFIX} .pom.asc"
181+ else
182+ echo " Failed to sign file as ${DESTINATION_DIR} /${FILE_PREFIX} .pom.asc"
183+ exit 1
184+ fi
185+
186+ # Compute hashes for the pom file
187+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .pom.sha1"
188+ # Compute SHA-1 and extract only the hash
189+ shasum " ${DESTINATION_DIR} /${FILE_PREFIX} .pom" | awk ' {print $1}' > " $OUTPUT_FILE "
190+ # sha256
191+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .pom.sha256"
192+ shasum -a 256 " ${DESTINATION_DIR} /${FILE_PREFIX} .pom" | awk ' {print $1}' > " $OUTPUT_FILE "
193+ # sha512
194+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .pom.sha512"
195+ shasum -a 512 " ${DESTINATION_DIR} /${FILE_PREFIX} .pom" | awk ' {print $1}' > " $OUTPUT_FILE "
196+ # md5
197+ OUTPUT_FILE=" ${DESTINATION_DIR} /${FILE_PREFIX} .pom.md5"
198+ md5sum " ${DESTINATION_DIR} /${FILE_PREFIX} .pom" | awk ' {print $1}' > " $OUTPUT_FILE "
199+
200+ # Force remove recursively all the .DS_Store files that might have been copied
201+ find " io/" -name " .DS_Store" -type f -delete
202+ # Finally zip the io/ directory and save it in current directory as ${FILE_PREFIX}.zip
203+ zip -r ${FILE_PREFIX} .zip " io"
204+
205+ # Test if the zip file was created
206+ if [ -f " ${FILE_PREFIX} .zip" ]; then
207+ echo " Zip file created successfully: ${FILE_PREFIX} .zip"
208+ else
209+ echo " Failed to create zip file: ${FILE_PREFIX} .zip"
210+ exit 1
211+ fi
212+
213+ # Copy the zip file to the destination directory to inspect
214+ cp ${FILE_PREFIX} .zip ../
0 commit comments