machine:
  post:
    - rm -rf ${GOPATH%%:*}/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
    - mkdir -p ${GOPATH%%:*}/src/github.com/${CIRCLE_PROJECT_USERNAME}
    - cp -r ${HOME}/${CIRCLE_PROJECT_REPONAME} ${GOPATH%%:*}/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}
    - git config --global user.email "billings@erisindustries.com"
    - git config --global user.name "Billings the Bot"

dependencies:
  pre:
    - sudo curl -L -o /usr/bin/docker 'http://s3-external-1.amazonaws.com/circle-downloads/docker-1.6.0-circleci'; chmod 0755 /usr/bin/docker; true
    - sudo service docker start
    - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
    - "sudo apt-get update && sudo apt-get install -y libgmp3-dev"

  override:
    - "cd ./cmd/erisdb && go build"
    - "mv ~/eris-db/cmd/erisdb/erisdb ~/bin"
    - chmod +x ~/bin/erisdb

test:
  override:
    - go test -v ./...

deployment:
  master:
    branch: master
    commands:
      - "export ERISDB_BUILD_BRANCH=$CIRCLE_BRANCH && DOCKER/build.sh"
      - docker push eris/erisdb:latest
      - docker push eris/erisdb:0.10
  unstable:
    branch: develop
    comands:
      - "export ERISDB_BUILD_BRANCH=$CIRCLE_BRANCH && DOCKER/build.sh"
      - docker tag eris/erisdb:$CIRCLE_BRANCH eris/db:unstable
      - docker push eris/erisdb:unstable