-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
161 lines (127 loc) · 3.63 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
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
153
154
155
156
157
158
159
160
161
# Tags
short-latest-tag := `git describe --tags --abbrev=0`
long-latest-tag := `git describe --tags`
# Flags
version-flag := '-ldflags "-X github.com/Tom5521/fsize/meta.Version=' + short-latest-tag + '"'
go-install-version-flag := '-ldflags "-X github.com/Tom5521/fsize/meta.Version=' + short-latest-tag + '"'
# Paths
fish-completion-path := "/usr/local/share/fish/vendor_completions.d/"
bash-completion-path := "/usr/local/share/bash-completion/completions/"
zsh-completion-path := "/usr/local/share/zsh/site-functions/"
linux-install-path := "/usr/local/bin/fsize"
# Parameters
skip-compress := env_var_or_default("SKIP_COMPRESS", "0")
default:
go build -v .
release:
#!/usr/bin/env -S bash -x
# Cleaning ./builds/
just clean
# Linux
just build linux amd64
just build linux arm64
just build linux 386
# Windows
just build windows amd64
just build windows arm64
just build windows 386
# Darwin
just build darwin amd64
just build darwin arm64
build os arch:
#!/usr/bin/env -S bash -x
bin=builds/fsize-{{os}}-{{arch}}
if [[ "{{ os }}" == "windows" ]]; then
bin="$bin.exe"
fi
GOOS={{os}} GOARCH={{arch}} \
go build -v \
{{version-flag}} \
-o $bin
if [[ {{skip-compress}} == 1 ]]; then
exit 0
fi
if [[ {{os}} == "windows" && {{arch}} == "arm64" || {{os}} == "darwin" ]]; then
echo ---------------------------------------------
echo compression not supported for {{os}}-{{arch}}
echo skipping compression process...
echo ---------------------------------------------
exit 0
fi
just compress $bin
build-local:
@ go build -v \
{{version-flag}} .
clean:
@rm -rf builds completions ./fsize
go-install:
go install -v {{go-install-version-flag}} github.com/Tom5521/fsize@{{short-latest-tag}}
go-uninstall:
rm ~/go/bin/fsize
go-reinstall:
@just go-uninstall
@just go-install
[private]
compress bin:
#!/usr/bin/env -S bash -x
if [[ {{skip-compress}} == 1 ]]; then
echo skipping compression of {{bin}}...
exit 0
fi
which upx > /dev/null 2>&1
if [[ $? != 0 ]]; then
echo ---------------------------------
echo upx binary not found in PATH
echo skipping compression process...
echo ---------------------------------
exit 0
fi
upx --8mib-ram --color -9 {{bin}}
[confirm]
[unix]
install:
just build-local
cp fsize {{linux-install-path}}
fsize --gen-bash-completion {{bash-completion-path}}fsize
-which fish && \
fsize --gen-fish-completion {{fish-completion-path}}fsize.fish
-which zsh && \
fsize --gen-zsh-completion {{zsh-completion-path}}_fsize
[confirm]
[windows]
install:
just build-local
cp fsize.exe C:/Windows/System32/
[confirm]
[unix]
uninstall:
-rm {{linux-install-path}} \
{{bash-completion-path}}fsize \
{{fish-completion-path}}fsize.fish
-rm {{zsh-completion-path}}_fsize
[confirm]
[windows]
uninstall:
rm -rf C:/Windows/System32/fsize.exe
[confirm]
reinstall:
just --yes uninstall
just --yes install
generate-completions:
mkdir -p completions
just build-local
./fsize --gen-bash-completion ./completions/fsize.sh
./fsize --gen-fish-completion ./completions/fsize.fish
./fsize --gen-zsh-completion ./completions/_fsize
commit:
git add .
meteor
git push
gh-release:
just release
gh release create {{short-latest-tag}} ./builds/* --generate-notes
test:
go test -v ./*/*_test.go
update-asciinema:
just build-local
asciinema rec --title "fsize {{short-latest-tag}}" --command "./fsize /usr/share/"