This will enable artifact signing for apex uploads
[releng.git] / jjb / apex / apex-upload-artifact.sh
1 #!/bin/bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5
6 # log info to console
7 echo "Uploading the Apex artifact. This could take some time..."
8 echo "--------------------------------------------------------"
9 echo
10
11 # source the opnfv.properties to get ARTIFACT_VERSION
12 source $WORKSPACE/opnfv.properties
13
14 #this is where we import the siging key
15 source $WORKSPACE/releng/utils/gpg_import_key.sh
16
17 signrpm () {
18 for artifact in $RPM_LIST $SRPM_LIST; do
19   echo "Signing artifact: ${artifact}"
20   gpg2 -vvv --batch \
21     --default-key opnfv-helpdesk@rt.linuxfoundation.org  \
22     --passphrase besteffort \
23     --detach-sig $artifact
24     gsutil cp "$artifact".sig gs://$GS_URL/$(basename "$artifact".sig)
25     echo "Upload complete for ${artifact} signature"
26 done
27 }
28
29 signiso () {
30 time gpg2 -vvv --batch \
31   --default-key opnfv-helpdesk@rt.linuxfoundation.org  \
32   --passphrase notreallysecure \
33   --detach-sig $BUILD_DIRECTORY/release/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso
34
35 gsutil cp $BUILD_DIRECTORY/release/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso.sig gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso.sig 
36 echo "ISO signature Upload Complete!"
37 }
38
39 uploadiso () {
40 # upload artifact and additional files to google storage
41 gsutil cp $BUILD_DIRECTORY/release/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log
42 echo "ISO Upload Complete!"
43 RPM_INSTALL_PATH=$BUILD_DIRECTORY/noarch
44 RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
45 VERSION_EXTENSION=$(echo $(basename $OPNFV_RPM_URL) | sed 's/opnfv-apex-//')
46 for pkg in common undercloud opendaylight-sfc onos; do
47     RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
48 done
49 SRPM_INSTALL_PATH=$BUILD_DIRECTORY
50 SRPM_LIST=$SRPM_INSTALL_PATH/$(basename $OPNFV_SRPM_URL)
51 VERSION_EXTENSION=$(echo $(basename $OPNFV_SRPM_URL) | sed 's/opnfv-apex-//')
52 for pkg in common undercloud opendaylight-sfc onos; do
53     SRPM_LIST+=" ${SRPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
54 done
55 }
56
57 uploadrpm () {
58 #This is where we upload the rpms
59 for artifact in $RPM_LIST $SRPM_LIST; do
60   echo "Uploading artifact: ${artifact}"
61   gsutil cp $artifact gs://$GS_URL/$(basename $artifact) > gsutil.iso.log
62   echo "Upload complete for ${artifact}"
63 done
64 gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log
65 gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log
66 }
67
68 if gpg2 --list-keys | grep "opnfv-helpdesk@rt.linuxfoundation.org"; then
69   echo "Signing Key avaliable"
70   signiso
71   uploadiso
72   signrpm
73   uploadrpm
74 else
75   uploadiso
76   uploadrpm
77 fi
78
79 echo
80 echo "--------------------------------------------------------"
81 echo "Done!"
82 echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
83 echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"