Newer
Older

Roman Brendler
committed
.release-rules: &release-rules
# rule to run job on a tag-reference which has the form number.number.number (semantic versioning)
# or number.number.number-text (semantic versioning + release-name)
# and where a Dockerfile exists
- if: $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+$/ || $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+[-]\S+$/
exists:
- Dockerfile
- test
- build

Roman Brendler
committed
- release
prepare:
stage: prepare
cache:
policy: pull-push
- mkdir -p .gopath
- export GOPATH="$CI_PROJECT_DIR/.gopath"
- go generate ./ui
stage: test
script:
- go test -v -cover $(go list ./... | grep -v tank/store)
test-store-postgres:
stage: test
services:
variables:
POSTGRES_DB: "tank"
POSTGRES_USER: "tank"
POSTGRES_PASSWORD: "aura"
AURA_TANK_TEST_DB_TYPE: "postgres"
AURA_TANK_TEST_DB_HOST: "postgres"
script:
- go run contrib/waitfor-tcp.go postgres:5432 30
- go test -v -cover ./store
stage: build
script:
- go build -ldflags "-extldflags '-static'" -tags netgo -o $CI_PROJECT_DIR/tank ./cmd/tank
## sqlite needs cgo... :(
##- go build -o $CI_PROJECT_DIR/tank ./cmd/tank
artifacts:
paths:
- tank
docker:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
cache:
paths:
- .docker/cache
key: default
policy: pull-push
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME

Roman Brendler
committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
docker-hub-push:
# Use the official docker image.
image: docker:latest
stage: release
variables:
# the name of the image without version
AURA_IMAGE_NAME: "autoradio/tank"
services:
- docker:dind
before_script:
# default repo is docker.io (aka docker hub)
- docker login -u "$DOCKER_ID" -p "$DOCKER_HUB_AUTH"
script:
# every commit on main branch should build image as unstable
# else it is from a tag (enforced by gitlab-ci rules)
# hint: tags are references independent of branches
- |
if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]
then docker build -t $AURA_IMAGE_NAME:unstable .
else docker build -t $AURA_IMAGE_NAME -t $AURA_IMAGE_NAME:$CI_COMMIT_TAG .
fi
# TODO: maybe isolate docker build and docker push
- docker push "$AURA_IMAGE_NAME" --all-tags
rules:
- *release-rules
# every commit on master/main branch should trigger a push to docker-hub as unstable without a release
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists:
- Dockerfile
release_job:
stage: release
needs:

Roman Brendler
committed
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules: *release-rules
script:
- echo "this will be a release when there is a tag, but tags should be protected to be only createable by maintainers."
release:
name: 'Release $CI_COMMIT_TAG'
description: ./CHANGELOG
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'