]>
Commit | Line | Data |
---|---|---|
6988a057 JH |
1 | # Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference |
2 | version: 2.1 | |
3 | jobs: | |
4 | build: | |
5 | working_directory: ~/repo | |
6 | docker: | |
7 | - image: cimg/go:1.16.6 | |
8 | steps: | |
9 | - checkout | |
10 | # - restore_cache: | |
11 | # keys: | |
12 | # - go-mod-v4-{{ checksum "go.sum" }} | |
13 | - run: | |
14 | name: Install Dependencies | |
15 | command: go mod download | |
16 | # - save_cache: | |
17 | # key: go-mod-v4-{{ checksum "go.sum" }} | |
18 | # paths: | |
19 | # - "/go/pkg/mod" | |
20 | - run: | |
21 | name: Run tests | |
22 | command: | | |
23 | mkdir -p /tmp/test-reports | |
24 | gotestsum --junitfile /tmp/test-reports/unit-tests.xml | |
25 | - store_test_results: | |
26 | path: /tmp/test-reports | |
27 | ||
28 | deploy: | |
29 | docker: | |
30 | - image: cimg/go:1.16.6 | |
31 | # working_directory: /go/src/github.com/jhalter/mobius | |
32 | steps: | |
33 | - checkout | |
34 | - run: go get -u github.com/mitchellh/gox | |
35 | - run: go get -u github.com/tcnksm/ghr | |
36 | - run: go get -u github.com/stevenmatthewt/semantics | |
37 | - run: | |
38 | name: cross compile | |
39 | command: | | |
40 | mkdir dist | |
41 | mkdir dist/mobius_server_linux_amd64 | |
42 | mkdir dist/mobius_server_darwin_amd64 | |
43 | mkdir dist/mobius_server_linux_arm | |
44 | ||
0c0b2680 | 45 | cd cmd/server |
6988a057 | 46 | |
0c0b2680 JH |
47 | cp -r mobius/config ../../dist/mobius_server_linux_amd64/config |
48 | cp -r mobius/config ../../dist/mobius_server_darwin_amd64/config | |
49 | cp -r mobius/config ../../dist/mobius_server_linux_arm/config | |
6988a057 | 50 | |
0c0b2680 JH |
51 | gox -os="linux" -arch="amd64" -output="../../dist/mobius_server_linux_amd64/mobius_server" |
52 | gox -os="darwin" -arch="amd64" -output="../../dist/mobius_server_darwin_amd64/mobius_server" | |
53 | gox -os="linux" -arch="arm" -output="../../dist/mobius_server_linux_arm/mobius_server" | |
6988a057 JH |
54 | |
55 | cd ../client | |
0c0b2680 JH |
56 | gox -os="linux" -arch="amd64" -output="../../dist/mobius_client_linux_amd64/mobius_client" |
57 | gox -os="darwin" -arch="amd64" -output="../../dist/mobius_client_darwin_amd64/mobius_client" | |
6988a057 | 58 | |
0c0b2680 | 59 | cd ../../dist |
6988a057 JH |
60 | tar -zcvf mobius_server_linux_amd64.tar.gz mobius_server_linux_amd64 |
61 | tar -zcvf mobius_server_darwin_amd64.tar.gz mobius_server_darwin_amd64 | |
62 | tar -zcvf mobius_server_linux_arm.tar.gz mobius_server_linux_arm | |
63 | tar -zcvf mobius_client_linux_amd64.tar.gz mobius_client_linux_amd64 | |
64 | tar -zcvf mobius_client_darwin_amd64.tar.gz mobius_client_darwin_amd64 | |
65 | - add_ssh_keys | |
66 | - run: | |
67 | name: create release | |
68 | command: | | |
69 | tag=$(semantics --output-tag) | |
70 | if [ "$tag" ]; then | |
71 | ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace $tag dist/ | |
72 | else | |
73 | echo "The commit message(s) did not indicate a major/minor/patch version." | |
74 | fi | |
75 | ||
76 | workflows: | |
77 | version: 2 | |
78 | build-deploy: | |
79 | jobs: | |
80 | - build | |
81 | - deploy: | |
82 | requires: | |
83 | - build | |
84 | filters: | |
85 | branches: | |
86 | only: master |