|
1 | | -version: 2 |
| 1 | +version: 2.1 |
| 2 | +parameters: |
| 3 | + cmds: |
| 4 | + type: string |
| 5 | + default: "ssl-quality-inspector" |
| 6 | + |
2 | 7 | jobs: |
3 | | - backend: |
| 8 | + test_go: |
| 9 | + resource_class: medium |
| 10 | + docker: |
| 11 | + - image: cimg/go:1.20.2 |
| 12 | + steps: |
| 13 | + - checkout |
| 14 | + - attach_workspace: |
| 15 | + at: . |
| 16 | + - run: go get -v -t -d ./... |
| 17 | + - run: go test -v -covermode=count -coverprofile=count.out ./... |
| 18 | + - run: go tool cover -html=count.out -o coverage.html |
| 19 | + - store_artifacts: |
| 20 | + path: coverage.html |
| 21 | + destination: coverage |
| 22 | + |
| 23 | + build_go: |
| 24 | + resource_class: large |
4 | 25 | docker: |
5 | | - - image: circleci/golang:1.17 |
| 26 | + - image: cimg/go:1.20.2 |
| 27 | + steps: |
| 28 | + - checkout |
| 29 | + - attach_workspace: |
| 30 | + at: . |
| 31 | + - run: go get -v -t -d ./... |
| 32 | + - run: | |
| 33 | + set -u |
| 34 | + version=${CIRCLE_TAG:-} |
| 35 | + for cmd in << pipeline.parameters.cmds >>; do |
| 36 | + GOOS=linux GOARCH=amd64 go build -o ./release/${cmd}_${version}_linux_amd64 ./cmd/${cmd} |
| 37 | + GOOS=linux GOARCH=arm64 go build -o ./release/${cmd}_${version}_linux_arm64 ./cmd/${cmd} |
| 38 | + GOOS=linux GOARCH=arm go build -o ./release/${cmd}_${version}_linux_arm ./cmd/${cmd} |
| 39 | + GOOS=darwin GOARCH=amd64 go build -o ./release/${cmd}_${version}_darwin_amd64 ./cmd/${cmd} |
| 40 | + GOOS=darwin GOARCH=arm64 go build -o ./release/${cmd}_${version}_darwin_arm64 ./cmd/${cmd} |
| 41 | + GOOS=windows GOARCH=amd64 go build -o ./release/${cmd}_${version}_windows_amd64.exe ./cmd/${cmd} |
| 42 | + done |
| 43 | + - persist_to_workspace: |
| 44 | + root: . |
| 45 | + paths: |
| 46 | + - release/* |
6 | 47 |
|
7 | | - working_directory: /go/src/github.com/RoboCup-SSL/ssl-quality-inspector |
| 48 | + publish_gh: |
| 49 | + resource_class: small |
| 50 | + docker: |
| 51 | + - image: cimg/go:1.20.2 |
8 | 52 | steps: |
9 | | - - checkout |
10 | | - - run: go get -v -t -d ./... |
11 | | - - run: go test -v ./... |
12 | | - - run: |
13 | | - working_directory: cmd/ssl-quality-inspector |
14 | | - command: | |
15 | | - GOOS=linux GOARCH=amd64 go build -o ../../release/ssl-quality-inspector_linux_amd64 |
16 | | - GOOS=darwin GOARCH=amd64 go build -o ../../release/ssl-quality-inspector_darwin_amd64 |
17 | | - GOOS=windows GOARCH=amd64 go build -o ../../release/ssl-quality-inspector_windows_amd64.exe |
18 | | - - persist_to_workspace: |
19 | | - root: . |
20 | | - paths: |
21 | | - - release/* |
| 53 | + - attach_workspace: |
| 54 | + at: . |
| 55 | + - run: | |
| 56 | + set -u |
| 57 | + go install github.com/tcnksm/[email protected] |
| 58 | + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -generatenotes ${CIRCLE_TAG} ./release |
22 | 59 |
|
23 | | - publish-github-release: |
| 60 | + build_docker: |
| 61 | + resource_class: small |
24 | 62 | docker: |
25 | | - - image: circleci/golang:1.17 |
| 63 | + - image: cimg/base:2023.04 |
26 | 64 | steps: |
27 | | - - attach_workspace: |
28 | | - at: . |
29 | | - - run: |
30 | | - name: "Prepare artifacts" |
31 | | - working_directory: release |
32 | | - command: | |
33 | | - mv ssl-quality-inspector_linux_amd64 ssl-quality-inspector_${CIRCLE_TAG}_linux_amd64 |
34 | | - mv ssl-quality-inspector_darwin_amd64 ssl-quality-inspector_${CIRCLE_TAG}_darwin_amd64 |
35 | | - mv ssl-quality-inspector_windows_amd64.exe ssl-quality-inspector_${CIRCLE_TAG}_windows_amd64.exe |
36 | | - - run: |
37 | | - name: "Publish Release on GitHub" |
38 | | - command: | |
39 | | - go get github.com/tcnksm/ghr |
40 | | - ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release/ |
| 65 | + - checkout |
| 66 | + - setup_remote_docker: |
| 67 | + version: 20.10.18 |
| 68 | + - run: | |
| 69 | + for cmd in << pipeline.parameters.cmds >>; do |
| 70 | + docker build --build-arg cmd=${cmd} -t robocupssl/${cmd}:latest . |
| 71 | + done |
| 72 | +
|
| 73 | + publish_docker: |
| 74 | + resource_class: small |
| 75 | + docker: |
| 76 | + - image: cimg/base:2023.04 |
| 77 | + steps: |
| 78 | + - checkout |
| 79 | + - setup_remote_docker: |
| 80 | + version: 20.10.18 |
| 81 | + - run: | |
| 82 | + # Parse version from tag (removing 'v' prefix) |
| 83 | + TAG=${CIRCLE_TAG:1} |
| 84 | + TAG=${TAG:-latest} |
| 85 | + for cmd in << pipeline.parameters.cmds >>; do |
| 86 | + docker build --build-arg cmd=${cmd} -t robocupssl/${cmd}:${TAG} . |
| 87 | + docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}" |
| 88 | + docker push robocupssl/${cmd}:${TAG} |
| 89 | + done |
41 | 90 |
|
42 | 91 | workflows: |
43 | 92 | version: 2 |
44 | | - main: |
| 93 | + build: |
| 94 | + jobs: |
| 95 | + - test_go |
| 96 | + release: |
| 97 | + jobs: |
| 98 | + - build_go: |
| 99 | + filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } } |
| 100 | + - publish_gh: |
| 101 | + context: github |
| 102 | + requires: [ build_go ] |
| 103 | + filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } } |
| 104 | + docker: |
45 | 105 | jobs: |
46 | | - - backend: |
47 | | - filters: |
48 | | - tags: |
49 | | - only: /.*/ |
50 | | - - publish-github-release: |
51 | | - requires: |
52 | | - - backend |
53 | | - filters: |
54 | | - branches: |
55 | | - ignore: /.*/ |
56 | | - tags: |
57 | | - only: /^v.*/ |
| 106 | + - build_docker: |
| 107 | + filters: { branches: { ignore: master } } |
| 108 | + - publish_docker: |
| 109 | + context: docker hub |
| 110 | + filters: { branches: { only: master }, tags: { only: /^v.*/ } } |
0 commit comments