-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
125 lines (95 loc) · 2.72 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
GIT_DIR := `git rev-parse --show-toplevel`
MAIN := "."
BIN_NAME := `basename {{GIT_DIR}}`
BIN_DIR := "bin"
DIST_DIR := "dist"
GITHUB_OWNER := "cluttrdev"
GITHUB_REPO := "gitlab-exporter"
# list available recipes
default:
@just --list
# format code
fmt:
go fmt ./...
# lint code
lint:
golangci-lint run ./...
# vet code
vet:
go vet ./...
# build application
build *args="":
{{GIT_DIR}}/scripts/build.sh -p {{MAIN}} {{args}}
# create binary distribution
dist *args="":
{{GIT_DIR}}/scripts/dist.sh -p {{MAIN}} {{args}}
# create a new release
release *args="":
#!/bin/sh
export GITHUB_OWNER={{GITHUB_OWNER}}
export GITHUB_REPO={{GITHUB_REPO}}
{{GIT_DIR}}/scripts/release.sh -p {{MAIN}} {{args}}
changes from="" to="":
#!/bin/sh
source {{GIT_DIR}}/scripts/functions.sh
get_changes {{from}} {{to}}
clean:
@# build artifacts
@echo "rm {{BIN_DIR}}/{{BIN_NAME}}"
@-[ -f {{BIN_DIR}}/{{BIN_NAME}} ] && rm {{BIN_DIR}}/{{BIN_NAME}}
@-[ -d {{BIN_DIR}} ] && rmdir {{BIN_DIR}}
@# distribution binaries
@echo "rm {{DIST_DIR}}/{{BIN_NAME}}_*"
@rm {{DIST_DIR}}/{{BIN_NAME}}_* 2>/dev/null || true
@-[ -d {{DIST_DIR}} ] && rmdir {{DIST_DIR}}
###############################################################################
# generate protobuf code
generate-protobuf:
#!/bin/sh
protoc \
-I protos/ \
-I protos/vendor/opentelemetry-proto \
--go_out=. --go_opt=module=github.com/cluttrdev/gitlab-exporter \
--go-grpc_out=. --go-grpc_opt=module=github.com/cluttrdev/gitlab-exporter \
protos/gitlabexporter/protobuf/*.proto protos/gitlabexporter/protobuf/service/*.proto
# generate graphql client code
generate-graphql:
#!/bin/sh
genqlient internal/gitlab/graphql/genqlient.yaml
docker-build:
#!/bin/sh
github_owner={{GITHUB_OWNER}}
github_repo={{GITHUB_REPO}}
git_dir={{GIT_DIR}}
set -eu
source ${git_dir}/scripts/functions.sh
image=${github_owner}/${github_repo}
version=$(get_version)
if is_dirty; then
version="${version}-modified"
fi
docker build \
-f Dockerfile \
--build-arg VERSION=${version} \
-t ${image}:${version} \
.
if is_tagged; then
docker tag ${image}:${version} ${image}:latest
fi
docker-push: docker-build
#!/bin/sh
github_owner={{GITHUB_OWNER}}
github_owner={{GITHUB_REPO}}
git_dir={{GIT_DIR}}
set -eu
source ${git_dir}/scripts/functions.sh
if is_dirty; then
echo "Working diretory is dirty"
exit 1
fi
image=${github_owner}/${github_repo}
version=$(get_version)
docker push ${image}:${version}
if is_tagged; then
docker push ${image}:latest
fi