Ray Milkey | 041d449 | 2022-01-05 11:33:10 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2020-present Open Networking Foundation. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | set -eu -o pipefail |
| 17 | |
| 18 | if [ $# != 2 ]; then |
| 19 | echo Usage: push-karaf version directory |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | PLUGIN_VERSION=$1 |
| 24 | DIRECTORY=$2 |
| 25 | SONATYPE_USER=${SONATYPE_USER:-""} |
| 26 | SONATYPE_PASSWORD=${SONATYPE_PASSWORD:-""} |
| 27 | |
| 28 | if [ "$SONATYPE_USER" == "" -o "$SONATYPE_PASSWORD" == "" ]; then |
| 29 | echo SONATYPE_USER and SONATYPE_PASSWORD must be set |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | PLUGIN_FILE="$DIRECTORY/apache-karaf-${PLUGIN_VERSION}.tar.gz" |
| 34 | BASE_ARTIFACT_NAME="apache-karaf" |
| 35 | |
| 36 | UPLOAD_BASE="https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/apache-karaf-offline/$PLUGIN_VERSION" |
| 37 | |
| 38 | # Make the signature file |
| 39 | gpg --armor --detach-sig $PLUGIN_FILE |
| 40 | |
| 41 | # Make the MD5 checksum file |
| 42 | md5 -q $PLUGIN_FILE >$PLUGIN_FILE.md5 |
| 43 | |
| 44 | # Make the SHA1 checksum file |
| 45 | ( shasum $PLUGIN_FILE | cut -d' ' -f1 ) > $PLUGIN_FILE.sha1 |
| 46 | |
| 47 | curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE $UPLOAD_BASE/$BASE_ARTIFACT_NAME-$PLUGIN_VERSION.tar.gz |
| 48 | curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE.asc $UPLOAD_BASE/$BASE_ARTIFACT_NAME-$PLUGIN_VERSION.tar.gz.asc |
| 49 | curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE.md5 $UPLOAD_BASE/$BASE_ARTIFACT_NAME-$PLUGIN_VERSION.tar.gz.md5 |
| 50 | curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE.sha1 $UPLOAD_BASE/$BASE_ARTIFACT_NAME-$PLUGIN_VERSION.tar.gz.sha1 |