This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJustfile
130 lines (106 loc) · 3.64 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
# just manual: https://github.com/casey/just
_default:
@just --list
# Runs clippy on the sources
check:
cargo clippy --locked -- -D warnings
# check security advisories
audit:
cargo deny check advisories
# Check links in markdown files
link-check:
-lychee -E '**/*.md'
# Runs nextest
test:
cargo nextest run
# Sets up a watcher that lints, tests, and builds
watch:
cargo watch -qcx 'clippy --all-targets --all-features -- -W clippy::pedantic -D warnings' -x 'nextest run' -x 'shuttle run --release'
# Update the changelog using git-cliff
_update_changelog version:
#!/usr/bin/env bash
set -euxo pipefail
# Update changelog
if ! command -v git-cliff &> /dev/null
then
echo "Please install git-cliff: https://github.com/orhun/git-cliff#installation"
exit
fi
git-cliff --tag {{version}} --unreleased --prepend CHANGELOG.md
${EDITOR:-vi} CHANGELOG.md
git commit CHANGELOG.md -m "docs(CHANGELOG): add entry for {{version}}"
# Increment the version
_incr_version version: (_update_changelog version)
#!/usr/bin/env bash
set -euxo pipefail
# Update version
cargo set-version {{trim_start_match(version, "v")}}
cargo build --release
git commit Cargo.toml Cargo.lock -m "chore(release): bump version to {{version}}"
# Get the changelog and git stats for the release
_tlog describe version:
# Format git-cliff output friendly for the tag
@git cliff -c minimal --strip all --unreleased --tag {{version}} | sd "(^## .*\n\s+|^See the.*|^\[.*|^\s*$|^###\s)" ""
@echo "$ git stats -r {{describe}}..{{version}}"
@git stats -r {{describe}}..HEAD
# Target can be ["major", "minor", "patch", or a version]
release target:
#!/usr/bin/env python3
# Inspired-by: https://git.sr.ht/~sircmpwn/dotfiles/tree/master/bin/semver
import os
import subprocess
import sys
import tempfile
if subprocess.run(["git", "branch", "--show-current"], stdout=subprocess.PIPE
).stdout.decode().strip() != "main":
print("WARNING! Not on the main branch.")
subprocess.run(["git", "pull", "--rebase"])
p = subprocess.run(["git", "describe", "--abbrev=0"], stdout=subprocess.PIPE)
describe = p.stdout.decode().strip()
old_version = describe[1:].split("-")[0].split(".")
if len(old_version) == 2:
[major, minor] = old_version
[major, minor] = map(int, [major, minor])
patch = 0
else:
[major, minor, patch] = old_version
[major, minor, patch] = map(int, [major, minor, patch])
new_version = None
if "{{target}}" == "patch":
patch += 1
elif "{{target}}" == "minor":
minor += 1
patch = 0
elif "{{target}}" == "major":
major += 1
minor = patch = 0
else:
new_version = "{{target}}"
if new_version is None:
if len(old_version) == 2 and patch == 0:
new_version = f"v{major}.{minor}"
else:
new_version = f"v{major}.{minor}.{patch}"
p = subprocess.run(["just", "_tlog", describe, new_version],
stdout=subprocess.PIPE)
shortlog = p.stdout.decode()
p = subprocess.run(["just", "_incr_version", new_version])
if p and p.returncode != 0:
print("Error: _incr_version returned nonzero exit code")
sys.exit(1)
with tempfile.NamedTemporaryFile() as f:
basename = os.path.basename(os.getcwd())
f.write(f"{basename} {new_version}\n\n".encode())
f.write(shortlog.encode())
f.flush()
subprocess.run(["git", "tag", "-e", "-F", f.name, "-a", new_version])
print(new_version)
# Deploy to shuttle.rs (e.g., just deploy --secrets Secrets.toml --ad)
deploy *FLAGS:
cargo shuttle deploy {{FLAGS}}
# Restart container on shuttle.rs
restart *FLAGS:
cargo shuttle project restart --idle-minutes 0 {{FLAGS}}
# View logs from shuttle.rs
logs *FLAGS:
cargo shuttle logs {{FLAGS}}