Skip to content

Commit df4b307

Browse files
authored
ci: github (#157)
1 parent a26a7c3 commit df4b307

8 files changed

Lines changed: 165 additions & 168 deletions

File tree

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/docker/Dockerfile.dev
2-
/docker/Dockerfile
32
/ui/node_modules/
43
.idea/
54
build/

.github/workflows/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: build
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/setup-go@v5
9+
with:
10+
go-version: 1.22.x
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: '20'
14+
- uses: actions/checkout@v4
15+
- run: make download-tools
16+
- run: make install
17+
- run: make generate
18+
- run: make lint
19+
- run: make test
20+
- run: make build-js
21+
env:
22+
NODE_OPTIONS: --openssl-legacy-provider
23+
- run: make packr
24+
- if: startsWith(github.ref, 'refs/tags/v')
25+
run: echo "$DOCKER_PASS" | docker login --username "scregoci" --password-stdin
26+
env:
27+
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
28+
- if: startsWith(github.ref, 'refs/tags/v')
29+
run: make release
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
dist/
23
build
34
vendor
45
coverage.txt

.goreleaser.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
project_name: traggo
2+
builds:
3+
- id: linux-amd64
4+
main: ./
5+
goos: [linux]
6+
goarch: ['amd64']
7+
flags: ['-tags="netgo osusergo sqlite_omit_load_extension"']
8+
ldflags: ["-s","-w","-linkmode","external","-extldflags","-static","-X main.BuildDate={{.Date}}","-X main.BuildMode=prod","-X main.BuildCommit={{.Commit}}","-X main.BuildVersion={{.Version}}"]
9+
- id: linux-386
10+
main: ./
11+
goos: [linux]
12+
goarch: ['386']
13+
flags: ['-tags="netgo osusergo sqlite_omit_load_extension"']
14+
ldflags: ["-s","-w","-linkmode","external","-extldflags","-static","-X main.BuildDate={{.Date}}","-X main.BuildMode=prod","-X main.BuildCommit={{.Commit}}","-X main.BuildVersion={{.Version}}"]
15+
- id: linux-armhf
16+
main: ./
17+
goos: [linux]
18+
goarch: [arm]
19+
goarm: [7]
20+
env: [CC=arm-linux-gnueabihf-gcc, CXX=arm-linux-gnueabihf-g++]
21+
flags: ['-tags="netgo osusergo sqlite_omit_load_extension"']
22+
ldflags: ["-s","-w","-linkmode","external","-extldflags","-static","-X main.BuildDate={{.Date}}","-X main.BuildMode=prod","-X main.BuildCommit={{.Commit}}","-X main.BuildVersion={{.Version}}"]
23+
- id: linux-arm64
24+
main: ./
25+
goos: [linux]
26+
goarch: [arm64]
27+
env: [CC=aarch64-linux-gnu-gcc, CXX=aarch64-linux-gnu-g++]
28+
flags: ['-tags="netgo osusergo sqlite_omit_load_extension"']
29+
ldflags: ["-s","-w","-linkmode","external","-extldflags","-static","-X main.BuildDate={{.Date}}","-X main.BuildMode=prod","-X main.BuildCommit={{.Commit}}","-X main.BuildVersion={{.Version}}"]
30+
- id: windows-amd64
31+
main: ./
32+
goos: [windows]
33+
goarch: [amd64]
34+
env: [CC=x86_64-w64-mingw32-gcc, CXX=x86_64-w64-mingw32-gcc]
35+
flags: ['-tags="netgo osusergo sqlite_omit_load_extension"']
36+
ldflags: ["-s","-w","-linkmode","external","-extldflags","-static","-X main.BuildDate={{.Date}}","-X main.BuildMode=prod","-X main.BuildCommit={{.Commit}}","-X main.BuildVersion={{.Version}}"]
37+
archives:
38+
- files:
39+
- LICENSE
40+
- README.md
41+
- .env.sample
42+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "386" }}i386{{- else }}{{ .Arch }}{{ end }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
43+
format_overrides:
44+
- goos: windows
45+
format: zip
46+
checksum:
47+
disable: true
48+
changelog:
49+
skip: true
50+
dockers:
51+
- use: buildx
52+
goos: linux
53+
goarch: amd64
54+
image_templates:
55+
- "traggo/server:amd64-latest"
56+
- "traggo/server:amd64-{{ .RawVersion }}"
57+
dockerfile: docker/Dockerfile
58+
build_flag_templates:
59+
- "--platform=linux/amd64"
60+
- "--label=org.opencontainers.image.created={{.Date}}"
61+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
62+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
63+
- "--label=org.opencontainers.image.version={{.Version}}"
64+
- use: buildx
65+
goos: linux
66+
goarch: '386'
67+
image_templates:
68+
- "traggo/server:386-latest"
69+
- "traggo/server:386-{{ .RawVersion }}"
70+
dockerfile: docker/Dockerfile
71+
build_flag_templates:
72+
- "--platform=linux/386"
73+
- "--label=org.opencontainers.image.created={{.Date}}"
74+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
75+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
76+
- "--label=org.opencontainers.image.version={{.Version}}"
77+
- use: buildx
78+
goos: linux
79+
goarch: arm64
80+
image_templates:
81+
- "traggo/server:arm64-latest"
82+
- "traggo/server:arm64-{{ .RawVersion }}"
83+
dockerfile: docker/Dockerfile
84+
build_flag_templates:
85+
- "--platform=linux/arm64"
86+
- "--label=org.opencontainers.image.created={{.Date}}"
87+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
88+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
89+
- "--label=org.opencontainers.image.version={{.Version}}"
90+
- use: buildx
91+
goos: linux
92+
goarch: arm
93+
goarm: 7
94+
image_templates:
95+
- "traggo/server:armv7-latest"
96+
- "traggo/server:armv7-{{ .RawVersion }}"
97+
dockerfile: docker/Dockerfile
98+
build_flag_templates:
99+
- "--platform=linux/arm/v7"
100+
- "--label=org.opencontainers.image.created={{.Date}}"
101+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
102+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
103+
- "--label=org.opencontainers.image.version={{.Version}}"
104+
docker_manifests:
105+
- name_template: "traggo/server:latest"
106+
image_templates:
107+
- "screego/server:amd64-latest"
108+
- "screego/server:386-latest"
109+
- "screego/server:arm64-latest"
110+
- "screego/server:armv7-latest"
111+
- name_template: "traggo/server:{{ .RawVersion }}"
112+
image_templates:
113+
- "screego/server:amd64-{{ .RawVersion }}"
114+
- "screego/server:386-{{ .RawVersion }}"
115+
- "screego/server:arm64-{{ .RawVersion }}"
116+
- "screego/server:armv7-{{ .RawVersion }}"

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

Makefile

Lines changed: 13 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,16 @@ COMMIT=$(shell git rev-parse --verify HEAD)
44
DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
55
LD_FLAGS=-s -w -linkmode external -extldflags "-static" -X main.BuildDate=$(DATE) -X main.BuildMode=prod -X main.BuildCommit=$(COMMIT) -X main.BuildVersion=$(VERSION)
66
BUILD_DIR=./build
7-
BUILD_LICENSE=${BUILD_DIR}/license/3RD_PARTY_LICENSES
8-
UI_BUILD_LICENSE=${BUILD_DIR}/license/UI_3RD_PARTY_LICENSES
97
PWD=$(shell pwd)
10-
GO_VERSION=1.13.1
11-
DOCKER_BUILD_IMAGE=traggo/build
12-
DOCKER_WORKDIR=/proj
13-
GOPATH_VOLUME=-v "`go env GOPATH`/pkg/mod/:/go/pkg/mod"
14-
WORKDIR_VOLUME=-v "${PWD}/:${DOCKER_WORKDIR}"
15-
DOCKER_GO_BUILD=go build -a -installsuffix cgo -ldflags '${LD_FLAGS}' -tags '${TAGS}'
16-
DOCKER_RUN=docker run --rm ${WORKDIR_VOLUME} ${GOPATH_VOLUME} -w ${DOCKER_WORKDIR}
17-
NEW_IMAGE_NAME=traggo/server
18-
DOCKER_MANIFEST=DOCKER_CLI_EXPERIMENTAL=enabled docker manifest
19-
BIN_PREFIX=traggo-server
8+
GOLANG_CROSS_VERSION=v1.22.0
209

2110
license-dir:
2211
mkdir -p build/license || true
2312

2413
download-tools:
2514
go install golang.org/x/tools/cmd/goimports@v0.1.10
2615
go install github.com/gobuffalo/packr/v2/packr2@v2.7.1
27-
go install github.com/99designs/gqlgen@v0.17.42
16+
go install github.com/99designs/gqlgen@v0.17.44
2817

2918
generate-go:
3019
gqlgen
@@ -80,95 +69,18 @@ pre-build: build-js packr
8069
build-bin-local: pre-build
8170
CGO_ENABLED=1 go build -a -ldflags '${LD_FLAGS}' -tags '${TAGS}' -o ${BUILD_DIR}/traggo-server
8271

83-
build-bin-linux-amd64: pre-build
84-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-amd64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-amd64 ${DOCKER_WORKDIR}
72+
.PHONY: release
73+
release:
74+
docker build -t traggo:build -f docker/Dockerfile.build docker
75+
docker run \
76+
--rm \
77+
-e CGO_ENABLED=1 \
78+
-v /var/run/docker.sock:/var/run/docker.sock \
79+
-v $$PWD:/work \
80+
-w /work \
81+
traggo:build \
82+
release --skip-validate
8583

86-
build-docker-linux-amd64:
87-
cp ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-amd64 docker/traggo && docker build -t ${NEW_IMAGE_NAME}:amd64-latest -t ${NEW_IMAGE_NAME}:amd64-${VERSION} docker/ && rm docker/traggo
88-
89-
build-bin-linux-386: pre-build
90-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-386 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-386 ${DOCKER_WORKDIR}
91-
92-
build-docker-linux-386:
93-
cp ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-386 docker/traggo && docker build -t ${NEW_IMAGE_NAME}:386-latest -t ${NEW_IMAGE_NAME}:386-${VERSION} docker/ && rm docker/traggo
94-
95-
build-bin-linux-arm-7: pre-build
96-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm-7 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-arm-7 ${DOCKER_WORKDIR}
97-
98-
build-docker-linux-arm-7:
99-
cp ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-arm-7 docker/traggo && docker build -t ${NEW_IMAGE_NAME}:arm-7-latest -t ${NEW_IMAGE_NAME}:arm-7-${VERSION} docker/ && rm docker/traggo
100-
101-
build-bin-linux-arm64: pre-build
102-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-arm64 ${DOCKER_WORKDIR}
103-
104-
build-docker-linux-arm64:
105-
cp ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-arm64 docker/traggo && docker build -t ${NEW_IMAGE_NAME}:arm64-latest -t ${NEW_IMAGE_NAME}:arm64-${VERSION} docker/ && rm docker/traggo
106-
107-
build-bin-windows-amd64: pre-build
108-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-windows-amd64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-windows-amd64.exe ${DOCKER_WORKDIR}
109-
110-
build-bin-windows-386: pre-build
111-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-windows-386 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-windows-386.exe ${DOCKER_WORKDIR}
112-
113-
build-bin-linux-ppc64le: pre-build
114-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-ppc64le ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-ppc64le ${DOCKER_WORKDIR}
115-
116-
build-docker-linux-ppc64le:
117-
cp ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-ppc64le docker/traggo && docker build -t ${NEW_IMAGE_NAME}:ppc64le-latest -t ${NEW_IMAGE_NAME}:ppc64le-${VERSION} docker/ && rm docker/traggo
118-
119-
build-bin-linux-s390x: pre-build
120-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-s390x ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-s390x ${DOCKER_WORKDIR}
121-
122-
build-docker-linux-s390x:
123-
cp ${BUILD_DIR}/${BIN_PREFIX}-${VERSION}-linux-s390x docker/traggo && docker build -t ${NEW_IMAGE_NAME}:s390x-latest -t ${NEW_IMAGE_NAME}:s390x-${VERSION} docker/ && rm docker/traggo
124-
125-
build-bin: build-bin-linux-amd64 build-bin-linux-386 build-bin-linux-arm-7 build-bin-linux-arm64 build-bin-linux-ppc64le build-bin-linux-s390x build-bin-windows-amd64 build-bin-windows-386
126-
127-
build-docker: build-docker-linux-amd64 build-docker-linux-386 build-docker-linux-arm-7 build-docker-linux-arm64 build-docker-linux-ppc64le build-docker-linux-s390x
128-
129-
fix-build-owner:
130-
sudo chown -R $(shell id -u):$(shell id -g) ${BUILD_DIR}
131-
132-
docker-login-ci:
133-
docker login -u "$$DOCKER_USER" -p "$$DOCKER_PASS";
134-
135-
docker-push:
136-
docker push --all-tags ${NEW_IMAGE_NAME}
137-
138-
docker-push-manifest:
139-
${DOCKER_MANIFEST} create "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:amd64-latest" "${NEW_IMAGE_NAME}:386-latest" "${NEW_IMAGE_NAME}:arm-7-latest" "${NEW_IMAGE_NAME}:arm64-latest" "${NEW_IMAGE_NAME}:ppc64le-latest" "${NEW_IMAGE_NAME}:s390x-latest"
140-
${DOCKER_MANIFEST} create "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:amd64-${VERSION}" "${NEW_IMAGE_NAME}:386-${VERSION}" "${NEW_IMAGE_NAME}:arm-7-${VERSION}" "${NEW_IMAGE_NAME}:arm64-${VERSION}" "${NEW_IMAGE_NAME}:ppc64le-${VERSION}" "${NEW_IMAGE_NAME}:s390x-${VERSION}"
141-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:amd64-latest" --os=linux --arch=amd64
142-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:amd64-${VERSION}" --os=linux --arch=amd64
143-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:386-latest" --os=linux --arch=386
144-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:386-${VERSION}" --os=linux --arch=386
145-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:arm-7-latest" --os=linux --arch=arm --variant=v7
146-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:arm-7-${VERSION}" --os=linux --arch=arm --variant=v7
147-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:arm64-latest" --os=linux --arch=arm64
148-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:arm64-${VERSION}" --os=linux --arch=arm64
149-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:ppc64le-latest" --os=linux --arch=ppc64le
150-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:ppc64le-${VERSION}" --os=linux --arch=ppc64le
151-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:latest" "${NEW_IMAGE_NAME}:s390x-latest" --os=linux --arch=s390x
152-
${DOCKER_MANIFEST} annotate "${NEW_IMAGE_NAME}:${VERSION}" "${NEW_IMAGE_NAME}:s390x-${VERSION}" --os=linux --arch=s390x
153-
${DOCKER_MANIFEST} push "${NEW_IMAGE_NAME}:${VERSION}"
154-
${DOCKER_MANIFEST} push "${NEW_IMAGE_NAME}:latest"
155-
156-
licenses-ui: license-dir
157-
(cd ui && yarn -s licenses generate-disclaimer --prod > ../${UI_BUILD_LICENSE})
158-
159-
licenses-go: license-dir
160-
go mod vendor
161-
echo "THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THE TRAGGO PRODUCT" > ${BUILD_LICENSE}
162-
echo >> ${BUILD_LICENSE}
163-
echo ------- >> ${BUILD_LICENSE}
164-
echo >> ${BUILD_LICENSE}
165-
(cd vendor && find . -type f \( -iname "LICENSE*" -o -iname "NOTICE*" \) -exec echo The following software may be included in this product {} \; -exec echo \; -exec cat {} \; -exec echo \; -exec echo -------- \; -exec echo \;) >> ${BUILD_LICENSE}
166-
167-
package-zip: licenses-ui licenses-go
168-
find build/* -maxdepth 0 -type f -exec zip -9 -j {}.zip {} build/license/3RD_PARTY_LICENSES build/license/UI_3RD_PARTY_LICENSES LICENSE \;
169-
170-
build-compress:
171-
find build/* -maxdepth 0 -type f -exec upx {} \;
17284

17385
install: install-go install-js
17486

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM scratch
22
WORKDIR /opt/traggo
3-
ADD traggo /opt/traggo
3+
COPY traggo /opt/traggo
44
EXPOSE 3030
55
ENTRYPOINT ["./traggo"]

docker/Dockerfile.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM ghcr.io/goreleaser/goreleaser-cross:v1.22.0
2+
3+
RUN apt-get update && apt-get install -y libc6-dev-i386

0 commit comments

Comments
 (0)