From 3446734ddfad1b0024212e5043bf1c3f633c668e Mon Sep 17 00:00:00 2001 From: Artem Sidorkin Date: Thu, 23 Apr 2020 11:35:32 +0300 Subject: [PATCH] Added deploying artifacts. --- .circleci/config.yml | 4 ++++ build.gradle | 13 ++++++++++++- deploy-artifacts.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 deploy-artifacts.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index e3355f7..6f371e8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,3 +48,7 @@ jobs: path: ~/junit - store_artifacts: path: ~/container-logs + - run: + name: Publish artifacts + command: ./deploy-artifacts.sh + when: on_success diff --git a/build.gradle b/build.gradle index e9e8f96..b69979f 100644 --- a/build.gradle +++ b/build.gradle @@ -26,10 +26,21 @@ subprojects { eventuateMavenRepoUrl.split(',').each { repoUrl -> maven { url repoUrl } } } + configurations { + deployerJars + } + + dependencies { + deployerJars 'org.springframework.build:aws-maven:5.0.0.RELEASE' + } + uploadArchives { repositories { mavenDeployer { - repository(url: deployUrl) + configuration = configurations.deployerJars + repository(url: deployUrl) { + authentication(userName: System.getenv('S3_REPO_AWS_ACCESS_KEY'), password: System.getenv('S3_REPO_AWS_SECRET_ACCESS_KEY')) + } pom.project { licenses { license { diff --git a/deploy-artifacts.sh b/deploy-artifacts.sh new file mode 100755 index 0000000..0ca56a1 --- /dev/null +++ b/deploy-artifacts.sh @@ -0,0 +1,33 @@ +#! /bin/bash -e + +BRANCH=$(git rev-parse --abbrev-ref HEAD) + +if [ $BRANCH == "master" ] ; then + BUILD_SNAPSHOT=$(sed -e '/^version=/!d' -e 's/^version=\(.*\)-SNAPSHOT$/\1.BUILD-SNAPSHOT/' < gradle.properties) + echo master: publishing $BUILD_SNAPSHOT + ./gradlew -P version=$BUILD_SNAPSHOT -P deployUrl=${S3_REPO_DEPLOY_URL} uploadArchives + exit 0 +fi + +if ! [[ $BRANCH =~ ^[0-9]+ ]] ; then + echo Not release $BRANCH - no PUSH + exit 0 +elif [[ $BRANCH =~ RELEASE$ ]] ; then + BINTRAY_REPO_TYPE=release +elif [[ $BRANCH =~ M[0-9]+$ ]] ; then + BINTRAY_REPO_TYPE=milestone +elif [[ $BRANCH =~ RC[0-9]+$ ]] ; then + BINTRAY_REPO_TYPE=rc +else + echo cannot figure out bintray for this branch $BRANCH + exit -1 +fi + +echo BINTRAY_REPO_TYPE=${BINTRAY_REPO_TYPE} + +VERSION=$BRANCH + +$PREFIX ./gradlew -P version=${VERSION} \ + -P bintrayRepoType=${BINTRAY_REPO_TYPE} \ + -P deployUrl=https://dl.bintray.com/eventuateio-oss/eventuate-maven-${BINTRAY_REPO_TYPE} \ + testClasses bintrayUpload