-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
74 lines (69 loc) · 2.36 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
stages:
- build
- build docker
- manifest
build:
stage: build
image: golang:1-alpine
cache:
paths:
- .cache
variables:
CGO_ENABLED: "0"
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
- export GOFLAGS="-buildvcs=false"
script:
- GOARCH=amd64 go build -o mautrix-wsproxy-amd64
- GOARCH=arm64 go build -o mautrix-wsproxy-arm64
- GOARCH=arm go build -o mautrix-wsproxy-arm
artifacts:
paths:
- mautrix-wsproxy-amd64
- mautrix-wsproxy-arm64
- mautrix-wsproxy-arm
- example-config.yaml
.build-docker: &build-docker
image: docker:stable
stage: build docker
dependencies:
- build
needs:
- build
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH . --file Dockerfile.ci --build-arg EXECUTABLE=./mautrix-wsproxy-$DOCKER_ARCH
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
build docker amd64:
<<: *build-docker
tags:
- amd64
variables:
DOCKER_ARCH: amd64
build docker arm64:
<<: *build-docker
tags:
- arm64
variables:
DOCKER_ARCH: arm64
manifest:
stage: manifest
variables:
GIT_STRATEGY: none
before_script:
- "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
needs:
- build docker amd64
- build docker arm64
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
- if [ "$CI_COMMIT_BRANCH" = "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:latest; fi
- if [ "$CI_COMMIT_BRANCH" != "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME; fi
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64