added script for publishing of p2 repo to bintray

Signed-off-by: Kai Kreuzer <kai@openhab.org>
pull/27/head
Kai Kreuzer 2016-02-22 19:44:56 +01:00
parent a06982b442
commit ae4046990f
2 changed files with 90 additions and 1 deletions

View File

@ -12,8 +12,39 @@
<groupId>org.openhab.core.features</groupId>
<artifactId>org.openhab.repo</artifactId>
<name>openHAB P2 Repository</name>
<name>openHAB Core P2 Repository</name>
<packaging>eclipse-repository</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/filtered-resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@ -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 "$@"