Simplify maintainer's helper script

This commit is contained in:
Darko Poljak 2019-05-09 21:05:33 +02:00
parent afa00a9094
commit 66cdbc5233

View file

@ -23,9 +23,8 @@
#
usage() {
printf "usage: %s TARGET RUN-AS
printf "usage: %s TARGET [TARGET-ARGS...]
Available targets:
print-runas
changelog-changes
changelog-version
check-date
@ -58,64 +57,29 @@ usage() {
version
target-version
clean
distclean
Run as:
nico
darko - default, if empty string specified\n" "$1"
distclean\n" "$1"
}
basename="${0##*/}"
if [ $# -lt 2 ]
if [ $# -lt 1 ]
then
usage "${basename}"
exit 1
fi
option=$1; shift
run_as="$1"; shift
case "$run_as" in
nico)
from_a=nico.schottelius
from_d=ungleich.ch
ml_name="Nico Schottelius"
ml_sig_name="Nico"
;;
darko|'')
from_a=darko.poljak
from_d=gmail.com
ml_name="Darko Poljak"
ml_sig_name="Darko"
if [ -z "${run_as}" ]
then
run_as="darko"
fi
;;
*)
printf "Unsupported RUN-AS value: '%s'.\n" "${run_as}" >&2
usage "${basename}"
exit 1
;;
esac
SHELLCHECKCMD="shellcheck -s sh -f gcc -x"
# Skip SC2154 for variables starting with __ since such variables are cdist
# environment variables.
SHELLCHECK_SKIP=': __.*is referenced but not assigned.*\[SC2154\]'
to_a="cdist-configuration-management"
to_d="googlegroups.com"
# Change to checkout directory
basedir="${0%/*}/../"
cd "$basedir"
case "$option" in
print-runas)
printf "run_as: '%s'\n" "$run_as"
;;
changelog-changes)
if [ "$#" -eq 1 ]; then
start=$1
@ -159,7 +123,7 @@ case "$option" in
;;
check-unittest)
"$0" test "${run_as}"
"$0" test
;;
ml-release)
@ -168,20 +132,10 @@ case "$option" in
exit 1
fi
# Send mail only once - lock until new changelog things happened.
[ ! -f .lock-ml ] && touch .lock-ml
x=$(find 'docs' -name changelog -type f -newer .lock-ml)
[ -z "${x}" ] && exit 0
version=$1; shift
to=${to_a}@${to_d}
from=${from_a}@${from_d}
(
cat << eof
From: ${ml_name} <$from>
To: cdist mailing list <$to>
Subject: cdist $version has been released
Hello .*,
@ -190,23 +144,11 @@ cdist $version has been released with the following changes:
eof
"$0" changelog-changes "${run_as}" "$version"
"$0" changelog-changes "$version"
cat << eof
Cheers,
${ml_sig_name}
--
Automatisation at its best level. With cdist.
eof
) > mailinglist.tmp
if [ "$run_as" = "nico" ]
then
/usr/sbin/sendmail -f "$from" "$to" < mailinglist.tmp && rm -f mailinglist.tmp
fi
touch .lock-ml
;;
archlinux-release)
@ -225,7 +167,7 @@ eof
pypi-release)
# Ensure that pypi release has the right version
"$0" version "${run_as}"
"$0" version
make docs-clean
make docs
@ -233,7 +175,7 @@ eof
;;
release-git-tag)
target_version=$($0 changelog-version "${run_as}")
target_version=$($0 changelog-version)
if git rev-parse --verify "refs/tags/${target_version}" 2>/dev/null; then
printf "Tag for %s exists, aborting\n" "${target_version}"
exit 1
@ -287,7 +229,7 @@ eof
git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \
|| exit 1
# make sure target version is generated
"$0" target-version "${run_as}"
"$0" target-version
tar -x -f "${archivename}" || exit 1
cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1
tar -c -f "${archivename}" "cdist-${tag}/" || exit 1
@ -317,7 +259,7 @@ eof
| sed "${sed_cmd}") || exit 1
# make release
changelog=$("$0" changelog-changes "${run_as}" "$1" | sed 's/^[[:space:]]*//')
changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//')
release_notes=$(
printf "%s\n\n%s\n\n**Changelog**\n\n%s\n" \
"${response_archive}" "${response_archive_sig}" "${changelog}"
@ -338,19 +280,19 @@ eof
release)
set -e
target_version=$($0 changelog-version "${run_as}")
target_branch=$($0 version-branch "${run_as}")
target_version=$($0 changelog-version)
target_branch=$($0 version-branch)
printf "Beginning release process for %s\n" "${target_version}"
# First check everything is sane
"$0" check-date "${run_as}"
"$0" check-unittest "${run_as}"
"$0" check-pycodestyle "${run_as}"
"$0" check-shellcheck "${run_as}"
"$0" check-date
"$0" check-unittest
"$0" check-pycodestyle
"$0" check-shellcheck
# Generate version file to be included in packaging
"$0" target-version "${run_as}"
"$0" target-version
# Ensure the git status is clean, else abort
if ! git diff-index --name-only --exit-code HEAD ; then
@ -385,8 +327,8 @@ eof
fi
# Verify that after the merge everything works
"$0" check-date "${run_as}"
"$0" check-unittest "${run_as}"
"$0" check-date
"$0" check-unittest
# Generate documentation (man and html)
# First, clean old generated docs
@ -397,7 +339,7 @@ eof
# Everything green, let's do the release
# Tag the current commit
"$0" release-git-tag "${run_as}"
"$0" release-git-tag
# Also merge back the version branch
if [ "$masterbranch" = yes ]; then
@ -406,37 +348,28 @@ eof
fi
# Publish git changes
# if you want to have mirror locally then uncomment this support
# if [ "$run_as" = "nico" ]
# then
# if you want to have mirror locally then uncomment this and comment below
# git push --mirror
# else
# if we are not Nico :) then just push, no mirror
git push
# push also new branch and set up tracking
git push -u origin "${target_branch}"
# fi
# Create and publish package for pypi
"$0" pypi-release "${run_as}"
if [ "$run_as" = "nico" ]
then
# Archlinux release is based on pypi
"$0" archlinux-release "${run_as}"
fi
"$0" pypi-release
# sign git tag
printf "Enter upstream repository authentication token: "
read -r token
"$0" sign-git-release "${run_as}" "${target_version}" "${token}"
"$0" sign-git-release "${target_version}" "${token}"
# Announce change on ML
"$0" ml-release "${run_as}" "${target_version}"
"$0" ml-release "${target_version}"
cat << eof
Manual steps post release:
- cdist-web
- send mail body generated in mailinglist.tmp and inform Dmitry for deb
- twitter
eof
;;
@ -476,7 +409,7 @@ eof
;;
check-pycodestyle)
"$0" pycodestyle "${run_as}"
"$0" pycodestyle
printf "\\nPlease review pycodestyle report.\\n"
while true
do
@ -522,20 +455,20 @@ eof
;;
shellcheck-gencodes)
"$0" shellcheck-local-gencodes "${run_as}"
"$0" shellcheck-remote-gencodes "${run_as}"
"$0" shellcheck-local-gencodes
"$0" shellcheck-remote-gencodes
;;
shellcheck-types)
"$0" shellcheck-type-explorers "${run_as}"
"$0" shellcheck-manifests "${run_as}"
"$0" shellcheck-gencodes "${run_as}"
"$0" shellcheck-type-explorers
"$0" shellcheck-manifests
"$0" shellcheck-gencodes
;;
shellcheck)
"$0" shellcheck-global-explorers "${run_as}"
"$0" shellcheck-types "${run_as}"
"$0" shellcheck-scripts "${run_as}"
"$0" shellcheck-global-explorers
"$0" shellcheck-types
"$0" shellcheck-scripts
;;
shellcheck-type-files)
@ -543,8 +476,8 @@ eof
;;
shellcheck-with-files)
"$0" shellcheck "${run_as}"
"$0" shellcheck-type-files "${run_as}"
"$0" shellcheck
"$0" shellcheck-type-files
;;
shellcheck-build-helper)
@ -552,7 +485,7 @@ eof
;;
check-shellcheck)
"$0" shellcheck "${run_as}"
"$0" shellcheck
printf "\\nPlease review shellcheck report.\\n"
while true
do
@ -574,7 +507,7 @@ eof
;;
version-branch)
"$0" changelog-version "${run_as}" | cut -d. -f '1,2'
"$0" changelog-version | cut -d. -f '1,2'
;;
version)
@ -582,7 +515,7 @@ eof
;;
target-version)
target_version=$($0 changelog-version "${run_as}")
target_version=$($0 changelog-version)
printf "VERSION = \"%s\"\n" "${target_version}" > cdist/version.py
;;
@ -605,7 +538,7 @@ eof
;;
distclean)
"$0" clean "${run_as}"
"$0" clean
rm -f cdist/version.py
;;
*)