From cea2a9d0c61e699ca0d7e22a9f368644101d1381 Mon Sep 17 00:00:00 2001 From: Ananth Bhaskararaman Date: Tue, 10 Sep 2024 13:01:44 +0530 Subject: [PATCH] Switch to goreleaser for builds --- .gitignore | 1 + .goreleaser.yaml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ cmd/bf/main.go | 16 ++------------ doc.go | 2 -- version.go | 3 --- 5 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 .goreleaser.yaml delete mode 100644 version.go diff --git a/.gitignore b/.gitignore index 61a6912..78cc422 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.pem ssllog.txt coverage.txt +dist diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..42eea48 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,57 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - main: ./cmd/bf + env: + - CGO_ENABLED=0 + overrides: + - goos: linux + goarch: amd64 + env: + - CGO_ENABLED=1 + - CC=zig cc -target x86_64-linux-musl + - CXX=zig c++ -target x86_64-linux-musl + - goos: linux + goarch: arm64 + env: + - CGO_ENABLED=1 + - CC=zig cc -target aarch64-linux-musl + - CXX=zig c++ -target aarch64-linux-musl + +archives: + - format: tar.gz + 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 }} + format_overrides: + - goos: linux + format: tar.zst + - goos: windows + format: zip + files: + - LICENSE + - README.md + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/cmd/bf/main.go b/cmd/bf/main.go index bc3a5b0..d9f6b30 100644 --- a/cmd/bf/main.go +++ b/cmd/bf/main.go @@ -2,27 +2,15 @@ package main import ( "context" - "fmt" "log/slog" "os" - "runtime/debug" - "github.com/RealImage/bifrost" "github.com/urfave/cli/v3" ) -var revision = "unknown" +var version = "devel" func main() { - if bi, ok := debug.ReadBuildInfo(); ok { - for _, s := range bi.Settings { - if s.Key == "vcs.revision" { - revision = s.Value - break - } - } - } - logLevel := new(slog.LevelVar) hdlr := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel}) slog.SetDefault(slog.New(hdlr)) @@ -30,7 +18,7 @@ func main() { cli := &cli.Command{ Name: "bifrost", Aliases: []string{"bf"}, - Version: fmt.Sprintf("%s (%s)", bifrost.Version, revision), + Version: version, Usage: "Bifrost is an mTLS Certificate Authority and Identity Proxy", Flags: []cli.Flag{ &cli.StringFlag{ diff --git a/doc.go b/doc.go index d01ac00..8753016 100644 --- a/doc.go +++ b/doc.go @@ -1,4 +1,2 @@ // Package bifrost contains an API client for the Bifrost CA service. -// -//go:generate sh -c "printf 'package bifrost\n\nconst Version = `%s`\n' $VERSION > version.go" package bifrost diff --git a/version.go b/version.go deleted file mode 100644 index a9913fb..0000000 --- a/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package bifrost - -const Version = `devel`