Skip to content

Commit

Permalink
Switch to goreleaser for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthb committed Sep 10, 2024
1 parent 26c6278 commit 93c837d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.pem
ssllog.txt
coverage.txt
dist
57 changes: 57 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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:"
16 changes: 2 additions & 14 deletions cmd/bf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,23 @@ 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))

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{
Expand Down
2 changes: 0 additions & 2 deletions doc.go
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions version.go

This file was deleted.

0 comments on commit 93c837d

Please sign in to comment.