diff --git a/.gitignore b/.gitignore index ec87029..e551d96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .go .idea /trafficmirror -vendor +dist trafficmirror +vendor diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6b3f36..3897536 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..1853295 --- /dev/null +++ b/.goreleaser.yml @@ -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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f16ff44..08d2b1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +repos: - repo: git://github.com/dnephin/pre-commit-golang rev: master hooks: @@ -12,4 +13,8 @@ entry: custom-hooks/go-mod-tidy.sh files: '(\.go)|(\.mod)|(\.sum)$' language: 'script' - description: "Runs `gofmt`, requires golang" \ No newline at end of file + description: "Runs `gofmt`, requires golang" +- repo: git@github.com:kadrach/pre-commit-gitlabci-lint.git + rev: ab984c60414b012e294a65166691473047ccce49 + hooks: + - id: gitlabci-lint