version: 2.1
executors:
  go:
    docker:
      - image: circleci/golang:1.12.0
    working_directory: /go/src/github.com/minamijoyo/myaws
    environment:
      GO111MODULE: "on"

commands:
  gomod:
    steps:
      - restore_cache:
          keys:
            - go-mod-v1-{{ checksum "go.sum" }}
      - run:
          command: go mod download
      - save_cache:
          key: go-mod-v1-{{ checksum "go.sum" }}
          paths:
            - "/go/pkg/mod"
jobs:
  test:
    executor: go
    steps:
      - checkout
      - gomod
      - run: make check

workflows:
  version: 2
  ci:
    jobs:
      - test

version: 2.1
executors:
  go:
    docker:
      - image: circleci/golang:1.12.0
    working_directory: /go/src/github.com/minamijoyo/myaws
    environment:
      GO111MODULE: "on"

commands:
  gomod:
    steps:
      - restore_cache:
          keys:
            - go-mod-v1-{{ checksum "go.sum" }}
      - run:
          command: go mod download
      - save_cache:
          key: go-mod-v1-{{ checksum "go.sum" }}
          paths:
            - "/go/pkg/mod"
jobs:
  test:
    executor: go
    steps:
      - checkout
      - gomod
      - run: make check

  release:
    executor: go
    steps:
      - checkout
      - gomod
      - run: make check
      - run: make release

workflows:
  version: 2
  ci:
    jobs:
      - test
  release:
    jobs:
      - release:
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /v[0-9]+(\.[0-9]+)*(-.*)*/

Automate release on tag push
Automate release on tag push
