-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
77 lines (60 loc) · 2.19 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# jig justfile
BINNAME := "jig"
BINDIR := "bin/release"
VERSION := `git describe --always --tags`
GIT_COMMIT := `git rev-parse HEAD`
GIT_SHA := `git rev-parse --short HEAD`
GIT_TAG := `git describe --tags --abbrev=0 --exact-match 2>/dev/null || true`
GIT_DIRTY := `test -n "$(git status --porcelain)" && echo "dirty" || echo "clean"`
BINARY_VERSION := if VERSION == '' { GIT_TAG } else { VERSION }
VERSION_METADATA := if GIT_TAG == '' { 'unreleased' } else { '' }
GOMODULE := `go list -m`
LDFLAGS := (
"-s -w"
+ " -X " + GOMODULE + "/internal/version.version=" + BINARY_VERSION
+ " -X " + GOMODULE + "/internal/version.metadata=" + VERSION_METADATA
+ " -X " + GOMODULE + "/internal/version.gitCommit=" + GIT_COMMIT
+ " -X " + GOMODULE + "/internal/version.gitTreeState=" + GIT_DIRTY
+ " -X " + GOMODULE + "/internal/version.date=" + `date -u +%Y-%m-%dT%H:%M:%SZ`
)
GOLANGCI_VERSION := "latest"
GOIMPORTS_VERSION := "latest"
[private]
default:
@just --list
# build binary
build $GOOS='' $GOARCH='':
go build \
-ldflags='{{ LDFLAGS }}' \
-o {{ BINDIR / BINNAME }}{{ if GOOS != '' {'-'+GOOS} else {''} }}{{ if GOARCH != '' {'-'+GOARCH} else {''} }} \
./cmd/jig
# run tests
test:
go test ./...
# run golangci-lint checks
lint *flags: _golangci
golangci-lint run {{ flags }}
# format with goimports
format: _goimports
GO111MODULE=on go list -f '{{{{.Dir}}' ./... | xargs goimports -w -local '{{ GOMODULE }}'
# bump with cocogitto
bump version:
cog bump --version {{ version }}
# build all binaries
release: _release-linux _release-darwin
_release-linux: (build "linux" "amd64") (build "linux" "arm64")
_release-darwin: (build "darwin" "amd64") (build "darwin" "arm64")
# video tape a demo
vhs:
vhs demo.tape
# TOOLS
# ---
_golangci: (_fetch "golangci-lint" GOLANGCI_VERSION "github.com/golangci/golangci-lint/cmd/golangci-lint")
_goimports: (_fetch "goimports" GOIMPORTS_VERSION "golang.org/x/tools/cmd/goimports")
_fetch bin version url:
#!/usr/bin/env bash
if hash {{ bin }} 2>/dev/null; then
test '{{ version }}' = 'latest' && exit
test {{ bin }} --version | grep -qF '{{ version }} ' && exit
fi
cd / && GO111MODULE=on go install '{{ url }}@{{ version }}'