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.*$/
|
|
|
|
script: |
|
|
|
|
# GITLAB_TOKEN is needed to create GitLab releases.
|
|
|
|
# DOCKER_* are needed to push Docker images.
|
|
|
|
docker run --rm --privileged \
|
|
|
|
-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
|