2021-02-05 23:49:47 +01:00
|
|
|
stages:
|
|
|
|
- test
|
2021-02-07 11:51:43 +01:00
|
|
|
- build
|
2023-06-19 22:37:30 +02:00
|
|
|
- release
|
2021-02-05 23:49:47 +01:00
|
|
|
|
2022-02-12 18:31:01 +01:00
|
|
|
.go_template:
|
|
|
|
image: golang:latest
|
|
|
|
|
2021-10-17 19:39:02 +02:00
|
|
|
dependencies:
|
2022-02-12 18:31:01 +01:00
|
|
|
extends: .go_template
|
2021-10-17 19:39:02 +02:00
|
|
|
stage: test
|
|
|
|
script:
|
2023-06-19 20:37:27 +02:00
|
|
|
- make check/dependencies
|
2021-10-17 19:39:02 +02:00
|
|
|
|
2021-02-05 23:49:47 +01:00
|
|
|
format:
|
2022-02-12 18:31:01 +01:00
|
|
|
extends: .go_template
|
2021-02-05 23:49:47 +01:00
|
|
|
stage: test
|
|
|
|
script:
|
2023-06-19 20:37:27 +02:00
|
|
|
- make check/fmt
|
2021-02-05 23:49:47 +01:00
|
|
|
|
|
|
|
test:
|
2022-02-12 18:31:01 +01:00
|
|
|
extends: .go_template
|
2021-02-05 23:49:47 +01:00
|
|
|
stage: test
|
|
|
|
script:
|
2023-06-19 20:37:27 +02:00
|
|
|
- make test
|
|
|
|
|
|
|
|
build:
|
|
|
|
extends: .go_template
|
|
|
|
stage: build
|
|
|
|
script:
|
|
|
|
- make build
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- fail2ban_exporter
|
|
|
|
expire_in: 1 day
|
2021-02-07 11:51:43 +01:00
|
|
|
|
2023-06-19 22:37:30 +02:00
|
|
|
release:
|
|
|
|
stage: release
|
|
|
|
image: docker:stable
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
variables:
|
|
|
|
DOCKER_REGISTRY: $CI_REGISTRY
|
|
|
|
DOCKER_USERNAME: $CI_REGISTRY_USER
|
|
|
|
DOCKER_PASSWORD: $CI_REGISTRY_PASSWORD
|
|
|
|
GIT_DEPTH: 0
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG =~ /^v.*$/
|
2023-06-20 09:20:11 +02:00
|
|
|
script:
|
|
|
|
- docker run --rm --privileged \
|
2023-06-19 22:37:30 +02:00
|
|
|
-v $PWD:/go/src/gitlab.com/hectorjsmith/fail2ban-prometheus-exporter \
|
|
|
|
-w /go/src/gitlab.com/hectorjsmith/fail2ban-prometheus-exporter \
|
|
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
|
|
-e DOCKER_USERNAME -e DOCKER_PASSWORD -e DOCKER_REGISTRY \
|
|
|
|
-e GITLAB_TOKEN \
|
|
|
|
goreleaser/goreleaser release --clean
|
2023-06-20 09:20:11 +02:00
|
|
|
|
|
|
|
tag images:
|
|
|
|
stage: release
|
|
|
|
image: docker:stable
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
needs:
|
|
|
|
- release
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
|
|
|
|
variables:
|
|
|
|
IMAGE_NAME: registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter
|
|
|
|
script:
|
|
|
|
- ./.gitlab-ci/tagLatestImage.sh
|