forked from alpine-docker/httpie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·46 lines (35 loc) · 1.09 KB
/
build.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
44
45
46
#!/usr/bin/env bash
# Prerequisite
# Make sure you set secret enviroment variables in Travis CI
# DOCKER_USERNAME
# DOCKER_PASSWORD
# API_TOKEN
set -ex
Usage() {
echo "$0 [rebuild]"
}
image="alpine/httpie"
repo="jakubroztocil/httpie"
if [[ ${CI} == 'true' ]]; then
latest=`curl -sL -H "Authorization: token ${API_TOKEN}" https://api.github.com/repos/${repo}/tags |jq -r ".[].name"|head -1`
else
latest=`curl -sL https://api.github.com/repos/${repo}/tags |jq -r ".[].name"|head -1`
fi
sum=0
echo "Lastest release is: ${latest}"
tags=`curl -sL https://hub.docker.com/v2/repositories/${image}/tags/ |jq -r .results[].name`
for tag in ${tags}
do
if [ ${tag} == ${latest} ];then
sum=$((sum+1))
fi
done
if [[ ( $sum -ne 1 ) || ( $1 == "rebuild" ) ]];then
docker build --no-cache --build-arg VERSION=$latest -t ${image}:${latest} .
docker tag ${image}:${latest} ${image}:latest
if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == false ]]; then
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push ${image}:${latest}
docker push ${image}:latest
fi
fi