forked from ungleich-public/cdist
9b9f34eb00
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
226 lines
5.3 KiB
Bash
Executable file
226 lines
5.3 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
|
#
|
|
# This file is part of cdist.
|
|
#
|
|
# cdist is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# cdist is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#
|
|
# This file contains the heavy lifting found usually in the Makefile
|
|
#
|
|
|
|
basedir=${0%/*}/../
|
|
# Change to checkout directory
|
|
cd "$basedir"
|
|
|
|
version=$(git describe)
|
|
|
|
option=$1; shift
|
|
|
|
case "$option" in
|
|
changelog-changes)
|
|
if [ "$#" -eq 1 ]; then
|
|
start=$1
|
|
else
|
|
start="[[:digit:]]"
|
|
fi
|
|
|
|
end="[[:digit:]]"
|
|
|
|
awk -F: "BEGIN { start=0 }
|
|
{
|
|
if(start == 0) {
|
|
if (\$0 ~ /^$start/) {
|
|
start = 1
|
|
}
|
|
} else {
|
|
if (\$0 ~ /^$end/) {
|
|
exit
|
|
} else {
|
|
print \$0
|
|
}
|
|
}
|
|
}" "$basedir/docs/changelog"
|
|
;;
|
|
|
|
changelog-version)
|
|
# get version from changelog
|
|
grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/:.*//'
|
|
;;
|
|
|
|
check-date)
|
|
# verify date in changelog is today
|
|
date_today="$(date +%Y-%m-%d)"
|
|
date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //')
|
|
|
|
if [ "$date_today" != "$date_changelog" ]; then
|
|
echo "Date in changelog is not today"
|
|
echo "Changelog: $date_changelog"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
check-unittest)
|
|
"$0" test
|
|
;;
|
|
|
|
check-version)
|
|
changelog_version=$($0 changelog-version)
|
|
|
|
if git show --quiet $changelog_version >/dev/null 2>&1; then
|
|
echo "Version $changelog_version already exists, aborting."
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
|
|
blog)
|
|
version=$1; shift
|
|
blogfile=$1; shift
|
|
|
|
cat << eof > "$blogfile"
|
|
[[!meta title="Cdist $version released"]]
|
|
|
|
Here's a short overview about the changes found in version ${version}:
|
|
|
|
eof
|
|
|
|
$0 changelog-changes >> "$blogfile"
|
|
|
|
cat << eof >> "$blogfile"
|
|
For more information visit the [[cdist homepage|software/cdist]].
|
|
|
|
[[!tag cdist config unix]]
|
|
eof
|
|
cd "$WEBBLOG"
|
|
git add "$file"
|
|
git commit -m "New cdist version (blogentry): $version" "$blogfile"
|
|
git push
|
|
;;
|
|
|
|
|
|
release-ml)
|
|
version=$($0 changelog-version)
|
|
to_a=cdist
|
|
to_d=l.schottelius.org
|
|
to=${to_a}@${to_d}
|
|
|
|
from_a=nico-cdist
|
|
from_d=schottelius.org
|
|
from=${from_a}@${from_d}
|
|
|
|
(
|
|
cat << eof
|
|
From: Nico -telmich- Schottelius <$from>
|
|
To: cdist mailing list <$to>
|
|
Subject: cdist $version released
|
|
|
|
Hello .*,
|
|
|
|
cdist $version has been released with the following changes:
|
|
|
|
eof
|
|
|
|
"$0" changelog-changes
|
|
cat << eof
|
|
|
|
Cheers,
|
|
|
|
Nico
|
|
|
|
--
|
|
Automatisation at its best level. With cdist.
|
|
eof
|
|
) | /usr/sbin/sendmail -f "$from" "$to"
|
|
;;
|
|
|
|
|
|
dist-tag)
|
|
version=$($0 changelog-version)
|
|
# add tag
|
|
printf "Enter tag description for %s> " "$version"
|
|
read tagmessage
|
|
git tag "$version" -m "$tagmessage"
|
|
;;
|
|
|
|
dist-branch-merge)
|
|
version=$($0 changelog-version)
|
|
target_branch=${version%\.*}
|
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
if [ "$target_branch" = "$current_branch" ]; then
|
|
echo "Skipping merge, already on destination branch"
|
|
else
|
|
printf "Press enter to git merge $current_branch into \"$target_branch\" > "
|
|
read prompt
|
|
git checkout "$target_branch"
|
|
git merge "$current_branch"
|
|
git checkout "$current_branch"
|
|
fi
|
|
;;
|
|
|
|
release-freecode)
|
|
version=$($0 changelog-version)
|
|
api_token=$(awk '/machine freecode login/ { print $8 }' ~/.netrc)
|
|
|
|
printf "Enter tag list for freecode release %s> " "$version"
|
|
read taglist
|
|
|
|
printf "Enter changelog for freecode release %s> " "$version"
|
|
read changelog
|
|
|
|
echo "Submit preview"
|
|
cat << eof
|
|
tag_list = $taglist
|
|
changelog = $changelog
|
|
version = $version
|
|
eof
|
|
printf "Press enter to submit to freecode> "
|
|
read dummy
|
|
|
|
cat << eof | cfreecode-api release-add cdist
|
|
{
|
|
"auth_code": "$api_token",
|
|
"release": {
|
|
"tag_list": "$taglist",
|
|
"version": "$version",
|
|
"changelog": "$changelog",
|
|
"hidden_from_frontpage": false
|
|
}
|
|
}
|
|
eof
|
|
|
|
;;
|
|
|
|
test)
|
|
export PYTHONPATH="$(pwd -P)"
|
|
|
|
if [ $# -lt 1 ]; then
|
|
python3 -m cdist.test
|
|
else
|
|
python3 -m unittest "$@"
|
|
fi
|
|
;;
|
|
|
|
version)
|
|
echo "VERSION = \"$(git describe)\"" > cdist/version.py
|
|
;;
|
|
|
|
*)
|
|
echo "Unknown helper target $@ - aborting"
|
|
exit 1
|
|
;;
|
|
|
|
esac
|