build: add justfile

Amolith created

Change summary

justfile         | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
justfile.license |  3 ++
2 files changed, 60 insertions(+)

Detailed changes

justfile 🔗

@@ -0,0 +1,57 @@
+# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+#
+# 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

justfile.license 🔗

@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+
+SPDX-License-Identifier: CC0-1.0