Skip to content

Commit

Permalink
Add Travis deploy phase
Browse files Browse the repository at this point in the history
  • Loading branch information
stebenoist committed Mar 2, 2018
1 parent 7f63a4c commit 85eb238
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ after_script:
after_success:
- bash <(curl -s https://codecov.io/bash)

deploy:
- provider: script
script: bash deploy.sh
on:
all_branches: true
skip_cleanup: true

- provider: releases
overwrite: true
api_key:
secure: ZHIdTaOa3MbxENL2spVhKk3P3DatNXZ5hjg+4oe0hCdZsr1feb0WnC4jsfMeU5rQcaiwJEWknrvdq66RUQvbcOtEr/SIrPUplc/qjWiH6i81lELX1OVp41M1YSkjEKnjCUqyW1lcBCS8KgwaiNCRd6BI6BbPhNy4bO0ssQXnT8wuaWaPExgjo8qck9qsB7n+Ta0gwkHd9Ly3FdH1I4DmcwB1T0kB9MRjmJk5WeX8uBN7vJjcrsy8VbDwLxTRhjAbLSz7Pa7fUBtA4ssXJQbbAxpXaaa8FkkBPLXCf+zsq6+Cqnhj/Y8O360iu92A6hgNKUkCCNqXJHxYP6L6ETY/wh+6XlnWKWPSCy3/z5KFJYptVDD70EStKhHj3Gwjyh0mXGGt4UpgMBZlTzj2I0uReS6BCGcJ3t0/ny3L0x4LhnQpNGsgzm/2CiLfr0PUcBgAI4b6jUpzfZlG9H7DfiwHJdhU1yTbelBjf4nYEAG2oQVijD9wSiMyTShWt6Hh4Vw1WsGemd14TzOdDP6eAbECqjAb6OIpe8edeiD/fdwXoXFCdmMHuq19XXGloCOgJpfExxByagZhN8SsFxsr5mUdnSSuXUZ3XtcoRhCum7J7ZsTIJ6nhS6DrvVjI9Hwiq2d3IK10JgQ6K48C/c0qW+TvOUJvgmeQCHpSF+gLJWQlodY=
file:
- dist/yorc.tgz
- dist/yorc-server-*-distrib.zip
skip_cleanup: true
on:
tags: true

addons:
apt:
packages:
Expand All @@ -41,3 +59,8 @@ addons:
- texlive-latex-base
- texlive-latex-extra
- texlive-latex-recommended

env:
global:
secure: UYRcG6VFZrs26zy+L3p6AgfAfIjCU9VTHHeaTqDZ7mYSKl7ijn4Av/tYna/gblftq9k5Lh1pPW54q2pkdl0d9KPA6fDbsi1AGpBg3smVZ3znzC+N6Y/MUZvyI6UkmjC00tCwCBouB2E8mQ/7xLBfX/bY4QqZBiOWr86eTULBhW1og0PbATBggPLdrHXouC3NVB8/MrhWBssoGNYnBxeHDmmPklhwx1tHEfEIh+QKsDOmm4AVLVb/ZFLziIr/eQ0k8vqU9/nRKZY1ZQ4gOmnWZ/74AC7e2EwcYWcjVK62rE4ePE86LL3zpqfnFFgu/v5d5l8m8yoMTOYx09pL/6Zbw280ahit/P7oDUtSyx+Vejv3hPDkupmKcxqeTEpkRxmDWNu6dYOeuMGo3P3uVbKA7SaqZTjxNDhxAvaMxwUg4rR44o1Vxwz6VVAZPIcMdoYlN/LDn1oJCx4bWL9p+P0MIPZp4H0NnE5N//MgZLoy2GueBGSVrx7c272H8FaC+er7ZzItCm3qUKAKR4CYoogdDK9avuhw+Wy180FfVE1dUZzNKkEZfDKxz33AXqwnsaCtcmMkv/qccpVtTJ1NnVuvaHRReMT2bLZhQLBk73/380lrbc6XPlJJh1l7YzP0IarChWVxynA4qb5qIXTiuoXifSfV5xcDNT8UkKuh5Vw1bXM=

106 changes: 106 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env bash
#
# Copyright 2018 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


## Usage: deploy.sh
##
## Purpose: Allow to deploy on Bintray (https://bintray.com) Travis Build artifacts
##
##
##


#set -x
#set -e

#### Test variables
#TRAVIS_TAG="3.0.0-RC1"
#TRAVIS_PULL_REQUEST="42"
#TRAVIS_BRANCH="my_branch"
#BINTRAY_API_KEY=AHAHHA

#### Bintray Variables
bintray_base_url="https://api.bintray.com/content"
bintray_api_user="stebenoist"
bintray_repo_distrib="ystia/yorc/distributions"

bintray_releases_path="releases"
bintray_snapshots_pr_path="snapshots/@BRANCH@/pr/@PR_ID@"
bintray_snapshots_path="snapshots/@BRANCH@"

#### Artifacts Variables
artifacts_list="dist/yorc.tgz dist/yorc-server-*-distrib.zip"
distrib_artifact_dir="./dist"
distrib_artifact_basename="yorc-server-"

#### get_version ()
#### Allows to get the current distribution version
get_version () {
find ${distrib_artifact_dir} -type f -name "${distrib_artifact_basename}*-distrib.zip" | awk -F${distrib_artifact_basename} '{print $2}' | sed "s|-distrib.zip||g" | sed "s|-SNAPSHOT||g"
}

############################################### Main ###############################################
#### Check the env var BINTRAY_API_KEY is set
if [[ ! -n "$BINTRAY_API_KEY" ]]; then
echo "The env variable BINTRAY_API_KEY is not set" >&2
exit 1
fi

#### Retrieve the version with distribution artifact
version=$(get_version)
if [[ ! -n "${version}" ]]; then
echo "No distribution artifact with correct name has been foud." >&2
exit 1
fi
echo "version is: ${version}"

#### Retrieve bintray expected path
if [[ -n "$TRAVIS_TAG" ]]; then
echo "Deploying release \"$TRAVIS_TAG\""
bintray_path=${bintray_releases_path}
else
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
echo "Deploying snapshot from push on branch \"$TRAVIS_BRANCH\""
bintray_path=$(echo ${bintray_snapshots_path} | sed "s|@BRANCH@|$TRAVIS_BRANCH|g")
else
if [[ -n "$TRAVIS_BRANCH" ]]; then
echo "Deploying snapshot from pr ($TRAVIS_PULL_REQUEST) on branch \"$TRAVIS_BRANCH\""
bintray_path=$(echo ${bintray_snapshots_pr_path} | sed "s|@BRANCH@|$TRAVIS_BRANCH|g" | sed "s|@PR_ID@|$TRAVIS_PULL_REQUEST|g")
fi
fi
fi

if [[ ! -n "${bintray_path}" ]]; then
echo "Unable to define expected bintray path" >&2
echo "TRAVIS_TAG=\"$TRAVIS_TAG\"" >&2
echo "TRAVIS_PULL_REQUEST=\"$TRAVIS_PULL_REQUEST\"" >&2
echo "TRAVIS_BRANCH=\"$TRAVIS_BRANCH\"" >&2
exit 1
fi
echo "bintray path is: ${bintray_path}"

#### Loop artifacts list and upload each one to bintray
for artifact in ${artifacts_list}
do
echo "Deploying artifact ${artifact}"
filename="$(basename ${artifact})"

cmd="curl -T ${artifact} -H \"X-Bintray-Publish: 1\" -H \"X-Bintray-Override: 1\" -u ${bintray_api_user}:$BINTRAY_API_KEY ${bintray_base_url}/${bintray_repo_distrib}/${version}/${bintray_path}/${filename}"
echo "run command: \"${cmd}\""
eval $cmd
done

0 comments on commit 85eb238

Please sign in to comment.