mautrix-whatsapp/.gitlab-ci.yml

64 lines
2.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-02-25 22:04:55 +01:00
build:
2019-07-27 16:03:05 +02:00
image: golang:1-alpine
stage: build
2020-02-25 21:59:39 +01:00
tags:
- amd64
cache:
paths:
- .cache
2019-07-27 16:03:05 +02:00
before_script:
- apk add git build-base
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
2019-07-27 16:03:05 +02:00
script:
2020-02-25 22:04:55 +01:00
- GOARCH=amd64 go build -o mautrix-whatsapp-amd64
- GOARCH=arm64 go build -o mautrix-whatsapp-arm64
2019-07-27 16:03:05 +02:00
artifacts:
paths:
2020-02-25 21:59:39 +01:00
- mautrix-whatsapp-amd64
- mautrix-whatsapp-arm64
- example-config.yaml
build docker amd64:
2019-07-27 16:03:05 +02:00
image: docker:stable
stage: build docker
2020-02-25 21:59:39 +01:00
tags:
- amd64
2019-07-27 16:03:05 +02:00
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
2020-02-25 21:59:39 +01:00
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . --file Dockerfile.ci --build-args EXECUTABLE=./mautrix-whatsapp-amd64
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
2019-07-27 16:03:05 +02:00
2020-02-25 21:59:39 +01:00
build docker arm64:
2019-07-27 16:03:05 +02:00
image: docker:stable
2020-02-25 21:59:39 +01:00
stage: build docker
tags:
- arm64
2019-07-27 16:03:05 +02:00
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
2020-02-25 21:59:39 +01:00
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . --file Dockerfile.ci --build-args EXECUTABLE=./mautrix-whatsapp-arm64
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
2019-07-27 16:03:05 +02:00
2020-02-25 21:59:39 +01:00
manifest:
stage: manifest
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
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
- 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