mautrix-whatsapp/.gitlab-ci.yml

111 lines
3.4 KiB
YAML
Raw Normal View History

2019-07-27 16:03:05 +02:00
stages:
- build
- build docker
2020-02-25 21:59:39 +01:00
- manifest
2019-07-27 16:03:05 +02:00
2020-05-08 22:53:30 +02:00
.build: &build
2019-07-27 16:03:05 +02:00
image: golang:1-alpine
stage: build
cache:
paths:
- .cache
2019-07-27 16:03:05 +02:00
before_script:
2020-05-08 22:53:30 +02:00
- echo "@edge_community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
2020-05-09 01:11:16 +02:00
- apk add build-base olm-dev@edge_community
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
2020-06-03 19:49:26 +02:00
- export GO_LDFLAGS="-X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'"
2019-07-27 16:03:05 +02:00
script:
- go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp
2019-07-27 16:03:05 +02:00
artifacts:
paths:
2020-02-25 22:13:19 +01:00
- mautrix-whatsapp
2020-02-25 21:59:39 +01:00
- example-config.yaml
2020-05-08 22:53:30 +02:00
.build-docker: &build-docker
2019-07-27 16:03:05 +02:00
image: docker:stable
stage: build docker
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
2020-08-14 23:50:26 +02:00
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --build-arg TARGETARCH=$DOCKER_ARCH --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH . --file Dockerfile.ci
2020-05-08 22:53:30 +02:00
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
build static:
2020-05-09 01:11:16 +02:00
image: golang:1-alpine
stage: build
tags:
- amd64
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
2020-06-03 19:49:26 +02:00
- export GO_LDFLAGS="-X main.Tag=$CI_COMMIT_TAG -X main.Commit=$CI_COMMIT_SHA -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'"
variables:
CGO_ENABLED: 0
2020-05-09 01:11:16 +02:00
script:
- GOOS=linux GOARCH=amd64 go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_amd64
- GOOS=linux GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_arm64
- GOOS=linux GOARCH=arm go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_arm
- GOOS=linux GOARCH=386 go build -ldflags "$GO_LDFLAGS" -o mautrix-whatsapp_linux_386
2020-05-09 01:11:16 +02:00
artifacts:
paths:
- mautrix-whatsapp_linux_amd64
- mautrix-whatsapp_linux_arm64
- mautrix-whatsapp_linux_arm
- mautrix-whatsapp_linux_386
2020-05-09 01:11:16 +02:00
- example-config.yaml
2020-05-08 22:53:30 +02:00
build amd64:
<<: *build
tags:
- amd64
build arm64:
<<: *build
tags:
- arm64
build docker amd64:
<<: *build-docker
tags:
- amd64
dependencies:
- build amd64
needs:
- build amd64
2020-05-08 22:53:30 +02:00
variables:
DOCKER_ARCH: amd64
2019-07-27 16:03:05 +02:00
2020-02-25 21:59:39 +01:00
build docker arm64:
2020-05-08 22:53:30 +02:00
<<: *build-docker
2020-02-25 21:59:39 +01:00
tags:
- arm64
2020-05-08 22:53:30 +02:00
dependencies:
- build arm64
needs:
- build arm64
2020-05-08 22:53:30 +02:00
variables:
DOCKER_ARCH: arm64
2019-07-27 16:03:05 +02:00
2020-02-25 21:59:39 +01:00
manifest:
stage: manifest
variables:
GIT_STRATEGY: none
2019-07-27 16:03:05 +02:00
before_script:
2020-02-25 21:59:39 +01:00
- "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
2019-07-27 16:03:05 +02:00
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
needs:
- build docker amd64
- build docker arm64
2019-07-27 16:03:05 +02:00
script:
2020-02-25 21:59:39 +01:00
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
2020-06-03 20:11:48 +02:00
- 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
2020-02-25 21:59:39 +01:00
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64