-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjustfile
More file actions
152 lines (124 loc) · 3.62 KB
/
justfile
File metadata and controls
152 lines (124 loc) · 3.62 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Install just: https://github.com/casey/just
# Project configuration
app := "gnparser"
org := "github.com/gnames/"
version := `git describe --tags`
ver := `git describe --tags --abbrev=0`
date := `date -u '+%Y-%m-%d_%H:%M:%S%Z'`
# Build flags
no_c := "CGO_ENABLED=0"
flags_shared := "GOARCH=amd64"
flags_linux := "GOARCH=amd64 GOOS=linux"
flags_linux_arm := "GOARCH=arm64 GOOS=linux"
flags_mac := "GOARCH=amd64 GOOS=darwin"
flags_mac_arm := "GOARCH=arm64 GOOS=darwin"
flags_win := "GOARCH=amd64 GOOS=windows"
flags_win_arm := "GOARCH=arm64 GOOS=windows"
flags_ld := '-ldflags "-s -w -X ' + org + app + \
'.Build=' + date + ' -X ' + org + app + \
'.Version=' + version + '"'
flags_rel := '-trimpath -ldflags "-s -w -X ' + org + app + \
'.Build=' + date + '"'
# Directories
release_dir := '/tmp'
build_dir := '.'
# Default recipe
default: install
# Run tests
test: deps install
go test -shuffle=on -race -count=1 ./...
# Test build
test-build: deps build
# Download dependencies
deps:
go mod download
# Install tools from tools.go
tools: deps
@echo Installing tools from tools.go
@cat {{app}}/tools.go | grep _ | awk -F'"' '{print $2}' | xargs -tI % go install %
# Generate PEG parsers
peg:
cd ent/parser && \
peg grammar.peg && \
goimports -w grammar.peg.go
cd ent/internal/preparser && \
peg grammar.peg && \
goimports -w grammar.peg.go
cd ent/icvcn && \
peg grammar.peg && \
goimports -w grammar.peg.go
# Generate Ragel state machines
ragel:
cd ent/internal/preprocess && \
ragel -Z -G2 virus.rl && \
ragel -Z -G2 noparse.rl
# Generate assets
asset:
cd io/fs && \
{{flags_shared}} go run -tags=dev assets_gen.go
# Build the project
build: peg
cd {{app}} && \
go clean && \
{{no_c}} go build {{flags_ld}} -o {{build_dir}}
# Build release version
buildrel: peg
cd {{app}} && \
go clean && \
{{no_c}} go build {{flags_rel}} -o {{build_dir}}
# Install the project
install: peg
cd {{app}} && \
go clean && \
{{no_c}} go install {{flags_ld}}
# Create multi-platform releases
release: peg dockerhub
#!/usr/bin/env bash
set -euo pipefail
cd {{app}}
# Linux x86
go clean
{{flags_linux}} {{no_c}} go build {{flags_ld}}
tar zcf {{release_dir}}/{{app}}-{{ver}}-linux-x86.tar.gz {{app}}
# Linux ARM
go clean
{{flags_linux_arm}} {{no_c}} go build {{flags_ld}}
tar zcf {{release_dir}}/{{app}}-{{ver}}-linux-arm.tar.gz {{app}}
# Mac x86
go clean
{{flags_mac}} {{no_c}} go build {{flags_ld}}
tar zcf {{release_dir}}/{{app}}-{{ver}}-mac-x86.tar.gz {{app}}
# Mac ARM
go clean
{{flags_mac_arm}} {{no_c}} go build {{flags_ld}}
tar zcf {{release_dir}}/{{app}}-{{ver}}-mac-arm.tar.gz {{app}}
# Windows x86
go clean
{{flags_win}} {{no_c}} go build {{flags_ld}}
zip -9 {{release_dir}}/{{app}}-{{ver}}-win-x86.zip {{app}}.exe
# Windows ARM
go clean
{{flags_win_arm}} {{no_c}} go build {{flags_ld}}
zip -9 {{release_dir}}/{{app}}-{{ver}}-win-arm.zip {{app}}.exe
go clean
# Build with docker-compose
dc: asset build
docker-compose build
# Build Docker image
docker: build
docker build -t gnames/go{{app}}:latest -t gnames/go{{app}}:{{version}} .
cd {{app}} && go clean
# Push to Docker Hub
dockerhub: docker
docker push gnames/go{{app}}
docker push gnames/go{{app}}:{{version}}
# Generate quality report
quality:
cd tools && \
go run quality.go > ../quality.md
# Generate man page
man: ronn
@ronn ./man/{{app}}.1.ronn --style=dark
# Ensure ronn is installed
ronn:
@which ronn > /dev/null || gem install ronn