Skip to content

Commit

Permalink
Better release process
Browse files Browse the repository at this point in the history
  • Loading branch information
pylessard committed Jun 26, 2024
1 parent b23db8f commit 174c1c8
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
7 changes: 4 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, normpath(abspath(join(dirname(__file__), '..', '..'))))
import isotp

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -60,9 +61,9 @@
# built documents.
#
# The short X.Y version.
version = u'2.0'
version = '.'.join(isotp.__version__.split('.')[0:2])
# The full version, including alpha/beta/rc tags.
release = version
release = isotp.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 4 additions & 0 deletions isotp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
from isotp.address import AddressingMode, TargetAddressType, Address, AsymmetricAddress
from isotp.protocol import TransportLayerLogic, TransportLayer, CanStack, NotifierBasedCanStack
from isotp.tpsock import socket

__version__ = '2.0.5'
__license__ = 'MIT'
__author__ = 'Pier-Yves Lessard'
43 changes: 43 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -eEuo pipefail
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd -P )"
cd "$PROJECT_ROOT"

RED='\033[0;31m'; CYAN='\033[0;36m'; YELLOW='\033[1;33m'; NC='\033[0m'

info() { >&2 echo -e "$CYAN[Info]$NC $1";}
warn() { >&2 echo -e "$YELLOW[Warning]$NC $1";}
error() { >&2 echo -e "$RED[Error]$NC $1"; }
fatal() { >&2 echo -e "$RED[Fatal]$NC $1"; exit ${2:-1}; }

trap 'fatal "Exited with status $? at line $LINENO"' ERR

[ -z ${1:+x} ] && fatal "Missing version argument"

version=$1

git_diff=$(git diff --shortstat)
git_diff_cached=$(git diff --shortstat --cached)

[ -z $git_diff ] || fatal "Uncomitted changes on repo"
[ -z $git_diff_cached ] || fatal "Staging changes on repo"

tag=$( { git tag -l --points-at HEAD || true; } | { grep $version || true; })
code_version=$(cat isotp/__init__.py | grep __version__ | sed -r "s/__version__[[:space:]]*=[[:space:]]*[']([^']+)'/\1/")
code_version=$(echo $code_version | tr -d '\r')

[ "$version" != "$tag" ] && fatal "Tag of HEAD does not match given version. Expected $version"
[ "$version" != "v$code_version" ] && fatal "Code version does not match given version : v$code_version vs $version"

rm -rf build dist *.egg-info
python3 -m build

read -p "Everything seems alright. Upload? "

proceed=0

[ "${REPLY,,}" == "yes" ] && proceed=1
[ "${REPLY,,}" == "y" ] && proceed=1

[ $proceed -ne 1 ] && { info "Not uploading"; exit; }
python3 -m twine upload dist/*
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from setuptools import setup, find_packages
from codecs import open
from os import path
import sys

here = path.abspath(path.dirname(__file__))
sys.path.insert(0, here)
import isotp

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
Expand All @@ -13,7 +16,7 @@
package_data={
'isotp' : ['py.typed']
},
version='2.0.4',
version=isotp.__version__,
extras_require={
'test': ['mypy', 'coverage', 'python-can'],
'dev': ['mypy', 'ipdb', 'autopep8', 'coverage', 'python-can']
Expand All @@ -24,7 +27,7 @@
author_email='py.lessard@gmail.com',
license='MIT',
url='https://github.com/pylessard/python-can-isotp',
download_url='https://github.com/pylessard/python-can-isotp/archive/v2.0.4.tar.gz',
download_url=f'https://github.com/pylessard/python-can-isotp/archive/v{isotp.__version__}.tar.gz',
keywords=['isotp', 'can', 'iso-15765', '15765', 'iso15765'],
python_requires='>=3.7',
classifiers=[
Expand Down

0 comments on commit 174c1c8

Please sign in to comment.