;tools: port bake to just, clean up
This commit is contained in:
parent
c0e9a7f797
commit
7b8df1d34f
201
bake
201
bake
@ -1,201 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# * bake
|
|
||||||
# ** Usage
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
usage() {
|
|
||||||
cat <<EOF
|
|
||||||
bake - light-medium project scripting (new). See also: make, ./Shake.hs
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
./bake - show this help
|
|
||||||
./bake relfiles - symlink important files temporarily in .relfiles/
|
|
||||||
./bake prep VERSION - prepare this release on today's date
|
|
||||||
./bake bin - push the current branch to CI to generate binaries
|
|
||||||
./bake lastweek - show last week info useful for TWIH
|
|
||||||
|
|
||||||
prep does the following:
|
|
||||||
- autocreates and switches to the appropriate release branch
|
|
||||||
- updates all hledger package versions
|
|
||||||
- updates all built-in docs
|
|
||||||
- updates all changelogs
|
|
||||||
VERSION is major (1.25), minor (1.25.1), fixup (1.25.1.1) or preview (1.25.99.1)
|
|
||||||
(see RELEASING.md).
|
|
||||||
|
|
||||||
Setting PAUSE=1, ECHO=1, and/or DRY=1 will cause commands to
|
|
||||||
be run one at a time, logged, or logged without running.
|
|
||||||
EOF
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
# ** hledger version numbers
|
|
||||||
|
|
||||||
# First 0-2 parts of a dotted version number.
|
|
||||||
versionMajorPart() {
|
|
||||||
echo "$1" | sed -E 's/([[:digit:]]+(\.[[:digit:]]+)?).*/\1/' # seriously...
|
|
||||||
}
|
|
||||||
|
|
||||||
# Third part of a dotted version number, if any.
|
|
||||||
versionMinorPart() {
|
|
||||||
echo "$1" | sed -E -e 's/^[[:digit:]]+(\.[[:digit:]]+(\.)?)?//' -e 's/^([[:digit:]]+).*/\1/'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fourth part of a dotted version number, if any.
|
|
||||||
versionFourthPart() {
|
|
||||||
echo "$1" | sed -E -e 's/^[[:digit:]]+(\.[[:digit:]]+(\.[[:digit:]]+(\.)?))//' -e 's/^([[:digit:]]+).*/\1/'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Does this dotted version number have a .99 third part and no fourth part ?
|
|
||||||
versionIsDev() {
|
|
||||||
V="$1"
|
|
||||||
test "$(versionMinorPart "$V")" = 99 -a -z "$(versionFourthPart "$V")"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Does this dotted version number have a .99 third part and a fourth part ?
|
|
||||||
versionIsPreview() {
|
|
||||||
V="$1"
|
|
||||||
test "$(versionMinorPart "$V")" = 99 -a -n "$(versionFourthPart "$V")"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Increment a major version number to the next.
|
|
||||||
majorVersionIncrement() {
|
|
||||||
python3 -c "print($1 + 0.01)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Appropriate release branch name for the given version number.
|
|
||||||
versionReleaseBranch() {
|
|
||||||
V="$1"
|
|
||||||
MAJOR=$(versionMajorPart "$V")
|
|
||||||
if versionIsDev "$V"; then
|
|
||||||
echo "$V is not a releasable version" >&2
|
|
||||||
exit 1
|
|
||||||
elif versionIsPreview "$V"; then
|
|
||||||
echo "$(majorVersionIncrement "$MAJOR")-branch"
|
|
||||||
else
|
|
||||||
echo "$MAJOR-branch"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# ** git
|
|
||||||
|
|
||||||
# Does the named branch exist in this git repo ?
|
|
||||||
gitBranchExists() {
|
|
||||||
B="$1"
|
|
||||||
git branch -l "$B" | grep -q "$B"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Switch to the named git branch, creating it if it doesn't exist.
|
|
||||||
gitSwitchAutoCreate() {
|
|
||||||
B="$1"
|
|
||||||
if gitBranchExists "$B"; then
|
|
||||||
git switch "$B"
|
|
||||||
else
|
|
||||||
git switch -c "$B"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# ** main
|
|
||||||
|
|
||||||
# Run a command with optional logging ($ECHO), dry-running ($DRY) and pausing ($PAUSE).
|
|
||||||
run() {
|
|
||||||
if [[ -n $PAUSE ]]; then read -rp "pausing, next is: $*"
|
|
||||||
elif [[ -n $ECHO || -n $DRY ]]; then echo "$@"
|
|
||||||
fi
|
|
||||||
if [[ -z $DRY ]]; then "$@"; fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Symlink important files temporarily in .relfiles/.
|
|
||||||
relfiles() {
|
|
||||||
echo "linking important release files in .relfiles/ for convenient access..."
|
|
||||||
mkdir -p .relfiles
|
|
||||||
cd .relfiles
|
|
||||||
for f in \
|
|
||||||
../stack.yaml \
|
|
||||||
../Shake.hs \
|
|
||||||
../CHANGELOGS.md \
|
|
||||||
../RELEASING.md \
|
|
||||||
../CHANGES.md \
|
|
||||||
../hledger/CHANGES.md \
|
|
||||||
../hledger-ui/CHANGES.md \
|
|
||||||
../hledger-web/CHANGES.md \
|
|
||||||
../hledger-lib/CHANGES.md \
|
|
||||||
../site/src/release-notes.md \
|
|
||||||
../site/src/install.md \
|
|
||||||
../doc/ANNOUNCE \
|
|
||||||
; do ln -sf $f .; done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create/switch to appropriate release branch and prepare for release.
|
|
||||||
prep() {
|
|
||||||
VERSION="$1"
|
|
||||||
[[ -z "$VERSION" ]] && usage
|
|
||||||
BRANCH=$(versionReleaseBranch "$VERSION")
|
|
||||||
COMMIT="-c"
|
|
||||||
echo "Switching to $BRANCH, auto-creating it if needed..."
|
|
||||||
run gitSwitchAutoCreate "$BRANCH"
|
|
||||||
echo "Bumping all version strings to $VERSION ..."
|
|
||||||
run ./Shake setversion "$VERSION" $COMMIT
|
|
||||||
echo "Updating all command help texts for embedding..."
|
|
||||||
run ./Shake cmdhelp $COMMIT
|
|
||||||
echo "Updating all dates in man pages..."
|
|
||||||
run ./Shake mandates
|
|
||||||
echo "Generating all the manuals in all formats...."
|
|
||||||
run ./Shake manuals $COMMIT
|
|
||||||
echo "Updating CHANGES.md files with latest commits..."
|
|
||||||
run ./Shake changelogs $COMMIT
|
|
||||||
}
|
|
||||||
|
|
||||||
# Push the current branch to the CI branches that generate platform binaries.
|
|
||||||
# Assumes the github remote is named "github".
|
|
||||||
bin() {
|
|
||||||
run git push -f github HEAD:binaries
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show last week info, useful for TWIH (sm's at least).
|
|
||||||
lastweek() {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show a bunch of debug message strings.
|
|
||||||
dbgstrs() {
|
|
||||||
rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o
|
|
||||||
}
|
|
||||||
|
|
||||||
# Extract Hledger.hs examples to jargon.j.
|
|
||||||
jargon() {
|
|
||||||
rg '^ *> (.*)' -or '$1' hledger-lib/Hledger.hs > jargon.j
|
|
||||||
}
|
|
||||||
|
|
||||||
# Extract ledger/hledger/beancount commit stats to project-commits.j.
|
|
||||||
# See also https://hledger.org/reporting-version-control-stats.html
|
|
||||||
projectcommits() {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
if declare -f "$1" > /dev/null; then "$@"; else usage; fi
|
|
||||||
|
|
||||||
# ** notes
|
|
||||||
# *** rerunning
|
|
||||||
# **** creates empty doc update commits
|
|
||||||
# **** creates duplicate changelog headings
|
|
||||||
# ***** CHANGES.md's version "1.24.99.1" is not yet tagged, can't list changes
|
|
||||||
152
justfile
152
justfile
@ -1,5 +1,5 @@
|
|||||||
# * project task scripts managed with https://github.com/casey/just.
|
# * project task scripts managed with https://github.com/casey/just.
|
||||||
# This hopes to gradually replace Makefile and bake.
|
# This aspires to gradually replace Makefile and bake.
|
||||||
|
|
||||||
@help:
|
@help:
|
||||||
just -lu
|
just -lu
|
||||||
@ -10,44 +10,148 @@
|
|||||||
@fmt:
|
@fmt:
|
||||||
just -q check || just --fmt --unstable
|
just -q check || just --fmt --unstable
|
||||||
|
|
||||||
# ** hledger version numbers
|
# ** releasing
|
||||||
|
|
||||||
|
# Symlink/copy important files temporarily in .relfiles/.
|
||||||
|
relfiles:
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
# Prepare to release today, creating/switching to release branch, updating versions, manuals, changelogs etc.
|
||||||
|
relprep VER:
|
||||||
|
#!/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
|
||||||
|
|
||||||
|
# Push the current branch to github to generate release binaries.
|
||||||
|
@relbin:
|
||||||
|
# assumes the github remote is named "github"
|
||||||
|
git push -f github HEAD:binaries
|
||||||
|
|
||||||
|
# *** hledger version numbers
|
||||||
|
# See doc/RELEASING.md > Glossary.
|
||||||
|
|
||||||
# First 0-2 parts of a dotted version number.
|
# First 0-2 parts of a dotted version number.
|
||||||
@versionMajorPart VER:
|
@_versionMajorPart VER:
|
||||||
echo {{ VER }} | sed -E 's/([[:digit:]]+(\.[[:digit:]]+)?).*/\1/'
|
echo {{ replace_regex(VER, '(\d+(\.\d+)?).*', '$1') }}
|
||||||
|
|
||||||
# Third part of a dotted version number, if any.
|
# Third part of a dotted version number, if any.
|
||||||
@versionMinorPart VER:
|
@_versionMinorPart VER:
|
||||||
echo {{ VER }} | sed -E -e 's/^[[:digit:]]+(\.[[:digit:]]+(\.)?)?//' -e 's/^([[:digit:]]+).*/\1/'
|
echo {{ if VER =~ '\d+(\.\d+){2,}' { replace_regex(VER, '\d+\.\d+\.(\d+).*', '$1') } else { '' } }}
|
||||||
|
|
||||||
# Fourth part of a dotted version number, if any.
|
# Fourth part of a dotted version number, if any.
|
||||||
@versionFourthPart VER:
|
@_versionFourthPart VER:
|
||||||
echo {{ VER }} | sed -E -e 's/^[[:digit:]]+(\.[[:digit:]]+(\.[[:digit:]]+(\.)?))//' -e 's/^([[:digit:]]+).*/\1/'
|
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 ?
|
# Does this dotted version number have a .99 third part and no fourth part ?
|
||||||
@versionIsDev VER:
|
@_versionIsDev VER:
|
||||||
V={{ VER }}
|
echo {{ if VER =~ '(\d+\.){2}99$' { 'y' } else { '' } }}
|
||||||
test "$(versionMinorPart "$V")" = 99 -a -z "$(versionFourthPart "$V")"
|
|
||||||
|
|
||||||
# Does this dotted version number have a .99 third part and a fourth part ?
|
# Does this dotted version number have a .99 third part and a fourth part ?
|
||||||
@versionIsPreview VER:
|
@_versionIsPreview VER:
|
||||||
V={{ VER }}
|
echo {{ if VER =~ '(\d+\.){2}99\.\d+' { 'y' } else { '' } }}
|
||||||
test "$(versionMinorPart "$V")" = 99 -a -n "$(versionFourthPart "$V")"
|
|
||||||
|
|
||||||
# Increment a major version number to the next.
|
# Increment a major version number to the next.
|
||||||
@majorVersionIncrement VER:
|
# @majorVersionIncrement MAJORVER:
|
||||||
python3 -c "print($1 + 0.01)"
|
# python3 -c "print({{MAJORVER}} + 0.01)"
|
||||||
|
|
||||||
# Appropriate release branch name for the given version number.
|
# Appropriate release branch name for the given version number.
|
||||||
@versionReleaseBranch VER:
|
_versionReleaseBranch VER:
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
V={{ VER }}
|
MAJOR=$(just _versionMajorPart {{ VER }})
|
||||||
MAJOR=$(versionMajorPart "$V")
|
if [[ $(just _versionIsDev {{VER}}) == y ]] then
|
||||||
if versionIsDev "$V"; then
|
echo "{{VER}} is not a releasable version" >&2
|
||||||
echo "$V is not a releasable version" >&2
|
exit 1
|
||||||
|
elif [[ $(just _versionIsPreview {{VER}}) == y ]] then
|
||||||
|
# echo "$(just majorVersionIncrement "$MAJOR")-branch"
|
||||||
|
echo "{{VER}} is not a releasable version" >&2
|
||||||
exit 1
|
exit 1
|
||||||
elif versionIsPreview "$V"; then
|
|
||||||
echo "$(majorVersionIncrement "$MAJOR")-branch"
|
|
||||||
else
|
else
|
||||||
echo "$MAJOR-branch"
|
echo "$MAJOR-branch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# *** git
|
||||||
|
|
||||||
|
# Does the named branch exist in this git repo ?
|
||||||
|
@_gitBranchExists BRANCH:
|
||||||
|
git branch -l {{BRANCH}} | grep -q {{BRANCH}}
|
||||||
|
|
||||||
|
# Switch to the named git branch, creating it if it doesn't exist.
|
||||||
|
_gitSwitchAutoCreate BRANCH:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
if just _gitBranchExists {{BRANCH}}; then
|
||||||
|
git switch {{BRANCH}}
|
||||||
|
else
|
||||||
|
git switch -c {{BRANCH}}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ** misc
|
||||||
|
|
||||||
|
# Show last week's activity, for TWIH
|
||||||
|
@lastweek:
|
||||||
|
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
|
||||||
|
|
||||||
|
# Show a bunch of debug messages.
|
||||||
|
@_dbgmsgs:
|
||||||
|
rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o
|
||||||
|
|
||||||
|
# # 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.
|
||||||
|
# See also https://hledger.org/reporting-version-control-stats.html
|
||||||
|
@_projectcommits:
|
||||||
|
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"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user