From ae4046990f738d0acc76a6c94da33e370c492a1a Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Mon, 22 Feb 2016 19:44:56 +0100 Subject: [PATCH] added script for publishing of p2 repo to bintray Signed-off-by: Kai Kreuzer --- features/repo/pom.xml | 33 ++++++++++- .../filtered-resources/publish-bintray.sh | 58 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100755 features/repo/src/main/filtered-resources/publish-bintray.sh diff --git a/features/repo/pom.xml b/features/repo/pom.xml index 6d717c389..c455720d1 100644 --- a/features/repo/pom.xml +++ b/features/repo/pom.xml @@ -12,8 +12,39 @@ org.openhab.core.features org.openhab.repo - openHAB P2 Repository + openHAB Core P2 Repository eclipse-repository + + + + maven-resources-plugin + 2.4.3 + + + default-resources + process-resources + + resources + + + ${project.build.directory} + + + + + + + + + src/main/filtered-resources + true + + **/* + + + + + diff --git a/features/repo/src/main/filtered-resources/publish-bintray.sh b/features/repo/src/main/filtered-resources/publish-bintray.sh new file mode 100755 index 000000000..3cea7e732 --- /dev/null +++ b/features/repo/src/main/filtered-resources/publish-bintray.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Publish p2 repo to bintray +# Usage: publish-bintray.sh user owner apikey +# +BINTRAY_URL=https://api.bintray.com/ +BINTRAY_REPO=p2 +BINTRAY_PACKAGE=openhab-core +PACKAGE_VERSION=${project.version} +PACKAGE_ARCHIVE=${project.build.finalName}.zip +PACKAGE_PATH=openhab-core/$PACKAGE_VERSION + +if [ "x$1" != "x" ]; then + BINTRAY_SUBJECT=$1 +fi +if [ "x$2" != "x" ]; then + BINTRAY_USER=$2 +fi +if [ "x$3" != "x" ]; then + BINTRAY_API_KEY=$3 +fi + + +DIRNAME=`dirname "$0"` + +function main() { + + cd $DIRNAME + + echo "Creating version $PACKAGE_VERSION ..." + response=$(curl -s -X POST -u ${BINTRAY_USER}:${BINTRAY_API_KEY} $BINTRAY_URL/packages/$BINTRAY_SUBJECT/$BINTRAY_REPO/$BINTRAY_PACKAGE/versions -d "{ \"name\": \"${PACKAGE_VERSION}\", \"desc\": \"Release ${PACKAGE_VERSION}\" }" -H "Content-Type: application/json") + if [[ $response == *"ordinal"* ]] + then + echo "Version created: $response" + elif [[ $response == *"already exists"* ]] + then + echo "Version exists: $response" + else + echo "Failed to create version: $response" + exit 1; + fi + + echo "Uploading archive $PACKAGE_ARCHIVE" + response=$(curl -s -X PUT --data-binary @$PACKAGE_ARCHIVE -u ${BINTRAY_USER}:${BINTRAY_API_KEY} "$BINTRAY_URL/content/$BINTRAY_SUBJECT/$BINTRAY_REPO/$PACKAGE_PATH/$PACKAGE_ARCHIVE;bt_package=$BINTRAY_PACKAGE;bt_version=$PACKAGE_VERSION;publish=1;explode=1;override=1" -H "Content-Type: application/zip") + if [[ $response == *"success"* ]] + then + echo "Archive uploaded: $response" + elif [[ $response == *"No files will be signed"* ]] + then + echo "Archive uploaded without signature: $response" + else + echo "Error uploading: $response" + exit 1; + fi +} + +main "$@" +