Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ project_name: capture
builds:
- id: capture
main: ./cmd/capture
ldflags:
ldflags: &common_ldflags
- -s -w
- -extldflags "-static"
- -X "main.Version={{.Version}}"
- -X "main.Commit={{.Commit}}"
- -X "main.CommitDate={{.CommitDate}}"
- -X "main.CompiledAt={{.Date}}"
- -X "main.GitTag={{.Tag}}"
env:
- CGO_ENABLED=0
goos:
Expand Down Expand Up @@ -39,10 +43,7 @@ kos:
main: ./cmd/capture
flags:
- -trimpath
ldflags:
- -s -w
- -extldflags "-static"
- -X "main.Version={{.Version}}"
ldflags: *common_ldflags
creation_time: "{{.CommitTimestamp}}"
sbom: spdx
env:
Expand Down
31 changes: 28 additions & 3 deletions cmd/capture/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,42 @@ import (
"github.com/bluewave-labs/capture/internal/server/handler"
)

// Application configuration variable that holds the settings.
//
// - Port: Server port, default is 59232
//
// - APISecret: Secret key for API access, default is a blank string.
var appConfig *config.Config

var Version = "develop" // This will be set during compile time using go build ldflags
// Build information variables populated at build time.
// These variables are typically set using ldflags during the build process
// to provide runtime access to build metadata.
var (
// Version represents the Capture version (default: "develop").
Version = "develop"
// Commit contains the Git commit hash of the build.
Commit = "unknown"
// CommitDate holds the date of the commit.
CommitDate = "unknown"
// CompiledAt stores the build compilation date.
CompiledAt = "unknown"
// GitTag contains the Git tag associated with the build, if any.
GitTag = "unknown"
)

func main() {
showVersion := flag.Bool("version", false, "Display the version of the capture")
flag.Parse()

// Check if the version flag is provided
// Check if the version flag is provided and show build information
if *showVersion {
fmt.Printf("Capture version: %s\n", Version)
fmt.Println("Capture Build Information")
fmt.Println("-------------------------")
fmt.Printf("Version : %s\n", Version)
fmt.Printf("Commit Hash : %s\n", Commit)
fmt.Printf("Commit Date : %s\n", CommitDate)
fmt.Printf("Compiled At : %s\n", CompiledAt)
fmt.Printf("Git Tag : %s\n", GitTag)
os.Exit(0)
}

Expand Down
Loading