-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
138 lines (120 loc) · 2.83 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
default:
@just --list
# helpers
git-head := "$(git rev-parse --abbrev-ref HEAD)"
gh-issue := "$(git rev-parse --abbrev-ref HEAD | cut -d- -f1)"
gh-title := "$(GH_PAGER=cat gh issue view " + gh-issue + " --json title -t '{{.title}}')"
version := "$(uv run bump-my-version show current_version 2>/dev/null)"
# init local dev environment
[group('dev')]
[macos]
init:
#!/usr/bin/env bash
set -euo pipefail
sudo port install gh uv
just sync
# pre-commit hook
echo -e "#!/usr/bin/env bash\njust pre-commit" > .git/hooks/pre-commit
chmod a+x .git/hooks/pre-commit
# synchronize local dev environment
[group('dev')]
sync:
uv sync --all-groups
# update local dev environment
[group('dev')]
upd:
uv sync --all-groups --upgrade
# add news item of type
[group('dev')]
news type issue *msg:
#!/usr/bin/env bash
set -euo pipefail
issue="{{ if issue == "-" { gh-issue } else { issue } }}"
msg="{{ if msg == "" { gh-title } else { msg } }}"
uv run towncrier create -c "$msg" "$issue.{{type}}.md"
# run linters
[group('dev')]
lint:
uv run mypy .
uv run ruff check
uv run ruff format --check
# build python package
[group('dev')]
build: sync
make build
# run tests
[group('dev')]
test *toxargs: build
time docker compose run --rm -it tox \
{{ if toxargs == "" { "run-parallel" } else { "run" } }} \
--installpkg="$(find dist -name '*.whl')" {{toxargs}}
# enter testing docker container
[group('dev')]
shell:
docker compose run --rm -it --entrypoint bash tox
# build docs
[group('dev')]
docs:
make docs
#
# Commit
# --------
#
# run pre-commit hook
[group('commit')]
pre-commit: lint docs
# create GitHub pull request
[group('commit')]
gh-pr *title:
gh pr create -d -t "{{ if title == "" { gh-title } else { title } }}"
#
# Release
# ---------
#
# just lint test
# just docs
#
# just bump
# just changelog
# (proofread changelog)
# (commit)
#
# just gh-pr
#
# just docs build
# (merge pull request)
#
# just gh-release
# just pypi-publish
#
# bump project version
[group('release')]
bump:
#!/usr/bin/env bash
set -euo pipefail
uv run bump-my-version show-bump
printf 'Choose bump path: '
read BUMP
uv run bump-my-version bump -- "$BUMP"
uv lock
# collect changelog entries
[group('release')]
changelog:
uv run towncrier build --yes --version "{{version}}"
sed -e's/^### \(.*\)$/***\1***/; s/\([a-z]\)\*\*\*$/\1***/' -i '' CHANGELOG.md
# create GitHub release
[group('release')]
gh-release:
#!/usr/bin/env bash
set -euo pipefail
if [ "{{git-head}}" != "main" ]; then
echo "Can release from main branch only"
exit 1
fi
tag="v{{version}}"
git tag "$tag" HEAD
gh release create -d -t "$tag — $(date -Idate)" --generate-notes "$tag"
# publish package on PyPI
[group('release')]
pypi-publish: build
uv publish