-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjustfile
199 lines (156 loc) · 4.38 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Tags
short-latest-tag := `git describe --tags --abbrev=0`
long-latest-tag := `git describe --tags`
# 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:
# Cleaning ./builds/
just clean
# Generate version
just generate
# Linux
just build linux 386
just build linux amd64
just build linux arm
just build linux arm64
# Windows
just build windows 386
just build windows amd64
just build windows arm
just build windows arm64
# Darwin
just build darwin amd64
just build darwin arm64
build os arch:
#!/usr/bin/env -S bash -x
bin=builds/fsize-{{os}}-{{arch}}
compiler="garble -tiny"
if [[ "{{ os }}" == "windows" ]]; then
bin="$bin.exe"
if [[ {{arch}} == "386" ]]; then
compiler="go"
fi
fi
command -v garble || just install-garble
CC=gcc GOOS={{os}} GOARCH={{arch}} \
$compiler build -v -o $bin || exit $?
if [[ {{skip-compress}} == 1 ]]; then
exit 0
fi
if [[ {{os}} == "windows" && {{arch}} == "arm64" || {{arch}} == "arm" ]]; then
echo compression not supported for {{os}}-{{arch}}
echo skipping compression process...
exit 0
fi
just compress $bin
build-local:
just generate
@ go build -v .
clean:
@rm -rf builds completions ./fsize
go-install:
go install -v github.com/Tom5521/fsize@{{short-latest-tag}}
go-uninstall:
rm ~/go/bin/fsize
go-reinstall:
@just go-uninstall
@just go-install
generate:
go generate ./meta/
update-locales:
#!/usr/bin/env -S bash -x
command -v xgotext || go install -v github.com/Tom5521/[email protected]
xgotext --input . --output ./po/en/default.pot --lang en --project-version {{long-latest-tag}}
for dir in ./po/*; do
if [[ "$dir" != "en" ]]; then
file=$dir/default.po
lang=$(basename $(dirname $file))
msgmerge -U --lang $lang --no-fuzzy-matching $file ./po/en/default.pot
fi
done
install-garble:
go install -v mvdan.cc/garble@latest
[private]
compress bin:
#!/usr/bin/env -S bash -x
if [[ {{skip-compress}} == 1 ]]; then
echo skipping compression of {{bin}}...
exit 0
fi
command -v upx > /dev/null
if [[ $? != 0 ]]; then
echo ---------------------------------
echo upx binary not found in PATH
echo skipping compression process...
echo ---------------------------------
exit 0
fi
upx --force-macos --8mib-ram -9 {{bin}}
upx -t {{bin}}
[confirm]
[unix]
install:
just build-local
cp fsize {{linux-install-path}}
fsize --gen-bash-completion {{bash-completion-path}}fsize
-command -v fish && \
fsize --gen-fish-completion {{fish-completion-path}}fsize.fish
-command -v 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-update-assets:
just release
gh release upload {{short-latest-tag}} builds/* --clobber
gh-release:
just release
gh release create {{short-latest-tag}} ./builds/* --generate-notes
test:
go test -v ./*/*_test.go
test-update:
#!/bin/bash
go build -v .
./fsize --update
v=$(./fsize --version)
if [[ "$v" != "fsize version {{short-latest-tag}}" ]]; then
echo -- FAIL --
exit 1
fi
update-asciinema:
just build-local
asciinema rec --title "fsize {{short-latest-tag}}" --command "./fsize /usr/share/"