version: 2
jobs:
  build:
    docker:
    - image: circleci/openjdk:8u171-jdk 
    steps:
    - checkout
    - run: mvn clean install
    - run: mvn surefire:test -Punit

version: 2

job-settings:
  defaults:
    agent-only: &defaults-agent-only
      docker:
        - image: groupbyinc/circleci-java

workflow-settings:
  context: &job-context
    context: org-global

main_branch_only: &main_branch_only
  filters:
    branches:
      only:
        - develop

workspace_key: &workspace_key
  key: v1-repo-{{ .Branch }}-{{ .Revision }}

dependency_cache_key: &dependency_cache_key
  run:
    name: Generate Dependency Cache Key
    command: /scripts/checksum.sh /tmp/checksum

cache_key: &cache_key
  key: v1-dependencies-{{checksum "/tmp/checksum"}}-{{ .Revision }}

setup_builder: &setup_builder
  run:
    name: Initialize Build Agent
    command: /scripts/setup.sh

jobs:
  build:
    <<: *defaults-agent-only
    steps:
      - checkout
      - *dependency_cache_key
      - restore_cache: *cache_key
      - *setup_builder
      - run: mvn clean install
      - run: mvn surefire:test -Punit
      - save_cache:
          <<: *cache_key
          paths:
            - ~/.m2
      - save_cache:
          <<: *workspace_key
          paths:
            - ~/.ssh
            - ~/project
  release:
    <<: *defaults-agent-only
    steps:
      - restore_cache: *workspace_key
      - *dependency_cache_key
      - restore_cache: *cache_key
      - *setup_builder
      - run: mvn -B release:prepare release:perform

workflows:
  version: 2
  build-and-push:
    jobs:
      - build: *job-context
      - hold:
          <<: *main_branch_only
          type: approval
          requires:
            - build
      - release:
          <<: *main_branch_only
          <<: *job-context
          requires:
            - hold

Update build to have hold and release on develop
Update build to have hold and release on develop
