Rebuild env so it can be deployed to the tus server

This commit is contained in:
Kevin van Zonneveld 2016-03-29 17:52:46 +02:00
parent 2205a84499
commit f0f16865a9
4 changed files with 86 additions and 1 deletions

View File

@ -156,7 +156,7 @@
ansistrano_group = "ubuntu"
[[deploy.playbooks.tasks]]
copy = "src=../env.sh dest={{{config.global.approot}}}/current/tusd_linux_amd64/env.sh mode=0600 owner=root group=root"
copy = "src={{ playbook_dir }}/env.sh dest={{{config.global.approot}}}/current/tusd_linux_amd64/env.sh mode=0600 owner=root group=root"
name = "tusd | Upload environment"
[[deploy.playbooks.tasks]]

37
.infra/scripts/encrypt.sh Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Uppy-server. Copyright (c) 2016, Transloadit Ltd.
#
# This file:
#
# - Walks over any FREY_ and TUSD_ environment variable (except for _AWS_)
# - Adds encrypted keys ready for use to .travis.yml
#
# Run as:
#
# source env.sh && ./encrypt.sh
#
# Authors:
#
# - Kevin van Zonneveld <kevin@transloadit.com>
set -o pipefail
set -o errexit
set -o nounset
# set -o xtrace
if [ -z "${FREY_DOMAIN:-}" ]; then
echo "FREY_DOMAIN not present. "
echo "Please first source env.sh"
exit 1
fi
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__freyroot="$(dirname "${__dir}")"
for var in $(env |awk -F= '{print $1}' |egrep '^(FREY|TUSD)_[A-Z0-9_]+$' |grep -v '_AWS_' |sort); do
echo "Encrypting and adding '${var}'"
travis encrypt "${var}=${!var}" --add env.global
done

47
.infra/scripts/rebuild-env.sh Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env bash
# tusd. Copyright (c) 2016, Transloadit Ltd.
# This file:
#
# - Creates a brand new env.sh based on env.example.sh that is shipped with Git
# - Walks over any FREY_ and TUSD_ environment variable
# - Adds them as exports to to env.sh inside $__freyroot
#
# Run as:
#
# ./rebuild-env.sh
#
# Authors:
#
# - Kevin van Zonneveld <kevin@transloadit.com>
set -o pipefail
set -o errexit
set -o nounset
# set -o xtrace
if [ -z "${FREY_DOMAIN:-}" ]; then
echo "FREY_DOMAIN not present. "
echo "Please make sure your environment is set properly (via e.g. travis encrypt)"
exit 1
fi
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__freyroot="$(dirname "${__dir}")"
if [ -f "${__freyroot}/env.sh" ]; then
echo "You alreayd have a '${__freyroot}/env.sh'"
exit 1
fi
cp -v "${__freyroot}/env.example.sh" "${__freyroot}/env.sh"
chmod 600 "${__freyroot}/env.sh"
for var in $(env |awk -F= '{print $1}' |egrep '^(FREY|TUSD)_[A-Z0-9_]+$'| grep -v '_AWS_' |sort); do
echo "Adding '${var}' to env.sh"
echo "export ${var}=\"${!var}\"" >> "${__freyroot}/env.sh"
done
ls -al "${__freyroot}/env.sh"

View File

@ -29,6 +29,7 @@ before_deploy:
- go get github.com/laher/goxc
- goxc -t -bc="linux darwin windows"
- goxc -d=./ -wd=./cmd/tusd -bc="linux darwin windows" -build-ldflags="-X main.VersionName=$TRAVIS_TAG -X main.GitCommit=$TRAVIS_COMMIT -X 'main.BuildDate=$(date --utc)'"
- .infra/scripts/rebuild-env.sh
- if [ "${TRAVIS_PULL_REQUEST}" == "false" ] && [ "${TRAVIS_BRANCH}" == "master" ]; then (make frey && frey setup --force-yes --projectDir .infra); else echo "Skipping deploy fornon-master/PRs"; fi
deploy:
provider: releases