aboutsummaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: 9cb2b4255347b620f33ff715ca2e1626302fd17d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
jobs:
  build:
    working_directory: ~/repo
    docker:
      - image: cimg/go:1.18.3
    steps:
      - checkout
#      - restore_cache:
#          keys:
#            - go-mod-v4-{{ checksum "go.sum" }}
      - run:
          name: Install Dependencies
          command: go mod download
#      - save_cache:
#          key: go-mod-v4-{{ checksum "go.sum" }}
#          paths:
#            - "/go/pkg/mod"
      - run:
          name: Run tests
          command: |
            mkdir -p /tmp/test-reports
            gotestsum --junitfile /tmp/test-reports/unit-tests.xml
      - store_test_results:
          path: /tmp/test-reports

  deploy:
    docker:
      - image: cimg/go:1.16.6
#    working_directory: /go/src/github.com/jhalter/mobius
    steps:
      - checkout
      - run: go get -u github.com/mitchellh/gox
      - run: go get -u github.com/tcnksm/ghr
      - run: go get -u github.com/stevenmatthewt/semantics
      - run:
          name: cross compile
          command: |
            make all
      - add_ssh_keys
      - run:
          name: create release
          command: |
            tag=$(semantics --output-tag)
            if [ "$tag" ]; then
              ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace $tag dist/
            else
              echo "The commit message(s) did not indicate a major/minor/patch version."
            fi

workflows:
  version: 2
  build-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master