diff --git a/Dockerfile b/Dockerfile index 109a52a..5273f50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update \ && go get -u github.com/kardianos/govendor \ && govendor add +external && govendor get \ && go install \ - && apt-get purge -y --auto-remove curl ca-certificates \ + && apt-get purge -y --auto-remove ca-certificates \ && rm -rf /var/lib/apt/lists/* CMD ["/bin/burlesque"] diff --git a/Makefile b/Makefile index c0c7b92..39f299d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,13 @@ +.PHONY: github_release + docker_build: - docker build -t aviasales/burlesque --force-rm --no-cache . + docker build -t aviasales/burlesque:latest --force-rm --no-cache . docker_run: - docker run --rm -p 4001:4001 aviasales/burlesque + docker run --rm -p 4001:4001 aviasales/burlesque:latest docker_tty: - docker run --rm -p 4001:4001 -v `pwd`:/src/github.com/KosyanMedia/burlesque -ti aviasales/burlesque /bin/bash + docker run --rm -p 4001:4001 -v `pwd`:/src/github.com/KosyanMedia/burlesque -ti aviasales/burlesque:latest /bin/bash + +github_release: + docker run --rm -v `pwd`:/src/github.com/KosyanMedia/burlesque aviasales/burlesque:latest /bin/bash -c "TAG=$(TAG) TOKEN=$(TOKEN) ./utils/github_release.sh" diff --git a/utils/github_release.sh b/utils/github_release.sh new file mode 100755 index 0000000..9442b24 --- /dev/null +++ b/utils/github_release.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Example of use: +# TAG=v1.2 TOKEN=447879c5af5887eab22725605783e86d3304bc99 bash ./github_release.sh + +if [ -z "$TAG" ]; then + echo "TAG is empty please do 'export TAG=v0.1' for example" + exit 1 +fi + +if [ -z "$TOKEN" ]; then + echo "You forgot write yout TOKEN" + exit 1 +fi + +LINUX_BIN_PATH=/bin/burlesque + +gzip -9 -f $LINUX_BIN_PATH || exit 1 + +response=`curl --data "{\\"tag_name\\": \\"$TAG\\",\\"target_commitish\\": \\"master\\",\\"name\\": \\"$TAG\\",\\"body\\": \\"Release of version $TAG\\", \\"draft\\": false,\\"prerelease\\": false}" \ + -H 'Accept-Encoding: gzip,deflate' --compressed "https://api.github.com/repos/KosyanMedia/burlesque/releases?access_token=$TOKEN" > response` + +release_id=`cat response|head -n 10|grep '"id"'|head -n 1|awk '{print $2}'|sed -e 's/,//'` +rm response + +if [ -z "$release_id" ]; then + echo "something wrong" + echo $response + exit 1 +fi + +curl -X POST -H 'Content-Type: application/x-gzip' --data-binary @$LINUX_BIN_PATH.gz "https://uploads.github.com/repos/KosyanMedia/burlesque/releases/$release_id/assets?name=burlesque.gz&access_token=$TOKEN"