diff --git a/.travis.yml b/.travis.yml index 4ef75a443..cf9ad787b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,14 @@ script: - if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then make cluster-test; fi +deploy: + - provider: script + script: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + && make docker-build && make docker-push + skip_cleanup: true + on: + tags: true + go: '1.16' notifications: slack: if: branch = main diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..a052a3581 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.16 + +RUN mkdir /twilio +WORKDIR /twilio + +COPY client ./client +COPY rest ./rest +COPY twilio.go . +COPY twilio_test.go . + +# Fetch dependencies +COPY go.mod . +COPY go.sum . +RUN go mod download diff --git a/Makefile b/Makefile index bdda6c490..b7c2631fd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: githooks install test goimports govet golint +.PHONY: githooks install test goimports govet golint docker-build docker-push githooks: ln -sf ../../githooks/pre-commit .git/hooks/pre-commit @@ -23,3 +23,16 @@ golint: govet go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39.0 golangci-lint run go mod tidy + +API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5) +docker-build: + docker build -t twilio/twilio-go . + docker tag twilio/twilio-go twilio/twilio-go:${TRAVIS_TAG} + docker tag twilio/twilio-go twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA} + docker tag twilio/twilio-go twilio/twilio-go:latest + +docker-push: + echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + docker push twilio/twilio-go:${TRAVIS_TAG} + docker push twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA} + docker push twilio/twilio-go:latest