2011-03-25 19:56:25 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2013-04-09 13:12:11 +00:00
|
|
|
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
2011-03-25 19:56:25 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
#
|
2013-06-03 20:29:49 +00:00
|
|
|
# This file contains the heavy lifting found usually in the Makefile
|
2011-03-25 19:56:25 +00:00
|
|
|
#
|
2011-03-20 02:23:13 +00:00
|
|
|
|
2013-06-20 07:24:05 +00:00
|
|
|
basedir=${0%/*}/../
|
|
|
|
# Change to checkout directory
|
|
|
|
cd "$basedir"
|
|
|
|
|
|
|
|
version=$(git describe)
|
2011-11-16 07:10:50 +00:00
|
|
|
|
2013-07-09 13:32:10 +00:00
|
|
|
option=$1; shift
|
|
|
|
|
|
|
|
case "$option" in
|
2012-11-07 11:12:26 +00:00
|
|
|
changelog-changes)
|
2013-07-09 13:32:10 +00:00
|
|
|
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"
|
2012-10-26 16:20:09 +00:00
|
|
|
;;
|
|
|
|
|
2012-10-26 16:35:47 +00:00
|
|
|
changelog-version)
|
2013-07-09 13:32:10 +00:00
|
|
|
# get version from changelog
|
2012-10-26 16:35:47 +00:00
|
|
|
grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/:.*//'
|
|
|
|
;;
|
|
|
|
|
2013-06-03 20:29:49 +00:00
|
|
|
check-date)
|
2013-07-09 13:32:10 +00:00
|
|
|
# verify date in changelog is today
|
2012-10-26 16:35:47 +00:00
|
|
|
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
|
2012-10-25 16:28:19 +00:00
|
|
|
;;
|
2011-03-25 21:10:52 +00:00
|
|
|
|
2013-07-09 13:32:10 +00:00
|
|
|
check-unittest)
|
|
|
|
"$0" test
|
|
|
|
;;
|
|
|
|
|
2012-11-07 11:12:26 +00:00
|
|
|
blog)
|
2013-07-09 13:32:10 +00:00
|
|
|
version=$1; shift
|
|
|
|
blogfile=$1; shift
|
2013-07-09 13:46:57 +00:00
|
|
|
dir=${blogfile%/*}
|
|
|
|
file=${blogfile##*/}
|
|
|
|
|
2013-07-09 13:32:10 +00:00
|
|
|
|
2012-11-07 11:12:26 +00:00
|
|
|
cat << eof > "$blogfile"
|
|
|
|
[[!meta title="Cdist $version released"]]
|
|
|
|
|
2013-07-03 20:33:48 +00:00
|
|
|
Here's a short overview about the changes found in version ${version}:
|
2012-11-07 11:12:26 +00:00
|
|
|
|
|
|
|
eof
|
|
|
|
|
2013-07-09 13:46:57 +00:00
|
|
|
$0 changelog-changes "$version" >> "$blogfile"
|
2012-11-07 11:12:26 +00:00
|
|
|
|
|
|
|
cat << eof >> "$blogfile"
|
|
|
|
For more information visit the [[cdist homepage|software/cdist]].
|
|
|
|
|
|
|
|
[[!tag cdist config unix]]
|
|
|
|
eof
|
2013-07-09 13:46:57 +00:00
|
|
|
cd "$dir"
|
2012-11-07 11:12:26 +00:00
|
|
|
git add "$file"
|
2013-07-09 13:46:57 +00:00
|
|
|
# Allow git commit to fail if there are no changes
|
|
|
|
git commit -m "cdist blog update: $version" "$blogfile" || true
|
2012-11-07 11:12:26 +00:00
|
|
|
;;
|
|
|
|
|
2013-07-09 15:22:56 +00:00
|
|
|
ml-release)
|
|
|
|
version=$1; shift
|
2013-07-09 13:32:10 +00:00
|
|
|
|
2012-11-07 11:12:26 +00:00
|
|
|
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>
|
2012-11-07 11:13:06 +00:00
|
|
|
Subject: cdist $version released
|
2012-11-07 11:12:26 +00:00
|
|
|
|
|
|
|
Hello .*,
|
|
|
|
|
|
|
|
cdist $version has been released with the following changes:
|
|
|
|
|
|
|
|
eof
|
|
|
|
|
2013-07-09 15:22:56 +00:00
|
|
|
"$0" changelog-changes "$version"
|
2012-11-07 11:12:26 +00:00
|
|
|
cat << eof
|
|
|
|
|
|
|
|
Cheers,
|
|
|
|
|
|
|
|
Nico
|
|
|
|
|
|
|
|
--
|
|
|
|
Automatisation at its best level. With cdist.
|
|
|
|
eof
|
|
|
|
) | /usr/sbin/sendmail -f "$from" "$to"
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
2013-07-09 15:22:56 +00:00
|
|
|
freecode-release)
|
|
|
|
version=$1; shift
|
2012-10-31 07:52:40 +00:00
|
|
|
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
|
|
|
|
|
2012-11-01 14:39:36 +00:00
|
|
|
cat << eof | cfreecode-api release-add cdist
|
2012-10-31 07:52:40 +00:00
|
|
|
{
|
|
|
|
"auth_code": "$api_token",
|
|
|
|
"release": {
|
2012-11-01 16:45:34 +00:00
|
|
|
"tag_list": "$taglist",
|
2012-10-31 07:52:40 +00:00
|
|
|
"version": "$version",
|
2012-11-01 16:45:34 +00:00
|
|
|
"changelog": "$changelog",
|
2012-10-31 07:52:40 +00:00
|
|
|
"hidden_from_frontpage": false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eof
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
2013-09-04 20:33:26 +00:00
|
|
|
release-git-tag)
|
|
|
|
target_version=$($0 changelog-version)
|
|
|
|
if git rev-parse --verify refs/tags/$target_version; then
|
|
|
|
echo "Tag for $target_version exists, aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
printf "Enter tag description for ${target_version}: "
|
|
|
|
read tagmessage
|
|
|
|
git tag "$target_version" -m "$$tagmessage"
|
|
|
|
;;
|
|
|
|
|
2013-09-04 19:20:05 +00:00
|
|
|
release)
|
|
|
|
set -e
|
2013-09-04 20:33:26 +00:00
|
|
|
target_version=$($0 changelog-version)
|
|
|
|
target_branch=$($0 version-branch)
|
|
|
|
|
|
|
|
echo "Beginning release process for $target_version"
|
|
|
|
|
2013-09-04 19:20:05 +00:00
|
|
|
# First check everything is sane
|
|
|
|
"$0" check-date
|
|
|
|
"$0" check-unittest
|
2013-09-04 20:33:26 +00:00
|
|
|
|
|
|
|
# Generate version file to be included in packaging
|
|
|
|
"$0" version
|
|
|
|
|
|
|
|
# Ensure the git status is clean, else abort
|
|
|
|
if ! git diff-index --exit-code --quiet HEAD; then
|
|
|
|
echo "Unclean tree, aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure we are on the master branch
|
|
|
|
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
|
|
|
|
echo "Releases are happening from the master branch, aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure version branch exists
|
|
|
|
if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then
|
|
|
|
git branch "$target_branch"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Merge master branch into version branch
|
|
|
|
git checkout "$target_branch"
|
|
|
|
git merge master
|
|
|
|
|
|
|
|
# Verify that after the merge everything works
|
|
|
|
"$0" check-date
|
|
|
|
"$0" check-unittest
|
|
|
|
|
|
|
|
# Generate man pages (indirect check if they build)
|
|
|
|
make man
|
|
|
|
|
|
|
|
# Generate speeches (indirect check if they build)
|
|
|
|
make speeches
|
|
|
|
|
|
|
|
#############################################################
|
|
|
|
# Everything green, let's do the release
|
|
|
|
|
|
|
|
# Tag the current commit
|
|
|
|
"$0" release-git-tag
|
|
|
|
|
|
|
|
# Also merge back the version branch
|
|
|
|
git checkout master
|
|
|
|
git merge "$target_branch"
|
|
|
|
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
make speeches-dist
|
|
|
|
|
|
|
|
RELEASE=speeches-dist web-release
|
|
|
|
RELEASE+=ml-release freecode-release
|
|
|
|
RELEASE+=man-dist pypi-release git-release
|
|
|
|
RELEASE+=archlinux-release
|
|
|
|
|
2013-09-04 19:20:05 +00:00
|
|
|
;;
|
|
|
|
|
2012-10-25 16:44:05 +00:00
|
|
|
test)
|
2012-11-01 13:13:52 +00:00
|
|
|
export PYTHONPATH="$(pwd -P)"
|
2012-10-25 16:44:05 +00:00
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
python3 -m cdist.test
|
|
|
|
else
|
|
|
|
python3 -m unittest "$@"
|
|
|
|
fi
|
2012-10-25 16:28:19 +00:00
|
|
|
;;
|
2013-07-09 13:32:10 +00:00
|
|
|
|
2013-09-04 20:33:26 +00:00
|
|
|
version-branch)
|
|
|
|
"$0" changelog-version | cut -d. -f '1,2'
|
|
|
|
;;
|
|
|
|
|
2013-06-07 19:14:51 +00:00
|
|
|
version)
|
2013-06-08 01:36:59 +00:00
|
|
|
echo "VERSION = \"$(git describe)\"" > cdist/version.py
|
2013-06-07 19:14:51 +00:00
|
|
|
;;
|
2011-03-25 21:10:52 +00:00
|
|
|
|
2012-10-25 16:44:05 +00:00
|
|
|
*)
|
2013-07-09 12:53:00 +00:00
|
|
|
echo "Unknown helper target $@ - aborting"
|
2012-10-25 16:44:05 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2011-10-02 13:56:27 +00:00
|
|
|
|
2011-03-25 20:04:26 +00:00
|
|
|
esac
|