Skip to content

Commit 174c1c8

Browse files
committedJun 26, 2024
Better release process
1 parent b23db8f commit 174c1c8

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed
 

‎doc/source/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
# add these directories to sys.path here. If the directory is relative to the
2020
# documentation root, use os.path.abspath to make it absolute, like shown here.
2121

22-
sys.path.insert(0, os.path.abspath('../..'))
22+
sys.path.insert(0, normpath(abspath(join(dirname(__file__), '..', '..'))))
23+
import isotp
2324

2425
# -- General configuration ------------------------------------------------
2526

@@ -60,9 +61,9 @@
6061
# built documents.
6162
#
6263
# The short X.Y version.
63-
version = u'2.0'
64+
version = '.'.join(isotp.__version__.split('.')[0:2])
6465
# The full version, including alpha/beta/rc tags.
65-
release = version
66+
release = isotp.__version__
6667

6768
# The language for content autogenerated by Sphinx. Refer to documentation
6869
# for a list of supported languages.

‎isotp/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@
3838
from isotp.address import AddressingMode, TargetAddressType, Address, AsymmetricAddress
3939
from isotp.protocol import TransportLayerLogic, TransportLayer, CanStack, NotifierBasedCanStack
4040
from isotp.tpsock import socket
41+
42+
__version__ = '2.0.5'
43+
__license__ = 'MIT'
44+
__author__ = 'Pier-Yves Lessard'

‎scripts/release.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -eEuo pipefail
3+
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd -P )"
4+
cd "$PROJECT_ROOT"
5+
6+
RED='\033[0;31m'; CYAN='\033[0;36m'; YELLOW='\033[1;33m'; NC='\033[0m'
7+
8+
info() { >&2 echo -e "$CYAN[Info]$NC $1";}
9+
warn() { >&2 echo -e "$YELLOW[Warning]$NC $1";}
10+
error() { >&2 echo -e "$RED[Error]$NC $1"; }
11+
fatal() { >&2 echo -e "$RED[Fatal]$NC $1"; exit ${2:-1}; }
12+
13+
trap 'fatal "Exited with status $? at line $LINENO"' ERR
14+
15+
[ -z ${1:+x} ] && fatal "Missing version argument"
16+
17+
version=$1
18+
19+
git_diff=$(git diff --shortstat)
20+
git_diff_cached=$(git diff --shortstat --cached)
21+
22+
[ -z $git_diff ] || fatal "Uncomitted changes on repo"
23+
[ -z $git_diff_cached ] || fatal "Staging changes on repo"
24+
25+
tag=$( { git tag -l --points-at HEAD || true; } | { grep $version || true; })
26+
code_version=$(cat isotp/__init__.py | grep __version__ | sed -r "s/__version__[[:space:]]*=[[:space:]]*[']([^']+)'/\1/")
27+
code_version=$(echo $code_version | tr -d '\r')
28+
29+
[ "$version" != "$tag" ] && fatal "Tag of HEAD does not match given version. Expected $version"
30+
[ "$version" != "v$code_version" ] && fatal "Code version does not match given version : v$code_version vs $version"
31+
32+
rm -rf build dist *.egg-info
33+
python3 -m build
34+
35+
read -p "Everything seems alright. Upload? "
36+
37+
proceed=0
38+
39+
[ "${REPLY,,}" == "yes" ] && proceed=1
40+
[ "${REPLY,,}" == "y" ] && proceed=1
41+
42+
[ $proceed -ne 1 ] && { info "Not uploading"; exit; }
43+
python3 -m twine upload dist/*

‎setup.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
from setuptools import setup, find_packages
22
from codecs import open
33
from os import path
4+
import sys
45

56
here = path.abspath(path.dirname(__file__))
7+
sys.path.insert(0, here)
8+
import isotp
69

710
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
811
long_description = f.read()
@@ -13,7 +16,7 @@
1316
package_data={
1417
'isotp' : ['py.typed']
1518
},
16-
version='2.0.4',
19+
version=isotp.__version__,
1720
extras_require={
1821
'test': ['mypy', 'coverage', 'python-can'],
1922
'dev': ['mypy', 'ipdb', 'autopep8', 'coverage', 'python-can']
@@ -24,7 +27,7 @@
2427
author_email='py.lessard@gmail.com',
2528
license='MIT',
2629
url='https://github.com/pylessard/python-can-isotp',
27-
download_url='https://github.com/pylessard/python-can-isotp/archive/v2.0.4.tar.gz',
30+
download_url=f'https://github.com/pylessard/python-can-isotp/archive/v{isotp.__version__}.tar.gz',
2831
keywords=['isotp', 'can', 'iso-15765', '15765', 'iso15765'],
2932
python_requires='>=3.7',
3033
classifiers=[

0 commit comments

Comments
 (0)