ci: update creation of tags (#19)

Update creation of docker tags to only tag actual releases with the
`:latest` tag. Builds on the main branch are now tagged with a `:nightly`
tag.
This commit is contained in:
Hector 2022-02-12 17:31:01 +00:00
parent 191dda3b9f
commit 05f236902a
3 changed files with 32 additions and 14 deletions

View File

@ -1,28 +1,41 @@
image: golang:latest
before_script:
- make go/dependencies
stages: stages:
- test - test
- build - build
.go_template:
image: golang:latest
before_script:
- make go/dependencies
.docker_template:
image: docker:stable
services:
- docker:dind
before_script:
- apk add git
- apk add make
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
dependencies: dependencies:
extends: .go_template
stage: test stage: test
script: script:
- make go/checkDependencies - make go/checkDependencies
format: format:
extends: .go_template
stage: test stage: test
script: script:
- make go/checkFmt - make go/checkFmt
test: test:
extends: .go_template
stage: test stage: test
script: script:
- make go/test - make go/test
build: build:
extends: .go_template
stage: build stage: build
only: only:
- main - main
@ -37,18 +50,20 @@ build:
expire_in: 1 day expire_in: 1 day
docker/gitlab: docker/gitlab:
extends: .docker_template
stage: build stage: build
only: only:
- main
- tags - tags
image: docker:stable
services:
- docker:dind
before_script:
- apk add git
- apk add make
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script: script:
- make docker/build/latest - make docker/build/latest
- make docker/build/tag - make docker/build/tag
- docker push registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter - docker push registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter
docker/gitlab/nightly:
extends: .docker_template
stage: build
only:
- main
script:
- make docker/build/nightly
- docker push registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter

View File

@ -32,5 +32,8 @@ build/docker:
docker/build/latest: docker/build/latest:
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest . docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest .
docker/build/nightly:
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:nightly .
docker/build/tag: docker/build/tag:
docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:$(shell git describe --tags) . docker build -t registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:$(shell git describe --tags) .

View File

@ -94,7 +94,7 @@ Use it by pulling the following image:
registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest registry.gitlab.com/hectorjsmith/fail2ban-prometheus-exporter:latest
``` ```
Use the `:latest` tag to get the most up to date code (less stable) or use one of the version tagged images to use a specific release. Use the `:latest` tag to get the latest stable release. Or use the `:nightly` tag for the latest (unstable) version.
See the [registry page](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/container_registry) for all available tags. See the [registry page](https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/container_registry) for all available tags.
### 3.1. Volumes ### 3.1. Volumes