From b97f06a2c67f91721f5bd0dd174f0c03c8090bfe Mon Sep 17 00:00:00 2001 From: Marvin Preuss Date: Thu, 19 Sep 2024 12:01:49 +0200 Subject: [PATCH] ci: just the beginning --- .github/workflows/ci.yml | 12 +++++++++++ .gitignore | 2 ++ .goreleaser.yaml | 44 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 3 +++ Taskfile.yml | 14 +++++++++++++ flake.nix | 1 + 6 files changed, 76 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .goreleaser.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e69be59 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,12 @@ +name: "ci" +on: + pull_request: + push: +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + - run: nix develop . -c golangci-lint run --enable-all + - run: nix develop . -c go test -v -race ./... diff --git a/.gitignore b/.gitignore index 2bbdbfe..c649679 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .direnv result + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..f7ace3a --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,44 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj +version: 2 +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + - arm64 + ldflags: + - "-s" + - "-w" + - "-extldflags '-static'" +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ {{- title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else if eq .Arch "386" }}i386 {{- else }}{{ .Arch }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +dockers: + - image_templates: + - xsteadfastx/caddy-log-exporter:{{ .Tag }}-amd64 + use: buildx + build_flag_templates: + - "--pull" + - "--platform=linux/amd64" + - image_templates: + - xsteadfastx/caddy-log-exporter:{{ .Tag }}-arm64 + use: buildx + build_flag_templates: + - "--pull" + - "--platform=linux/arm64" + goarch: arm64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ef2bcb3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +ENTRYPOINT ["/caddy-log-exporter"] +COPY caddy-log-exporter / diff --git a/Taskfile.yml b/Taskfile.yml index 4869935..b6719b1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -6,6 +6,7 @@ tasks: cmds: - task: lint - task: test + - task: release-snapshot lint: cmds: @@ -14,3 +15,16 @@ tasks: test: cmds: - "{{.NIX_CMD_BASE}} go test -v -race ./..." + + tidy: + cmds: + - go mod tidy + - go mod vendor + + release: + cmds: + - "{{.NIX_CMD_BASE}} goreleaser release --clean" + + release-snapshot: + cmds: + - "{{.NIX_CMD_BASE}} goreleaser release --clean --snapshot" diff --git a/flake.nix b/flake.nix index be7c5fa..cc7df44 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,7 @@ golines gopls goreleaser + ko ]; in with pkgs; {