-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·43 lines (36 loc) · 1.15 KB
/
package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /bin/bash
MIX_ENV=prod mix local.hex --force
MIX_ENV=prod mix local.rebar --force
MIX_ENV=prod mix deps.get
pushd front/
npm i
bower i --allow-root
npm test
NODE_ENV=production npm run webpack
popd
MIX_ENV=prod mix phx.digest --force
MIX_ENV=prod mix compile --force
MIX_ENV=prod mix release
# From https://gist.github.com/chrismdp/6c6b6c825b07f680e710
# Env: S3KEY
# Env: S3SECRET
function put_s3() {
local path=$1
local file=$2
local aws_path=$3
local bucket='rel-crafters'
local date=$(date +"%a, %d %b %Y %T %z")
local acl="x-amz-acl:public-read"
local content_type='application/x-compressed-tar'
local string="PUT\\n\\n$content_type\\n$date\\n$acl\\n/$bucket$aws_path$file"
local signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
curl -X PUT -T "$path/$file" \
-H "Host: $bucket.s3.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$acl" \
-H "Authorization: AWS ${S3KEY}:$signature" \
"https://$bucket.s3.amazonaws.com$aws_path$file"
}
# $release = "_build/hello/hello.tar.gz"
# put_s3 $(dirname "$release") $(basename "$release") "/path/on/s3/to/files/"