-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
43 lines (39 loc) · 1.42 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
image: golang:1.23
stages:
- test
- build
- deploy
format:
stage: test
script:
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
- go test -race $(go list ./... | grep -v /vendor/)
compile:
stage: build
script:
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/$CI_PROJECT_NAME
artifacts:
paths:
- $CI_PROJECT_NAME
deploy:
stage: deploy
before_script:
- go install github.com/google/ko@latest
- ko login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag="$CI_COMMIT_REF_NAME"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- KO_DOCKER_REPO=$CI_REGISTRY_IMAGE VERSION=${tag} ko build --bare --tags ${tag},latest --platform=linux/amd64,linux/arm64,linux/arm
- KO_DOCKER_REPO=$CI_REGISTRY_IMAGE VERSION=${tag} ko build --bare --tags ${tag}-amd64 --platform=linux/amd64
- KO_DOCKER_REPO=$CI_REGISTRY_IMAGE VERSION=${tag} ko build --bare --tags ${tag}-aarch64 --platform=linux/arm64
- KO_DOCKER_REPO=$CI_REGISTRY_IMAGE VERSION=${tag} ko build --bare --tags ${tag}-armv6hf,${tag}-armv7hf --platform=linux/arm
rules:
- if: $CI_COMMIT_TAG != null
- if: $CI_PIPELINE_SOURCE == "web"