You've already forked prometheus-fail2ban-exporter
							
							update build pipeline
This commit is contained in:
		@@ -27,6 +27,10 @@ test:
 | 
				
			|||||||
build:
 | 
					build:
 | 
				
			||||||
  extends: .go_template
 | 
					  extends: .go_template
 | 
				
			||||||
  stage: build
 | 
					  stage: build
 | 
				
			||||||
 | 
					  rules:
 | 
				
			||||||
 | 
					    - if: $CI_COMMIT_TAG =~ /^v.*$/
 | 
				
			||||||
 | 
					      when: never
 | 
				
			||||||
 | 
					    - when: on_success
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - make build
 | 
					    - make build
 | 
				
			||||||
  artifacts:
 | 
					  artifacts:
 | 
				
			||||||
@@ -46,13 +50,25 @@ release:
 | 
				
			|||||||
    GIT_DEPTH: 0
 | 
					    GIT_DEPTH: 0
 | 
				
			||||||
  rules:
 | 
					  rules:
 | 
				
			||||||
    - if: $CI_COMMIT_TAG =~ /^v.*$/
 | 
					    - if: $CI_COMMIT_TAG =~ /^v.*$/
 | 
				
			||||||
  script: |
 | 
					  script:
 | 
				
			||||||
    # GITLAB_TOKEN is needed to create GitLab releases.
 | 
					    - docker run --rm --privileged \
 | 
				
			||||||
    # DOCKER_* are needed to push Docker images.
 | 
					 | 
				
			||||||
    docker run --rm --privileged \
 | 
					 | 
				
			||||||
      -v $PWD:/go/src/gitlab.com/hectorjsmith/fail2ban-prometheus-exporter \
 | 
					      -v $PWD:/go/src/gitlab.com/hectorjsmith/fail2ban-prometheus-exporter \
 | 
				
			||||||
      -w /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 \
 | 
					      -v /var/run/docker.sock:/var/run/docker.sock \
 | 
				
			||||||
      -e DOCKER_USERNAME -e DOCKER_PASSWORD -e DOCKER_REGISTRY  \
 | 
					      -e DOCKER_USERNAME -e DOCKER_PASSWORD -e DOCKER_REGISTRY  \
 | 
				
			||||||
      -e GITLAB_TOKEN \
 | 
					      -e GITLAB_TOKEN \
 | 
				
			||||||
      goreleaser/goreleaser release --clean
 | 
					      goreleaser/goreleaser release --clean
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								.gitlab-ci/tagLatestImage.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.gitlab-ci/tagLatestImage.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					VERSION=`echo $CI_COMMIT_TAG | cut -c 2-`
 | 
				
			||||||
 | 
					MAJOR=`echo $VERSION | cut -d "." -f 1`
 | 
				
			||||||
 | 
					MINOR=`echo $VERSION | cut -d "." -f 2`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "version: $VERSION (major: $MAJOR; minor: $MINOR)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
 | 
				
			||||||
 | 
					docker pull $IMAGE_NAME:$VERSION
 | 
				
			||||||
 | 
					docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest
 | 
				
			||||||
 | 
					docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:$MAJOR
 | 
				
			||||||
 | 
					docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:$MAJOR.$MINOR
 | 
				
			||||||
 | 
					docker push $IMAGE_NAME
 | 
				
			||||||
		Reference in New Issue
	
	Block a user