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