1# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2#
3# SPDX-License-Identifier: CC0-1.0
4
5GOOS := env("GOOS", `go env GOOS`)
6GOARCH := env("GOARCH", `go env GOARCH`)
7VERSION := `git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g'`
8
9default: fmt lint staticcheck test vuln reuse
10
11fmt:
12 # Formatting all Go source code
13 go install mvdan.cc/gofumpt@latest
14 gofumpt -l -w .
15
16lint:
17 # Linting Go source code
18 golangci-lint run
19
20staticcheck:
21 # Performing static analysis
22 go install honnef.co/go/tools/cmd/staticcheck@latest
23 staticcheck ./...
24
25test:
26 # Running tests
27 go test -v ./...
28
29vuln:
30 # Checking for vulnerabilities
31 go install golang.org/x/vuln/cmd/govulncheck@latest
32 govulncheck ./...
33
34reuse:
35 # Linting licenses and copyright headers
36 reuse lint
37
38build:
39 # Building formatted-commit
40 CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go build -o formatted-commit -ldflags "-s -w -X main.version={{VERSION}}"
41
42run *FLAGS:
43 # Running formatted-commit
44 CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go run -ldflags "-s -w -X main.version={{VERSION}}" . {{FLAGS}}
45
46pack:
47 # Packing formatted-commit
48 upx --best -qo formatted-commit.min formatted-commit
49 mv formatted-commit.min formatted-commit
50
51clean:
52 # Removing build artifacts
53 rm -rf formatted-commit
54
55clean-all:
56 # Removing build artifacts and config.toml
57 rm -rf formatted-commit config.toml