Rot

Latest version: v0.1.0

Safety actively analyzes 613542 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.1.0

Initial release.


!/bin/zsh
The Release Script
Part of the Python Project Template.
Copyright © 2013, Kw.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions, and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the author of this software nor the names of
contributors to this software may be used to endorse or promote
products derived from this software without specific prior written
consent.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

. .pypt/config
function status {
echo $
}

function warning {
echo 'WARNING: '$
}

function error {
echo 'ERROR: '$
}

function cleanup {
rm -rf $PROJECTLC.egg-info **/__pycache__ dist build
}

function cleanup_cmfn {
[[ -e $cmfn ]] && rm $cmfn
[[ -e $cmfn"-commit" ]] && mv $cmfn"-commit" $cmfn2
}

status '*** Kw’s Release Scripts'

branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $? != 0 ]]; then
error 'Cannot fetch the current branch.'
exit 2
fi

echo $branch | grep '^release/' > /dev/null
if [[ $? != 0 ]]; then
error 'Not on a git-flow release branch.'
status 'Run: git flow release start [version number here]'
exit 2
fi

version=$(echo $branch | sed 's|^release/||')

echo $version | grep '^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$' > /dev/null

if [[ $? != 0 ]]; then
echo $version | grep '^[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\-[0-9A-Za-z-]\{1,\}$' > /dev/null
if [[ $? != 0 ]]; then
warning 'version number is not compliant with versioning scheme (Semantic Versioning 2.0)'
echo -n 'Continue? [y/N] '
read vercont
if [[ $vercont == 'y' || $vercont == 'Y' ]]; then
echo 'Continuing.'
else
exit 2
fi
else
status 'NOTICE: pre-release version number in use.'
echo -n 'Continue? [Y/n] '
read vercont
if [[ $vercont == 'n' || $vercont == 'N' ]]; then
exit 2
else
echo 'Continuing.'
fi
fi
fi

I am creating all the dates at the exact same time.
date=$(date '+%Y-%m-%d')
datel=$(date '+%Y-%m-%d %H:%M%z')
datep=$(date '+%Y%m%d')
dates=$(date '+%s')

cmfn=$PWD/.git/kwrs-$dates
cmfn2=/tmp/kwrs-commit-$dates

cleanup
cleanup_cmfn
git add -A --ignore-errors .

cat > $cmfn <<EOF
~ Kw’s Release Scripts
~ Please write your commit and changelog messages.
~ You may use reST formatting in the latter.
~ Please make the first line of your commit message short.
~ The second line of multi-line commits should be empty.

~ COMMIT MESSAGE START ~
~version~
~ COMMIT MESSAGE END ~

~ CHANGELOG MESSAGE START ~

~ CHANGELOG MESSAGE END ~

~~~
EOF

sed -i "s/~version~/v$version: /" $cmfn
git status >> $cmfn

if [[ "$EDITOR" == 'vim' || "$EDITOR" == '/usr/bin/vim' ]]; then
$EDITOR -c 'set filetype=gitcommit' $cmfn
elif [[ $EDITOR == '' ]]; then
vim -c 'set filetype=gitcommit' $cmfn
else
$EDITOR $cmfn
fi

.pypt/commitlog $cmfn $PWD $version
[[ $? != 0 ]] && exit $?

status 'Replacing versions and dates in files...'
sed "s/version=.*/version='$version',/g" setup.py -i
sed "s/release = .*/release = '$version'/g" docs/conf.py -i
sed "s/:Version: .*/:Version: $version/g" docs/*.rst -i
sed "s/ $PROJECTLCC v.*/ $PROJECTLCC v$version/" $PROJECTLC/**.py -i
sed "s/__version__ = .*/__version__ = '$version'/g" $PROJECTLC/__init__.py -i
sed "s/:Date: .*/:Date: $date/g" docs/*.rst -i

[[ -e PKGBUILD ]] && sed "s/pkgver=.*/pkgver=$version/g" PKGBUILD -i
[[ -e PKGBUILD-git ]] && sed "s/pkgver=.*/pkgver=$version/g" PKGBUILD-git -i
[[ -e PKGBUILD-2 ]] && sed "s/pkgver=.*/pkgver=$version/g" PKGBUILD-2 -i
[[ -e PKGBUILD-2-git ]] && sed "s/pkgver=.*/pkgver=$version/g" PKGBUILD-2-git -i

cp docs/README.rst docs/CHANGELOG.rst docs/CONTRIBUTING.rst .
cp docs/README.rst README

status 'Generating locales...'
./.pypt/localegen

status 'Importing...'
python -c "import $PROJECTLC"
if [[ $? = 1 ]]; then
error "Import failed. Fix your code or don't come back."
exit 1
fi

status 'Running tests...'
./setup.py test
if [[ $? = 1 ]]; then
error "Tests failed. Fix your code or don't come back."
exit 1
fi

status 'Running pre-sdist.hook...'

. .pypt/hooks/pre-sdist.hook

status 'This is the last chance to quit. Hit ^C now if you want to.'
read bailout

./setup.py sdist upload

status 'Creating AUR packages...'
[[ -e PKGBUILD ]] && md5out=$(md5sum 'dist/'$PROJECTLC'-'$version'.tar.gz'|awk '{print $1}')
sed "s/md5sums=.*/md5sums=('$md5out')/" PKGBUILD -i
[[ -e PKGBUILD-2 ]] && sed "s/md5sums=.*/md5sums=('$md5out')/" PKGBUILD-2 -i

if [[ $AURTYPE != "none" ]]; then
rm -rf MKPKGBUILD
mkdir MKPKGBUILD
cd MKPKGBUILD

case "$AURTYPE" in
"app")
mkdir $AURNAME{,-git}
cp ../PKGBUILD ./$AURNAME
cp ../PKGBUILD-git ./$AURNAME"-git/PKGBUILD"
tar -czf $AURNAME"-"$version"-1".src.tar.gz $AURNAME
tar -czf $AURNAME"-git-"$version"-1".src.tar.gz $AURNAME"-git"
;;
"python")
mkdir python{,2}'-'$PROJECTLC{,-git}
cp ../PKGBUILD ./python-$PROJECTLC
cp ../PKGBUILD-git ./python-$PROJECTLC"-git/PKGBUILD"
cp ../PKGBUILD-2 ./python2-$PROJECTLC/PKGBUILD
cp ../PKGBUILD-2-git ./python2-$PROJECTLC"-git/PKGBUILD"
tar -czf python-$PROJECTLC"-"$version"-1".src.tar.gz python-$PROJECTLC
tar -czf python2-$PROJECTLC"-"$version"-1".src.tar.gz python-$PROJECTLC
tar -czf python-$PROJECTLC"-git-"$version"-1".src.tar.gz python-$PROJECTLC"-git"
tar -czf python2-$PROJECTLC"-git-"$version"-1".src.tar.gz python-$PROJECTLC"-git"
;;
*) warning 'incorrect $AURTYPE value.'
esac
if [[ -e *.src.tar.gz ]]; then
./.pypt/aursend *.src.tar.gz
fi
cd ..
rm -rf MKPKGBUILD
fi

cleanup

git add -A --ignore-errors .

git commit -asF $cmfn"commit"

cleanup_cmfn

git flow release finish $version
git push
git push --tags

status "Done!"

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.