From 474a36c0e24c7a424a4ddffcefd4e7cbf3a70eb7 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Mon, 17 Sep 2018 01:47:51 -0700 Subject: [PATCH] Set up automatic release publishing (#266) Summary: On tags, build and publish artifacts to bintray. The encrypted accounted creds are for a `flipperfbbot` account on Bintray I created for this. Pull Request resolved: https://github.com/facebook/flipper/pull/266 Reviewed By: priteshrnandgaonkar Differential Revision: D9848181 Pulled By: passy fbshipit-source-id: cf9150b2352a9ce972c48533ce15e8e75aa908fe --- .circleci/config.yml | 14 ++++++++++++++ scripts/bintray-publish-keys.enc | 1 + scripts/publish-android-release.sh | 16 ++++++++++++++++ scripts/publish-android-snapshot.sh | 8 ++++---- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 scripts/bintray-publish-keys.enc create mode 100755 scripts/publish-android-release.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 69d972217..66d6ad86f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,8 +11,22 @@ jobs: ./gradlew :sample:assembleDebug scripts/publish-android-snapshot.sh + release: + docker: + - image: circleci/android:api-28-ndk-r17b + steps: + - checkout + - run: + name: build and deploy + command: scripts/publish-android-release.sh + workflows: version: 2 build: jobs: - build + - release: + filters: + tags: + - only: /^v.*/ + diff --git a/scripts/bintray-publish-keys.enc b/scripts/bintray-publish-keys.enc new file mode 100644 index 000000000..35f1f110e --- /dev/null +++ b/scripts/bintray-publish-keys.enc @@ -0,0 +1 @@ +Salted__{a]XH%Yhuѹy[=Ǔ:OQ4OZqX6¸COaS*NXT(Ǜ>*!,Fw.T\ dg \ No newline at end of file diff --git a/scripts/publish-android-release.sh b/scripts/publish-android-release.sh new file mode 100755 index 000000000..179ad6964 --- /dev/null +++ b/scripts/publish-android-release.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties" || echo "")" + +if [ "$ANDROID_PUBLISH_KEY" == "" ]; then + echo "No encryption key. Skipping snapshot deployment." + exit +elif [ "$IS_SNAPSHOT" != "" ]; then + echo "Build appears to be a SNAPSHOT release, but this is a script for building stable releases. Skipping ..." + exit 1 +else + openssl aes-256-cbc -d -in scripts/bintray-publish-keys.enc -k "$ANDROID_PUBLISH_KEY" >> "$BASEDIR/gradle.properties" + "$BASEDIR"/gradlew bintrayUpload --info -PdryRun=false +fi diff --git a/scripts/publish-android-snapshot.sh b/scripts/publish-android-snapshot.sh index 266dcec90..179ad6964 100755 --- a/scripts/publish-android-snapshot.sh +++ b/scripts/publish-android-snapshot.sh @@ -7,10 +7,10 @@ IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.propertie if [ "$ANDROID_PUBLISH_KEY" == "" ]; then echo "No encryption key. Skipping snapshot deployment." exit -elif [ "$IS_SNAPSHOT" == "" ]; then - echo "Skipping build. Given build doesn't appear to be a SNAPSHOT release." +elif [ "$IS_SNAPSHOT" != "" ]; then + echo "Build appears to be a SNAPSHOT release, but this is a script for building stable releases. Skipping ..." exit 1 else - openssl aes-256-cbc -d -in scripts/gradle-publish-keys.enc -k "$ANDROID_PUBLISH_KEY" >> "$BASEDIR/gradle.properties" - "$BASEDIR"/gradlew uploadArchives --info + openssl aes-256-cbc -d -in scripts/bintray-publish-keys.enc -k "$ANDROID_PUBLISH_KEY" >> "$BASEDIR/gradle.properties" + "$BASEDIR"/gradlew bintrayUpload --info -PdryRun=false fi