-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
98 lines (73 loc) · 2.35 KB
/
justfile
File metadata and controls
98 lines (73 loc) · 2.35 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
set dotenv-load := false
#Fire and forget option
alias up := up_publish
alias vup := upgrade
alias cup := commit_upgrade
alias pub := publish
default:
@just --list --unsorted
#Updates the help message within Readme.md
update readme:
#!/usr/bin/env python3
import subprocess
with open("Readme.md", "r+") as f:
s_d = "```HELP"
e_d = "```"
r = f.read()
start = r.find(s_d) + len(s_d)
end = r.find(e_d, start)
out = subprocess.getoutput("cargo run --release --quiet -- -h")
r = r.replace(r[start: end], f"\n{out}\n")
f.seek(0)
f.write(r)
f.close()
commit msg readme="Readme.md": (update readme)
git commit -am "{{msg}}"
try_commit msg readme="Readme.md": (update readme)
-git commit -am "{{msg}}"
push msg: (commit msg)
git push
# Upgrade version within Cargo.toml. type must be minor, middle or major
upgrade type="minor": && commit_upgrade
#!/usr/bin/env python3
import sys
with open("Cargo.toml", "r+") as f:
s_d = "version = \""
e_d = "\""
r = f.read()
start = r.find(s_d) + len(s_d)
end = r.find(e_d, start)
current = r[start: end]
new = current.split(".")
index = 0
upgrade = lambda i : str(int(new[i]) + 1)
reset = "0"
match "{{type}}":
case "minor":
new[2] = upgrade(2)
case "middle":
new[1] = upgrade(1)
new[2] = reset
case "major":
new[0] = upgrade(0)
new[1] = reset
new[2] = reset
case _:
exit("Error: 'type' must be one of: minor,major,middle")
new = ".".join(new)
r = r.replace(current, f"{new}")
f.seek(0)
f.write(r)
f.close()
commit_upgrade:
cargo check --release
git add "Cargo.toml" "Cargo.lock"
git commit -m "Version upgrade: $(cargo run --release --quiet -- --version)"
#Fire and forget option
up_publish type="minor": (upgrade type) (try_commit "$(cargo run --release --quiet -- --version)")
-git push
cargo publish
#Publish to crates.io
publish: (try_commit "$(cargo run --release --quiet -- --version)")
-git push
cargo publish