feat: use goreleaser
Some checks failed
Golang Tests / unittest (stable, ubuntu-latest-amd64) (push) Failing after 15s
Golang Tests / unittest (stable, ubuntu-latest-arm64) (push) Failing after 15s
Markdown linter / markdown-lint (push) Failing after 13s
Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Failing after 28s
Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Failing after 2m39s
Some checks failed
Golang Tests / unittest (stable, ubuntu-latest-amd64) (push) Failing after 15s
Golang Tests / unittest (stable, ubuntu-latest-arm64) (push) Failing after 15s
Markdown linter / markdown-lint (push) Failing after 13s
Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Failing after 28s
Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Failing after 2m39s
This commit is contained in:
parent
76f5437ab3
commit
9eed0fe492
20
.gitea/workflows/markdown-linters.yaml
Normal file
20
.gitea/workflows/markdown-linters.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: Markdown linter
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [ "opened", "reopened", "synchronize" ]
|
||||||
|
push:
|
||||||
|
branches: [ '**' ]
|
||||||
|
tags-ignore: [ '**' ]
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
markdown-lint:
|
||||||
|
container:
|
||||||
|
image: git.cryptic.systems/volker.raschek/markdownlint:0.45.0
|
||||||
|
runs-on:
|
||||||
|
- ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
- name: Lint Markdown files
|
||||||
|
run: markdownlint --config .markdownlint.yaml .
|
52
.gitea/workflows/release.yaml
Normal file
52
.gitea/workflows/release.yaml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: [ '**' ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on:
|
||||||
|
- ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
- uses: docker/setup-qemu-action@v3.6.0
|
||||||
|
- uses: actions/setup-go@v5.5.0
|
||||||
|
with:
|
||||||
|
go-version: stable
|
||||||
|
- uses: docker/login-action@v3.4.0
|
||||||
|
with:
|
||||||
|
registry: git.cryptic.systems
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
|
||||||
|
- env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
|
||||||
|
GONOSUMDB: ${{ vars.GONOSUMDB }}
|
||||||
|
GOPROXY: ${{ vars.GOPROXY }}
|
||||||
|
uses: goreleaser/goreleaser-action@v6.3.0
|
||||||
|
with:
|
||||||
|
version: "~> v2"
|
||||||
|
args: release --clean
|
||||||
|
|
||||||
|
sync-to-hub-docker-io:
|
||||||
|
needs:
|
||||||
|
- release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Copy images to docker.io
|
||||||
|
run: |
|
||||||
|
TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm')
|
||||||
|
|
||||||
|
apt-get update --yes
|
||||||
|
apt-get install --yes skopeo
|
||||||
|
skopeo copy \
|
||||||
|
--all \
|
||||||
|
--dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \
|
||||||
|
--dest-username ${{ secrets.DOCKER_IO_USERNAME }} \
|
||||||
|
--src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \
|
||||||
|
--src-username volker.raschek \
|
||||||
|
docker://git.cryptic.systems/volker.raschek/prometheus-fail2ban-exporter:${TAG} \
|
||||||
|
docker://docker.io/volkerraschek/prometheus-fail2ban-exporter:${TAG}
|
@ -1,30 +0,0 @@
|
|||||||
name: Run unit tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
types: [ "opened", "reopened", "synchronize" ]
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
workflow_dispatch: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
container:
|
|
||||||
image: docker.io/library/golang:1.24.3
|
|
||||||
runs-on:
|
|
||||||
- ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Install tooling
|
|
||||||
run: |
|
|
||||||
apt-get update --yes
|
|
||||||
apt-get upgrade --yes
|
|
||||||
apt-get install --yes git npm
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- env:
|
|
||||||
GOPROXY: ${{ vars.GOPROXY }}
|
|
||||||
GONOSUMDB: ${{ vars.GONOSUMDB }}
|
|
||||||
name: Execute containerized unit test
|
|
||||||
run: make test
|
|
20
.gitea/workflows/update-docker-hub-description.yaml
Normal file
20
.gitea/workflows/update-docker-hub-description.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: Update Docker Hub Description
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ 'master' ]
|
||||||
|
paths: [ 'README.md' ]
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-description-on-hub-docker-io:
|
||||||
|
runs-on:
|
||||||
|
- ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
- uses: peter-evans/dockerhub-description@v4.0.2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_IO_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_IO_PASSWORD }}
|
||||||
|
repository: volkerraschek/prometheus-fail2ban-exporter
|
||||||
|
readme-filepath: README.md
|
175
.goreleaser.yaml
Normal file
175
.goreleaser.yaml
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
project_name: prometheus-fail2ban-exporter
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- formats: [ "tar.xz" ]
|
||||||
|
files:
|
||||||
|
- README.md
|
||||||
|
- LICENSE
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- main: main.go
|
||||||
|
binary: >-
|
||||||
|
{{ .ProjectName }}-
|
||||||
|
{{- .Version }}-
|
||||||
|
{{- .Os }}-
|
||||||
|
{{- if eq .Arch "amd64" }}amd64
|
||||||
|
{{- else if eq .Arch "amd64_v1" }}amd64
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}-{{ .Arm }}{{ end }}
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
- GONOSUMDB={{ .Env.GONOSUMDB }}
|
||||||
|
- GOPROXY={{ .Env.GOPROXY }}
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
- riscv64
|
||||||
|
goarm:
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X 'main.version={{ trimprefix .Tag "v" }}' -X 'main.date={{ time "2006-01-02T15:04:05Z07:00" }}'
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^chore'
|
||||||
|
- '^docs'
|
||||||
|
- '^test'
|
||||||
|
- Merge pull request
|
||||||
|
- Merge branch
|
||||||
|
- go mod tidy
|
||||||
|
format: "{{.SHA}}: {{.Message}} (@{{.AuthorUsername}})"
|
||||||
|
groups:
|
||||||
|
- title: Features
|
||||||
|
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
|
||||||
|
order: 0
|
||||||
|
- title: "Bug fixes"
|
||||||
|
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
|
||||||
|
order: 1
|
||||||
|
- title: Others
|
||||||
|
order: 999
|
||||||
|
sort: asc
|
||||||
|
use: git
|
||||||
|
|
||||||
|
dockers:
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/amd64
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: amd64
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/arm/v6
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/arm/v7
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/arm64
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: arm64
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/riscv64
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: riscv64
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-riscv64'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
docker_manifests:
|
||||||
|
- name_template: 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}'
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-riscv64'
|
||||||
|
|
||||||
|
gitea_urls:
|
||||||
|
api: https://git.cryptic.systems/api/v1
|
||||||
|
download: https://git.cryptic.systems
|
||||||
|
|
||||||
|
version: 2
|
20
Dockerfile
20
Dockerfile
@ -1,19 +1,5 @@
|
|||||||
FROM docker.io/library/golang:1.24.3 AS build
|
FROM scratch AS build
|
||||||
|
|
||||||
WORKDIR /workspace
|
COPY prometheus-fail2ban-exporter-* /usr/bin/prometheus-fail2ban-exporter
|
||||||
ADD . /workspace
|
|
||||||
|
|
||||||
RUN apt update --yes && \
|
ENTRYPOINT [ "/usr/bin/prometheus-fail2ban-exporter" ]
|
||||||
apt install --yes build-essential && \
|
|
||||||
make install \
|
|
||||||
PREFIX=/usr \
|
|
||||||
DESTDIR=/app \
|
|
||||||
EXECUTABLE=prometheus-fail2ban-exporter
|
|
||||||
|
|
||||||
FROM docker.io/library/debian:12-slim
|
|
||||||
|
|
||||||
COPY --from=build /app /
|
|
||||||
|
|
||||||
EXPOSE 9191
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/usr/bin/prometheus-fail2ban-exporter" ]
|
|
@ -16,14 +16,12 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
version = "dev"
|
version = "dev"
|
||||||
commit = "none"
|
|
||||||
date = "unknown"
|
date = "unknown"
|
||||||
builtBy = "unknown"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func printAppVersion() {
|
func printAppVersion() {
|
||||||
fmt.Println(version)
|
fmt.Printf("Version: %s\n", version)
|
||||||
fmt.Printf(" build date: %s\r\n commit hash: %s\r\n built by: %s\r\n", date, commit, builtBy)
|
fmt.Printf("Build date: %s\n", date)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
@ -1,20 +0,0 @@
|
|||||||
image: git.cryptic.systems/volker.raschek/prometheus-fail2ban-exporter:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
|
||||||
{{#if build.tags}}
|
|
||||||
tags:
|
|
||||||
{{#each build.tags}}
|
|
||||||
- {{this}}
|
|
||||||
{{/each}}
|
|
||||||
- "latest"
|
|
||||||
{{/if}}
|
|
||||||
manifests:
|
|
||||||
-
|
|
||||||
image: git.cryptic.systems/volker.raschek/prometheus-fail2ban-exporter:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
-
|
|
||||||
image: git.cryptic.systems/volker.raschek/prometheus-fail2ban-exporter:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm64-v8
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
Loading…
x
Reference in New Issue
Block a user