hledger/justfile

166 lines
5.7 KiB
Makefile
Raw Normal View History

2023-12-09 13:15:17 +03:00
#!/usr/bin/env just
# * Light project scripts, without file dependendencies, using https://github.com/casey/just.
# https://docs.rs/regex/1.5.4/regex/#syntax Regexps
# https://just.systems/man/en/chapter_31.html Functions
# See also Makefile, Shake.hs
@help:
just -lu
2023-12-09 13:26:13 +03:00
@_check:
just --fmt --unstable --check
2023-12-09 13:26:13 +03:00
@_fmt:
just -q _check || just --fmt --unstable
2023-12-09 13:26:06 +03:00
# ** dev
# push to github CI branch, wait for CI tests to pass, then push to master
@push *INTERVALSECS:
tools/push {{ INTERVALSECS }}
2023-12-09 12:54:46 +03:00
# ** releasing
# Symlink/copy important files temporarily in .relfiles/.
relfiles:
2023-12-09 13:29:21 +03:00
#!/usr/bin/env bash
echo "linking/copying important release files in .relfiles/ for convenient access..."
mkdir -p .relfiles
cd .relfiles
for f in \
../stack.yaml \
../Shake.hs \
../hledger-install/hledger-install.sh \
../CHANGES.md \
../hledger/CHANGES.md \
../hledger-ui/CHANGES.md \
../hledger-web/CHANGES.md \
../hledger-lib/CHANGES.md \
../doc/github-release.md \
../doc/ANNOUNCE \
../doc/ANNOUNCE.masto \
../site/src/release-notes.md \
../site/src/install.md \
; do ln -sf $f .; done
cp ../doc/RELEASING.md ./RELEASING2.md # temp copy which can be edited without disruption
2023-12-09 12:54:46 +03:00
# Prepare to release today, creating/switching to release branch, updating versions, manuals, changelogs etc.
relprep VER:
2023-12-09 13:29:21 +03:00
#!/usr/bin/env bash
[[ -z {{ VER }} ]] && usage
BRANCH=$(just _versionReleaseBranch {{ VER }})
COMMIT="-c"
echo "Switching to $BRANCH, auto-creating it if needed..."
_gitSwitchAutoCreate "$BRANCH"
echo "Bumping all version strings to {{ VER }} ..."
./Shake setversion {{ VER }} $COMMIT
echo "Updating all command help texts for embedding..."
./Shake cmdhelp $COMMIT
echo "Updating all dates in man pages..."
./Shake mandates
echo "Generating all the manuals in all formats...."
./Shake manuals $COMMIT
echo "Updating CHANGES.md files with latest commits..."
./Shake changelogs $COMMIT
2023-12-09 12:54:46 +03:00
# Push the current branch to github to generate release binaries.
@relbin:
2023-12-09 13:29:21 +03:00
# assumes the github remote is named "github"
git push -f github HEAD:binaries
2023-12-09 12:54:46 +03:00
# *** hledger version numbers
# See doc/RELEASING.md > Glossary.
# First 0-2 parts of a dotted version number.
2023-12-09 12:54:46 +03:00
@_versionMajorPart VER:
echo {{ replace_regex(VER, '(\d+(\.\d+)?).*', '$1') }}
# Third part of a dotted version number, if any.
2023-12-09 12:54:46 +03:00
@_versionMinorPart VER:
echo {{ if VER =~ '\d+(\.\d+){2,}' { replace_regex(VER, '\d+\.\d+\.(\d+).*', '$1') } else { '' } }}
# Fourth part of a dotted version number, if any.
2023-12-09 12:54:46 +03:00
@_versionFourthPart VER:
echo {{ if VER =~ '\d+(\.\d+){3,}' { replace_regex(VER, '\d+(\.\d+){2}\.(\d+).*', '$2') } else { '' } }}
# Does this dotted version number have a .99 third part and no fourth part ?
2023-12-09 12:54:46 +03:00
@_versionIsDev VER:
echo {{ if VER =~ '(\d+\.){2}99$' { 'y' } else { '' } }}
# Does this dotted version number have a .99 third part and a fourth part ?
2023-12-09 12:54:46 +03:00
@_versionIsPreview VER:
echo {{ if VER =~ '(\d+\.){2}99\.\d+' { 'y' } else { '' } }}
# Increment a major version number to the next.
2023-12-09 12:54:46 +03:00
# @majorVersionIncrement MAJORVER:
# python3 -c "print({{MAJORVER}} + 0.01)"
# Appropriate release branch name for the given version number.
2023-12-09 12:54:46 +03:00
_versionReleaseBranch VER:
#!/usr/bin/env bash
MAJOR=$(just _versionMajorPart {{ VER }})
2023-12-09 13:29:21 +03:00
if [[ $(just _versionIsDev {{ VER }}) == y ]] then
echo "{{ VER }} is not a releasable version" >&2
2023-12-09 12:54:46 +03:00
exit 1
2023-12-09 13:29:21 +03:00
elif [[ $(just _versionIsPreview {{ VER }}) == y ]] then
2023-12-09 12:54:46 +03:00
# echo "$(just majorVersionIncrement "$MAJOR")-branch"
2023-12-09 13:29:21 +03:00
echo "{{ VER }} is not a releasable version" >&2
exit 1
else
echo "$MAJOR-branch"
fi
2023-12-09 12:54:46 +03:00
# *** git
# Does the named branch exist in this git repo ?
@_gitBranchExists BRANCH:
2023-12-09 13:29:21 +03:00
git branch -l {{ BRANCH }} | grep -q {{ BRANCH }}
2023-12-09 12:54:46 +03:00
# Switch to the named git branch, creating it if it doesn't exist.
_gitSwitchAutoCreate BRANCH:
2023-12-09 13:29:21 +03:00
#!/usr/bin/env bash
if just _gitBranchExists {{ BRANCH }}; then
git switch {{ BRANCH }}
else
git switch -c {{ BRANCH }}
fi
2023-12-09 12:54:46 +03:00
# ** misc
# Show last week's activity, for TWIH
@lastweek:
2023-12-09 13:29:21 +03:00
echo "hledger time last 7 days including today (this should be run on a Friday):"
tt bal hledger -DTS -b '6 days ago' --drop 2
echo
echo "By activity type, percentage:"
tt bal hledger -DTS -b '6 days ago' --pivot t -% -c 1% | tail +1
echo
echo "Time log details:"
tt print hledger -b '6 days ago' | grep -E '^[^ ]|hledger'
echo
echo "main repo:"
git log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="6 days ago" --reverse
echo
echo "site repo:"
git -C site log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="6 days ago" --reverse
echo
echo "finance repo:"
git -C finance log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="6 days ago" --reverse
echo
2023-12-09 12:54:46 +03:00
# Show a bunch of debug messages.
@_dbgmsgs:
2023-12-09 13:29:21 +03:00
rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o
2023-12-09 12:54:46 +03:00
# # Extract Hledger.hs examples to jargon.j.
# @_jargon:
# rg '^ *> (.*)' -or '$1' hledger-lib/Hledger.hs > jargon.j
# echo "wrote jargon.j"
# Extract ledger/hledger/beancount commit stats to project-commits.j.
@_projectcommits:
2023-12-09 13:29:21 +03:00
# https://hledger.org/reporting-version-control-stats.html
printf "account ledger\naccount hledger\naccount beancount\n\n" >project-commits.j
for p in ledger hledger beancount; do git -C ../$p log --format="%cd (%h) %s%n ($p) 1%n" --date=short --reverse >> project-commits.j; done
echo "wrote project-commits.j"