Skip to content

Commit 2dd57eb

Browse files
committed
Update build pipeline to also build arm images
1 parent b4b5956 commit 2dd57eb

File tree

1 file changed

+85
-51
lines changed

1 file changed

+85
-51
lines changed

.circleci/config.yml

+85-51
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,116 @@
1-
version: 2
1+
version: 2.1
2+
parameters:
3+
cmds:
4+
type: string
5+
default: "ssl-simulation-controller"
6+
27
jobs:
3-
app:
8+
test_go:
9+
resource_class: medium
410
docker:
5-
- image: cimg/go:1.23@sha256:7ad5b6d5a429411e365f93a685cd8902c42ac19875e866d8723551c03f9f3da7
6-
11+
- image: cimg/go:1.23.5@sha256:d9d2cd7d194f229721b28b24c4ca5d8b6876b90e67ca6329943e202940288269
712
steps:
813
- checkout
14+
- attach_workspace:
15+
at: .
916
- run: go get -v -t -d ./...
1017
- run: go test -v -covermode=count -coverprofile=count.out ./...
1118
- run: go tool cover -html=count.out -o coverage.html
12-
- run:
13-
working_directory: cmd/ssl-simulation-controller
14-
command: |
15-
GOOS=linux GOARCH=amd64 go build -o ../../release/ssl-simulation-controller_linux_amd64
16-
GOOS=darwin GOARCH=amd64 go build -o ../../release/ssl-simulation-controller_darwin_amd64
17-
GOOS=windows GOARCH=amd64 go build -o ../../release/ssl-simulation-controller_windows_amd64.exe
19+
- store_artifacts:
20+
path: coverage.html
21+
destination: coverage
22+
23+
build_go:
24+
resource_class: large
25+
docker:
26+
- image: cimg/go:1.23.5@sha256:d9d2cd7d194f229721b28b24c4ca5d8b6876b90e67ca6329943e202940288269
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
1843
- persist_to_workspace:
1944
root: .
2045
paths:
2146
- release/*
22-
- store_artifacts:
23-
path: coverage.html
24-
destination: coverage
2547

26-
publish-github-release:
48+
publish_gh:
49+
resource_class: small
2750
docker:
28-
- image: cimg/go:1.23@sha256:7ad5b6d5a429411e365f93a685cd8902c42ac19875e866d8723551c03f9f3da7
51+
- image: cimg/go:1.23.5@sha256:d9d2cd7d194f229721b28b24c4ca5d8b6876b90e67ca6329943e202940288269
2952
steps:
3053
- attach_workspace:
3154
at: .
32-
- run:
33-
name: "Prepare artifacts"
34-
working_directory: release
35-
command: |
36-
mv ssl-simulation-controller_linux_amd64 ssl-simulation-controller_${CIRCLE_TAG}_linux_amd64
37-
mv ssl-simulation-controller_darwin_amd64 ssl-simulation-controller_${CIRCLE_TAG}_darwin_amd64
38-
mv ssl-simulation-controller_windows_amd64.exe ssl-simulation-controller_${CIRCLE_TAG}_windows_amd64.exe
39-
- run:
40-
name: "Publish Release on GitHub"
41-
command: |
42-
go install github.com/tcnksm/ghr@v0.14.0
43-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release/
55+
- run: |
56+
set -u
57+
go install github.com/tcnksm/ghr@v0.16.0
58+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -generatenotes ${CIRCLE_TAG} ./release
4459
45-
docker:
60+
build_docker:
61+
resource_class: small
4662
docker:
4763
- image: cimg/base:2025.01@sha256:f6b81723236539a091130e4f0e57c599253abf2e3980aa4e60eeee871b4e2ef7
4864
steps:
4965
- checkout
5066
- setup_remote_docker
5167
- run: |
68+
docker buildx create \
69+
--name container-builder \
70+
--driver docker-container \
71+
--bootstrap --use
72+
for cmd in << pipeline.parameters.cmds >>; do
73+
docker buildx build --platform linux/amd64,linux/arm64 --build-arg cmd=${cmd} -t robocupssl/${cmd}:latest .
74+
done
75+
76+
publish_docker:
77+
resource_class: small
78+
docker:
79+
- image: cimg/base:2025.01@sha256:f6b81723236539a091130e4f0e57c599253abf2e3980aa4e60eeee871b4e2ef7
80+
steps:
81+
- checkout
82+
- setup_remote_docker
83+
- run: |
84+
docker buildx create \
85+
--name container-builder \
86+
--driver docker-container \
87+
--bootstrap --use
88+
89+
# Parse version from tag (removing 'v' prefix)
5290
TAG=${CIRCLE_TAG:1}
5391
TAG=${TAG:-latest}
54-
docker build -t robocupssl/ssl-simulation-controller:$TAG .
55-
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
56-
docker push robocupssl/ssl-simulation-controller:$TAG
92+
for cmd in << pipeline.parameters.cmds >>; do
93+
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
94+
docker buildx build --platform linux/amd64,linux/arm64 --build-arg cmd=${cmd} -t robocupssl/${cmd}:${TAG} --push .
95+
done
5796
5897
workflows:
5998
version: 2
60-
main:
99+
build:
100+
jobs:
101+
- test_go
102+
release:
61103
jobs:
62-
- app:
63-
filters:
64-
tags:
65-
only: /.*/
66-
- publish-github-release:
104+
- build_go:
105+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
106+
- publish_gh:
67107
context: github
68-
requires:
69-
- app
70-
filters:
71-
branches:
72-
ignore: /.*/
73-
tags:
74-
only: /^v.*/
75-
- docker:
108+
requires: [ build_go ]
109+
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
110+
docker:
111+
jobs:
112+
- build_docker:
113+
filters: { branches: { ignore: master } }
114+
- publish_docker:
76115
context: docker hub
77-
filters:
78-
branches:
79-
only: master
80-
tags:
81-
only: /^v.*/
82-
116+
filters: { branches: { only: master }, tags: { only: /^v.*/ } }

0 commit comments

Comments
 (0)