From 134340cbe43fae349a7d3937b9bddf5fa1cfe38c Mon Sep 17 00:00:00 2001 From: Amolith Date: Tue, 21 Oct 2025 17:29:49 -0600 Subject: [PATCH] build: add justfile --- justfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ justfile.license | 3 +++ 2 files changed, 60 insertions(+) create mode 100644 justfile create mode 100644 justfile.license diff --git a/justfile b/justfile new file mode 100644 index 0000000000000000000000000000000000000000..a5d0c9b97733c1f155a88abcd45f1aa2db369a81 --- /dev/null +++ b/justfile @@ -0,0 +1,57 @@ +# SPDX-FileCopyrightText: Amolith +# +# SPDX-License-Identifier: CC0-1.0 + +GOOS := env("GOOS", `go env GOOS`) +GOARCH := env("GOARCH", `go env GOARCH`) +VERSION := `git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g'` + +default: fmt lint staticcheck test vuln reuse + +fmt: + # Formatting all Go source code + go install mvdan.cc/gofumpt@latest + gofumpt -l -w . + +lint: + # Linting Go source code + golangci-lint run + +staticcheck: + # Performing static analysis + go install honnef.co/go/tools/cmd/staticcheck@latest + staticcheck ./... + +test: + # Running tests + go test -v ./... + +vuln: + # Checking for vulnerabilities + go install golang.org/x/vuln/cmd/govulncheck@latest + govulncheck ./... + +reuse: + # Linting licenses and copyright headers + reuse lint + +build: + # Building formatted-commit + CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go build -o formatted-commit -ldflags "-s -w -X main.version={{VERSION}}" ./main.go + +run *FLAGS: + # Running formatted-commit + CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go run -ldflags "-s -w -X main.version={{VERSION}}" ./main.go {{FLAGS}} + +pack: + # Packing formatted-commit + upx --best -qo formatted-commit.min formatted-commit + mv formatted-commit.min formatted-commit + +clean: + # Removing build artifacts + rm -rf formatted-commit + +clean-all: + # Removing build artifacts and config.toml + rm -rf formatted-commit config.toml diff --git a/justfile.license b/justfile.license new file mode 100644 index 0000000000000000000000000000000000000000..3dbb1e29808ff6ce1e89aa3211dbfa6c8aa5ef0e --- /dev/null +++ b/justfile.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Amolith + +SPDX-License-Identifier: CC0-1.0