From 3cf5883aa6f580b60bf9af4bbfa435221c02ef09 Mon Sep 17 00:00:00 2001 From: Aaron He Date: Thu, 11 Jul 2019 15:22:38 -0700 Subject: [PATCH] Set up auto deploy of snapshots --- .circleci/config.yml | 3 +++ publish.sh | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0c656c4a..c4a9a858 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,3 +18,6 @@ jobs: - run: ./gradlew test - run: mkdir -p $CIRCLE_TEST_REPORTS/junit/ - run: find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; + - run: + name: Deploy Snapshot + command: ./publish.sh diff --git a/publish.sh b/publish.sh index 21899d25..a5500157 100755 --- a/publish.sh +++ b/publish.sh @@ -1,2 +1,21 @@ -#!/usr/bin/env bash -./gradlew clean uploadArchives +#!/bin/bash +# +# Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo. +# +# Adapted from https://coderwall.com/p/9b_lfq and +# http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/ + +REPO_URL="git@github.com:Tinder/Scarlet.git" +BRANCH="master" + +set -e + +if [ "${CIRCLE_REPOSITORY_URL}" != "$REPO_URL" ]; then + echo "Skipping snapshot deployment: wrong repository. Expected '$REPO_URL' but was '${CIRCLE_REPOSITORY_URL}'." +elif [ "${CIRCLE_BRANCH}" != "$BRANCH" ]; then + echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '${CIRCLE_BRANCH}'." +else + echo "Deploying snapshot..." + ./gradlew clean uploadArchives + echo "Snapshot deployed!" +fi \ No newline at end of file