Repository navigation
Expand file tree
/
Copy pathdev
More file actions
executable file
·64 lines (50 loc) · 1.79 KB
/
Copy pathdev
File metadata and controls
executable file
·64 lines (50 loc) · 1.79 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
#!/usr/bin/env rad
---
Facilitates development & ops for flexid.
---
args:
build b bool # Enable to build.
test t bool # Enable to test.
version v str = "" # Set to release a new version.
amend a bool # Enable to amend the previous commit.
push p bool # Enable to push.
version enum ["patch", "minor", "major"]
if version or build:
$`go build`
$r`find . -name '*.go' -exec gofmt -w {} +`
$`goimports -w .`
if version or test:
$`go test`
if version:
clean_before = $`git status --porcelain | grep -q .` catch:
pass
$`git diff HEAD --compact-summary`
if not clean_before:
print(red("Dirty git repo! Commit and try again."))
exit(1)
version = resolve_version()
print("Bumping to version:", green(version))
if amend:
confirm $`git commit --amend --no-edit`
else:
confirm $`git commit -m "Bump version to {version}"`
confirm $`git tag -a "{version}" -m "Bump version to {version}"`
if version or push:
_, branch = $`echo -n $(git branch --show-current)`
confirm $`git push origin {branch} --tags`
print(green("✅ Done!"))
// -- functions
fn resolve_version():
_, tags = $`git tag`
tags = split(tags[:-1], "\n")
tags = [replace(t, "v", "") for t in tags]
tags = [split(t, "\.") for t in tags]
major = sort([parse_int(t[0]) for t in tags])[-1]
minor = sort([parse_int(t[1]) for t in tags if parse_int(t[0]) == major])[-1]
patch = sort([parse_int(t[2]) for t in tags if parse_int(t[0]) == major and parse_int(t[1]) == minor])[-1]
if version == "patch":
return "v{major}.{minor}.{patch + 1}"
if version == "minor":
return "v{major}.{minor + 1}.0"
if version == "major":
return "v{major + 1}.0.0"