Skip to content

Commit b2a4ddc

Browse files
authored
Merge pull request #85 from RoboCup-SSL/pipeline
Update build and release pipeline
2 parents 692e955 + 18ffb15 commit b2a4ddc

File tree

14 files changed

+110
-45
lines changed

14 files changed

+110
-45
lines changed

.circleci/config.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
version: 2.1
2+
parameters:
3+
cmds:
4+
type: string
5+
default: "ssl-game-controller ssl-ref-client"
6+
27
jobs:
38
build_node:
49
resource_class: medium
@@ -46,7 +51,7 @@ jobs:
4651
- run: |
4752
set -u
4853
version=${CIRCLE_TAG:-}
49-
for cmd in ssl-game-controller ssl-ref-client; do
54+
for cmd in ${cmds}; do
5055
GOOS=linux GOARCH=amd64 go build -o ./release/${cmd}_${version}_linux_amd64 ./cmd/${cmd}
5156
GOOS=linux GOARCH=arm64 go build -o ./release/${cmd}_${version}_linux_arm64 ./cmd/${cmd}
5257
GOOS=linux GOARCH=arm go build -o ./release/${cmd}_${version}_linux_arm ./cmd/${cmd}
@@ -69,9 +74,9 @@ jobs:
6974
- run: |
7075
set -u
7176
go install github.com/tcnksm/[email protected]
72-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./release
77+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete -generatenotes ${CIRCLE_TAG} ./release
7378
74-
docker:
79+
build_docker:
7580
resource_class: small
7681
docker:
7782
- image: cimg/base:2023.04
@@ -80,11 +85,27 @@ jobs:
8085
- setup_remote_docker:
8186
version: 20.10.18
8287
- run: |
83-
TAG=${CIRCLE_TAG:-1}
88+
for cmd in ${cmds}; do
89+
docker build -f ./cmd/${cmd}/Dockerfile -t robocupssl/${cmd}:latest .
90+
done
91+
92+
publish_docker:
93+
resource_class: small
94+
docker:
95+
- image: cimg/base:2023.04
96+
steps:
97+
- checkout
98+
- setup_remote_docker:
99+
version: 20.10.18
100+
- run: |
101+
# Parse version from tag (removing 'v' prefix)
102+
TAG=${CIRCLE_TAG:1}
84103
TAG=${TAG:-latest}
85-
docker build -t robocupssl/ssl-game-controller:$TAG .
86-
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
87-
docker push robocupssl/ssl-game-controller:$TAG
104+
for cmd in ${cmds}; do
105+
docker build -f ./cmd/${cmd}/Dockerfile -t robocupssl/${cmd}:${TAG} .
106+
docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"
107+
docker push robocupssl/${cmd}:${TAG}
108+
done
88109
89110
workflows:
90111
version: 2
@@ -106,6 +127,7 @@ workflows:
106127
filters: { branches: { ignore: /.*/ }, tags: { only: /^v.*/ } }
107128
docker:
108129
jobs:
109-
- docker:
130+
- build_docker
131+
- publish_docker:
110132
context: docker hub
111133
filters: { branches: { only: master }, tags: { only: /^v.*/ } }

.dockerignore

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
.circleci
2-
.idea
3-
.vscode
4-
.local
5-
/config
6-
/doc
7-
node_modules
8-
/proto
9-
.git
10-
/Dockerfile
11-
/.env
12-
/docker-compose.yaml
13-
/state-store.json.stream
14-
dist
1+
*
2+
!cmd
3+
!frontend
4+
!internal
5+
!pkg
6+
!go.mod
7+
!go.sum
8+
9+
frontend/node_modules
10+
frontend/dist

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ indent_size = 4
1717
[*.{yaml,json}]
1818
indent_style = space
1919
indent_size = 2
20+
21+
[Makefile]
22+
indent_style = tab

.github/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
changelog:
2+
categories:
3+
- title: 🏕 Features
4+
labels:
5+
- '*'
6+
exclude:
7+
labels:
8+
- dependencies
9+
- title: 👒 Dependencies
10+
labels:
11+
- dependencies

.github/renovate.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"extends": [
33
"config:base",
44
"schedule:monthly"
5+
],
6+
"labels": [
7+
"dependencies"
58
]
69
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ yarn-error.log*
2626

2727
# Local installations
2828
/.local
29+
30+
# Make cache
31+
/.frontend

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.PHONY: all ssl-game-controller-docker ssl-ref-client-docker docker frontend test install proto
2+
3+
all: install docker
4+
5+
docker-ssl-game-controller:
6+
docker build -f ./cmd/ssl-game-controller/Dockerfile -t ssl-game-controller:latest .
7+
8+
docker-ssl-ref-client:
9+
docker build -f ./cmd/ssl-ref-client/Dockerfile -t ssl-ref-client:latest .
10+
11+
docker: docker-ssl-game-controller docker-ssl-ref-client
12+
13+
.frontend: $(shell find frontend/ -type f)
14+
cd frontend && \
15+
npm install && \
16+
npm run build && \
17+
touch ../.frontend
18+
19+
frontend: .frontend
20+
21+
test: frontend
22+
go test ./...
23+
24+
install: frontend
25+
go install -v ./...
26+
27+
proto:
28+
tools/generateProto.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ go run cmd/ssl-game-controller/main.go
149149
### Build self-contained release binary
150150

151151
```bash
152-
./install.sh
152+
make install
153153
```
154154

155155
### Test with autoRefs

Dockerfile renamed to cmd/ssl-game-controller/Dockerfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ RUN npm run build
66

77
FROM golang:1.20-alpine AS build_go
88
WORKDIR /go/src/github.com/RoboCup-SSL/ssl-game-controller
9-
COPY cmd cmd
10-
COPY internal internal
11-
COPY pkg pkg
12-
COPY frontend frontend
13-
COPY go.mod .
14-
COPY go.sum .
9+
COPY . .
1510
COPY --from=build_node /tmp/ssl-game-controller/frontend/dist frontend/dist
1611
RUN go install -v ./cmd/ssl-game-controller
1712

@@ -20,6 +15,5 @@ FROM alpine:3
2015
COPY --from=build_go /go/bin/ssl-game-controller /app/ssl-game-controller
2116
RUN mkdir -p config && chown -R 1000: config
2217
USER 1000
23-
EXPOSE 8081 10007 10008 10009 10011 10107 10108 10111
2418
ENTRYPOINT ["/app/ssl-game-controller"]
2519
CMD []

cmd/ssl-ref-client/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1.20-alpine AS build_go
2+
WORKDIR /go/src/github.com/RoboCup-SSL/ssl-game-controller
3+
COPY . .
4+
RUN go install -v ./cmd/ssl-ref-client
5+
6+
# Start fresh from a smaller image
7+
FROM alpine:3
8+
COPY --from=build_go /go/bin/ssl-ref-client /app/ssl-ref-client
9+
USER 1000
10+
ENTRYPOINT ["/app/ssl-ref-client"]
11+
CMD []

0 commit comments

Comments
 (0)