Build and push release image on tag
version: 2.1
jobs:
+ # Build development binary
build-dev:
docker:
- image: liftbridge/liftbridge-circleci:0.1.0
@@ -16,6 +17,8 @@ jobs:
paths:
- liftbridge-dev
- docker/
+
+ # Run unit/integration tests and upload code coverage
test:
docker:
- image: liftbridge/liftbridge-circleci:0.1.0
@@ -35,6 +38,7 @@ jobs:
cat coverage.txt.tmp | grep -v ".pb.go" > coverage.txt # Exclude protobuf from coverage
goveralls -coverprofile=coverage.txt -service=circle-ci -repotoken=$COVERALLS_REPO_TOKEN
+ # Build and publish standalone development Docker image
build-and-push-standalone-dev-image:
docker:
- image: circleci/buildpack-deps:stretch
@@ -62,6 +66,35 @@ jobs:
docker push "liftbridge/standalone-dev:${VERSION}"
docker push 'liftbridge/standalone-dev:latest'
+ # Build and publish release Docker image
+ build-and-push-release-image:
+ docker:
+ - image: circleci/buildpack-deps:stretch
+ steps:
+ - setup_remote_docker
+ - attach_workspace:
+ at: ~/project
+ - run:
+ name: Set image version
+ command: |
+ if [ -n "$CIRCLE_TAG" ]; then
+ echo "export VERSION='${CIRCLE_TAG}'" >> $BASH_ENV
+ else
+ echo "export VERSION='${CIRCLE_SHA1}'" >> $BASH_ENV
+ fi
+ - run:
+ name: Build image
+ command: |
+ docker build -t "liftbridge/liftbridge:${VERSION}" .
+ docker tag "liftbridge/liftbridge:${VERSION}" 'liftbridge/liftbridge:latest'
+ - run:
+ name: Publish image
+ command: |
+ echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
+ docker push "liftbridge/liftbridge:${VERSION}"
+ docker push 'liftbridge/liftbridge:latest'
+
+ # Build website artifacts
build-website:
docker:
- image: circleci/node
@@ -78,6 +111,7 @@ jobs:
- Makefile
- website/
+ # Deploy website to Google App Engine
deploy-website:
docker:
- image: google/cloud-sdk
@@ -104,6 +138,14 @@ workflows:
filters:
branches:
only: master
+ tags:
+ only: /^v.*/
+ - build-and-push-release-image:
+ filters:
+ branches:
+ ignore: /.*/
+ tags:
+ only: /^v.*/
- build-website:
filters:
branches:
