Skip to content

Commit

Permalink
feat[gihub] add make github_release command
Browse files Browse the repository at this point in the history
  • Loading branch information
ezotrank committed May 16, 2016
1 parent 7532e11 commit f28c518
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 31 additions & 0 deletions utils/github_release.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit f28c518

Please sign in to comment.