Skip to content

Commit

Permalink
Merge pull request #13 from StackVista/feat-GoReleaser
Browse files Browse the repository at this point in the history
feat(goreleaser): STAC-0 | Adding goreleaser to tagged builds
  • Loading branch information
rb3ckers authored Jan 17, 2020
2 parents d04c23d + 90bbff2 commit 7405f3d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.go
.idea
/trafficmirror
vendor
dist
trafficmirror
vendor
48 changes: 34 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
variables:
CI_REGISTRY: docker.io
IMAGE_FAMILY: stackstate/trafficmirror

stages:
- build
- docker_build
- build
- tag

docker_build:
stage: docker_build
image: docker:stable
image: docker.io/library/docker:stable
except:
refs:
- master
only:
refs:
- branches
script:
- echo "${docker_password}" | docker login --username=${docker_user} --password-stdin ${CI_REGISTRY}
- docker build
--tag "${CI_REGISTRY}/${IMAGE_FAMILY}:${CI_BUILD_REF:-dirty}"
--target app
${PWD}
- docker push "${CI_REGISTRY}/${IMAGE_FAMILY}:${CI_BUILD_REF:-dirty}"
stage: build
variables:
CI_REGISTRY: docker.io
IMAGE_FAMILY: stackstate/trafficmirror-test

tag_build:
image: docker.io/goreleaser/goreleaser:v0.124.1
only:
refs:
- tags
script:
- echo "${docker_password}" | docker login --username=${docker_user} --password-stdin ${CI_REGISTRY}
- docker build
--tag "${CI_REGISTRY}/${IMAGE_FAMILY}:${CI_BUILD_REF:-dirty}"
--target app
${PWD}
- docker push "${CI_REGISTRY}/${IMAGE_FAMILY}:${CI_BUILD_REF:-dirty}"
- goreleaser check
- goreleaser release --rm-dist
stage: tag
variables:
DOCKER_PASSWORD: ${docker_password}
DOCKER_REGISTRY: docker.io
DOCKER_USERNAME: ${docker_user}
GITHUB_TOKEN: ${remco_github_api_token}
36 changes: 36 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
project_name: trafficmirror
release:
github:
owner: rb3ckers
name: trafficmirror
name_template: '{{.Tag}}'
before:
hooks:
- go mod tidy
- go mod download
builds:
- env:
- CGO_ENABLED=0
- GO111MODULE=on
checksum:
name_template: checksums.txt
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
dockers:
- extra_files:
- datatypes/
- go.mod
- go.sum
- main.go
- rootfs/
image_templates:
- docker.io/stackstate/trafficmirror:latest
- docker.io/stackstate/trafficmirror:{{ .Tag }}
- docker.io/stackstate/trafficmirror:v{{ .Major }}
- docker.io/stackstate/trafficmirror:v{{ .Major }}.{{ .Minor }}
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
repos:
- repo: git://github.com/dnephin/pre-commit-golang
rev: master
hooks:
Expand All @@ -12,4 +13,8 @@
entry: custom-hooks/go-mod-tidy.sh
files: '(\.go)|(\.mod)|(\.sum)$'
language: 'script'
description: "Runs `gofmt`, requires golang"
description: "Runs `gofmt`, requires golang"
- repo: git@github.com:kadrach/pre-commit-gitlabci-lint.git
rev: ab984c60414b012e294a65166691473047ccce49
hooks:
- id: gitlabci-lint

0 comments on commit 7405f3d

Please sign in to comment.