version: 2
jobs:
  build:
    docker:
      - image: openjdk:8
    steps:
      - checkout
      - add_ssh_keys

      - restore_cache:
          key: v1-gradle-{{ checksum "build.gradle" }}
          key: v1-gradle-
      - run: ./gradlew check --info
      - run:
          name: Save test results
          command: |
            mkdir -p ~/junit/
            find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
          when: always
      - store_test_results:
          path: ~/junit
      - store_artifacts:
          path: ~/junit

      - save_cache:
          paths:
            - "~/.gradle"
            - "~/.m2"
          key: v1-gradle-{{ checksum "build.gradle" }}

      - deploy:
          name: Release to kamatama41/maven-repository
          command: |
            if [ "${CIRCLE_BRANCH}" == "release" ]; then
              git config --global user.email "shiketaudonko41@gmail.com"
              git config --global user.name "kamatama41"
              git checkout master
              git reset --hard origin/master
              ./gradlew release -Prelease.useAutomaticVersion=true
            fi

version: 2
jobs:
  build:
    docker:
      - image: openjdk:8
    steps:
      - checkout

      - restore_cache:
          key: v1-gradle-{{ checksum "build.gradle" }}
          key: v1-gradle-
      - run: ./gradlew check --info
      - run:
          name: Save test results
          command: |
            mkdir -p ~/junit/
            find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
          when: always
      - store_test_results:
          path: ~/junit
      - store_artifacts:
          path: ~/junit

      - save_cache:
          paths:
            - "~/.gradle"
            - "~/.m2"
          key: v1-gradle-{{ checksum "build.gradle" }}

      - deploy:
          name: Release to kamatama41/maven-repository
          command: |
            if [ "${CIRCLE_BRANCH}" == "release" ]; then
              git config --global user.email "shiketaudonko41@gmail.com"
              git config --global user.name "kamatama41"
              git checkout master
              git reset --hard origin/master
              ./gradlew release -Prelease.useAutomaticVersion=true
            fi

Remove add_ssh_keys: Added SSH key was not recognized on "gradle release" for some reason.
Remove add_ssh_keys:
Added SSH key was not recognized on "gradle release" for some reason.
