diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 391e3e3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -# -# Simply build and test by https://travis-ci.org -# -language: java - -jdk: -- openjdk8 - -before_install: -- chmod +x gradlew - -#after_success: -#- ./gradlew jacocoTestReport coveralls - -#cache: -# directories: -# - ~/.gradle/wrapper -# - ~/.gradle/caches diff --git a/deploy.sh b/deploy.sh index 800c3c2..2198e80 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,34 +1,192 @@ #!/bin/bash -BINTRAY_USER=$1 -BINTRAY_API_KEY=$2 -BINTRAY_VERSION=$3 +# SPDX-License-Identifier: Apache 2.0 -function show_help_and_exit() { - echo "Usage:" - echo " deploy.sh bintrayUser apiKey version" - exit 1 +# Version 1.0 +# ----------- +# for origin file refer to https://github.com/de-jcup/p2-updatesite-github-pages-automation + +# +# How it works +# - JAR signing environment variables must be set +# - jar signing is done automatically +# - we use github pages to provide static content for eclipse marketplace +# - corresponding github repository is automatically calculated based on this repository +# e.g. "eclipse-yaml-editor" will need a "update-site-eclipse-yaml-editor" repository +# - so by naming conventions this script can be used every where (in de-jcup github context. +# if you want to use it with another user just set GITHUB_USER with other username +# - eclipse update site project must have "update" inside their project folder names (and we only accept ONE...) +# - The repository must exist on Github +# - The update site must be build before deployment + +RED='\033[0;31m' +LIGHT_RED='\033[1;31m' +LIGHT_GREEN='\033[1;32m' +BROWN='\033[0;33m' +NC='\033[0m' # No Color + +function headline(){ + echo -e "${BROWN}$1${NC}" +} + +function info(){ + echo -e "- ${LIGHT_GREEN}$1${NC}" +} + + +function initVariables(){ + # check preconditions + if [ "$KEYSTORE_PWD" == "" ]; then + echo "KEYSTORE_PWD not set!" + exit 1 + fi + + if [ "$KEYSTORE_LOCATION" == "" ]; then + echo "KEYSTORE_LOCATION not set!" + exit 1 + fi + + + GITHUB_USER="de-jcup" + SOURCE_PROJECT_DIR=${PWD} + UPDATE_SITE_NAME=$(file *update* | grep directory | cut -d':' -f1) + SOURCE_PROJECT_NAME=${SOURCE_PROJECT_DIR##*/} # we use current directory name to identify (assume the project has been checked out with name like on github + TARGET_PROJECT_NAME="update-site-${SOURCE_PROJECT_NAME}" + + cd .. + THIS_ROOT_DIR="${PWD}" + TARGET_PROJECT_DIR="${THIS_ROOT_DIR}/${TARGET_PROJECT_NAME}" + TARGET_UPDATESITE_DIR="${THIS_ROOT_DIR}/${TARGET_PROJECT_NAME}/update-site" +} + +function showHeader(){ + headline "*******************************************************************" + headline "* Deployment of update site: '${UPDATE_SITE_NAME}'" + headline "*******************************************************************" + headline "ROOT : $THIS_ROOT_DIR" + headline "TARGET: $TARGET_PROJECT_DIR" + headline " $TARGET_UPDATESITE_DIR" + headline "SOURCE: $SOURCE_PROJECT_DIR" +} + + + +function signNewJarsInUpdateSiteProject(){ + info "start signing jars" + cd $TARGET_UPDATESITE_DIR + + PLUGINDIR=./plugins/* + FEATUREDIR=./features/* + + echo "Processing features dir $FEATUREDIR file..." + for f in $FEATUREDIR; + do + if [ ${f: -7} == ".sha256" ] ; then + continue + fi + CHECKSUM=$(sha256sum $f) + CHECKSUM_FILENAME="${f}.sha256" + if [ ! -f "$CHECKSUM_FILENAME" ] ; then + echo "Signing feature: $f file..." + jarsigner -keystore $KEYSTORE_LOCATION -storepass:env KEYSTORE_PWD $f signFiles + echo "$CHECKSUM" > $CHECKSUM_FILENAME + echo + else + echo "> ignore: $f because already signed" + fi + done + + echo "Processing plugin dir $PLUGINDIR file..." + + for f in $PLUGINDIR; + do + if [ ${f: -7} == ".sha256" ]; then + continue + fi + CHECKSUM=$(sha256sum $f) + CHECKSUM_FILENAME="${f}.sha256" + if [ ! -f "$CHECKSUM_FILENAME" ]; then + echo "Signing plugin: $f file..." + jarsigner -keystore $KEYSTORE_LOCATION -storepass:env KEYSTORE_PWD $f signFiles + echo "$CHECKSUM" > $CHECKSUM_FILENAME + echo + else + echo "> ignore: $f because already signed" + fi + # take action on each file. $f store current file name + echo "" + done + + # + # Jar signing done... + # + info "JAR signing done" + +} + +function ensureCleanUpdateSiteRepository(){ + cd $THIS_ROOT_DIR + if [ -d "$TARGET_PROJECT_NAME" ]; then + # Control will enter here if $DIRECTORY doesn't exist. + info "drop old update-site repository" + rm $TARGET_PROJECT_DIR -rf + info "pwd:${PWD}" + fi + info "fetch update-site repository from scratch" + git clone https://github.com/$GITHUB_USER/$TARGET_PROJECT_NAME + cd $TARGET_PROJECT_DIR + git pull +} + +function copyOriginUpdateSiteContent(){ + if [ ! -d "$TARGET_UPDATESITE_DIR" ] ; then + info "$TARGET_UPDATESITE_DIR not found, so start creation" + mkdir $TARGET_UPDATESITE_DIR + fi + info "copy from $SOURCE_PROJECT_DIR/$UPDATE_SITE_NAME/*.* to $TARGET_UPDATESITE_DIR" + cp $SOURCE_PROJECT_DIR/$UPDATE_SITE_NAME/site.xml $TARGET_UPDATESITE_DIR -f + cp $SOURCE_PROJECT_DIR/$UPDATE_SITE_NAME/artifacts.jar $TARGET_UPDATESITE_DIR -f + cp $SOURCE_PROJECT_DIR/$UPDATE_SITE_NAME/content.jar $TARGET_UPDATESITE_DIR -f + + if [ ! -d "$TARGET_UPDATESITE_DIR/features" ]; then + # Control will enter here if $DIRECTORY doesn't exist. + mkdir $TARGET_UPDATESITE_DIR/features + fi + cp $SOURCE_PROJECT_DIR/$UPDATE_SITE_NAME/features/*.jar $TARGET_UPDATESITE_DIR/features -rn + + if [ ! -d "$TARGET_UPDATESITE_DIR/plugins" ]; then + # Control will enter here if $DIRECTORY doesn't exist. + mkdir $TARGET_UPDATESITE_DIR/plugins + fi + cp $SOURCE_PROJECT_DIR/$UPDATE_SITE_NAME/plugins/*.jar $TARGET_UPDATESITE_DIR/plugins -rn + +} + +function addFilesToUpdateSiteRepo(){ + cd $TARGET_PROJECT_DIR + info "add all new stuff to git repository" + git add --all +} +function commitAndPushUpdateSiteRepo(){ + cd $TARGET_PROJECT_DIR + info "commit"s + git commit -m"released new changes to p2 plugin updatesite" + + info "push" + git push } -if [ -z "$BINTRAY_USER" ]; then - echo "bintray user not set" - show_help_and_exit; -fi -if [ -z "$BINTRAY_API_KEY" ]; then - echo "bintray api key not set" - show_help_and_exit; -fi +# ------------------------------ +# - Start +# ------------------------------ +initVariables -if [ -z "$BINTRAY_VERSION" ]; then - echo "bintray version not set" - show_help_and_exit; -fi +showHeader -# call jar signing before pushing to bintray... -export KEYSTORE_PWD -export KEYSTORE_LOCATION +ensureCleanUpdateSiteRepository +copyOriginUpdateSiteContent +signNewJarsInUpdateSiteProject +addFilesToUpdateSiteRepo +commitAndPushUpdateSiteRepo -set -e -./signJars -./pushToBintray.sh ${BINTRAY_USER} ${BINTRAY_API_KEY} de-jcup basheditor update-site ${BINTRAY_VERSION} ./basheditor-updatesite/ \ No newline at end of file diff --git a/pushToBintray.sh b/pushToBintray.sh deleted file mode 100755 index 9daba59..0000000 --- a/pushToBintray.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -# Sample Usage: pushToBintray.sh username apikey owner repo package version pathToP2Repo -# Origin code from : https://github.com/vogellacompany/bintray-publish-p2-updatesite/blob/master/pushToBintray.sh -API=https://api.bintray.com -BINTRAY_USER=$1 -BINTRAY_API_KEY=$2 -BINTRAY_OWNER=$3 -BINTRAY_REPO=$4 -PCK_NAME=$5 -PCK_VERSION=$6 -PATH_TO_REPOSITORY=$7 - -function main() { -deploy_updatesite -} - -function deploy_updatesite() { -echo "${BINTRAY_USER}" -echo "${BINTRAY_API_KEY}" -echo "${BINTRAY_OWNER}" -echo "${BINTRAY_REPO}" -echo "${PCK_NAME}" -echo "${PCK_VERSION}" -echo "${PATH_TO_REPOSITORY}" - -if [ ! -z "$PATH_TO_REPOSITORY" ]; then - cd $PATH_TO_REPOSITORY - if [ $? -ne 0 ]; then - #directory does not exist - echo $PATH_TO_REPOSITORY " does not exist" - exit 1 - fi -fi - - -FILES=./* -BINARYDIR=./binary/* -PLUGINDIR=./plugins/* -FEATUREDIR=./features/* - -for f in $FILES; -do -if [ ! -d $f ]; then - echo "Processing $f file..." - if [[ "$f" == *content.jar ]] || [[ "$f" == *artifacts.jar ]] - then - echo "Uploading p2 metadata file directly to the repository" - curl -X PUT -T $f -u ${BINTRAY_USER}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER}/${BINTRAY_REPO}/$f;publish=0 - else - curl -X PUT -T $f -u ${BINTRAY_USER}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER}/${BINTRAY_REPO}/${PCK_NAME}/${PCK_VERSION}/$f;publish=0 - fi - echo "" -fi -done - -echo "Processing features dir $FEATUREDIR file..." -for f in $FEATUREDIR; -do - echo "Processing feature: $f file..." - curl -X PUT -T $f -u ${BINTRAY_USER}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER}/${BINTRAY_REPO}/${PCK_NAME}/${PCK_VERSION}/$f;publish=0 - echo "" -done - -echo "Processing plugin dir $PLUGINDIR file..." - -for f in $PLUGINDIR; -do - # take action on each file. $f store current file name - echo "Processing plugin: $f file..." - curl -X PUT -T $f -u ${BINTRAY_USER}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER}/${BINTRAY_REPO}/${PCK_NAME}/${PCK_VERSION}/$f;publish=0 - echo "" -done - -echo "Processing binary dir $BINARYDIR file..." -if [ -d "$(dirname $BINARYDIR)" ]; then -for f in $BINARYDIR; -do - # take action on each file. $f store current file name - echo "Processing binary: $f file..." - curl -X PUT -T $f -u ${BINTRAY_USER}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER}/${BINTRAY_REPO}/${PCK_NAME}/${PCK_VERSION}/$f;publish=0 - echo "" -done -fi - - - -echo "Publishing the new version" -curl -X POST -u ${BINTRAY_USER}:${BINTRAY_API_KEY} https://api.bintray.com/content/${BINTRAY_OWNER}/${BINTRAY_REPO}/${PCK_NAME}/${PCK_VERSION}/publish -d "{ \"discard\": \"false\" }" - -} - - -main "$@" \ No newline at end of file diff --git a/signJars b/signJars deleted file mode 100755 index 838ad1a..0000000 --- a/signJars +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -if [ "$KEYSTORE_PWD" == "" ]; then - echo "KEYSTORE_PWD not set!" - exit 1 -fi - -if [ "$KEYSTORE_LOCATION" == "" ]; then - echo "KEYSTORE_LOCATION not set!" - exit 1 -fi -cd basheditor-updatesite - -PLUGINDIR=./plugins/* -FEATUREDIR=./features/* - -echo "Processing features dir $FEATUREDIR file..." -for f in $FEATUREDIR; -do - echo "Signing feature: $f file..." - jarsigner -keystore $KEYSTORE_LOCATION -storepass:env KEYSTORE_PWD $f signFiles - echo "" -done - -echo "Processing plugin dir $PLUGINDIR file..." - -for f in $PLUGINDIR; -do - # take action on each file. $f store current file name - echo "Signing plugin: $f file..." - jarsigner -keystore $KEYSTORE_LOCATION -storepass:env KEYSTORE_PWD $f signFiles - echo "" -done