Skip to content

Commit ebbfe7e

Browse files
committed
Cleaner release process
1 parent 11445e7 commit ebbfe7e

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

doc/source/conf.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
import sys
1616
import os
17+
from os.path import abspath, join, dirname, normpath
1718

1819
# If extensions (or modules to document with autodoc) are in another directory,
1920
# add these directories to sys.path here. If the directory is relative to the
2021
# documentation root, use os.path.abspath to make it absolute, like shown here.
2122

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

2426
# -- General configuration ------------------------------------------------
2527

@@ -60,9 +62,9 @@
6062
# built documents.
6163
#
6264
# The short X.Y version.
63-
version = u'1.23'
65+
version = '.'.join(udsoncan.__version__.split('.')[0:2])
6466
# The full version, including alpha/beta/rc tags.
65-
release = version
67+
release = udsoncan.__version__
6668

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

scripts/release.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 udsoncan/__init__.py | grep __version__ | sed -r "s/__version__[[:space:]]*=[[:space:]]*'([^']+)'/\1/")
27+
28+
[ "$version" != "$tag" ] && fatal "Tag of HEAD does not match given version. Expected '$version'"
29+
[ "$version" != "v$code_version" ] && fatal "Code version does not match given version : 'v$code_version' vs '$version'"
30+
31+
rm -rf build dist *.egg-info
32+
python3 -m build
33+
34+
read -p "Everything seems alright. Upload? "
35+
36+
proceed=0
37+
38+
[ "${REPLY,,}" == "yes" ] && proceed=1
39+
[ "${REPLY,,}" == "y" ] && proceed=1
40+
41+
[ $proceed -ne 1 ] && { info "Not uploading"; exit; }
42+
python3 -m twine upload dist/*

setup.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
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__))
67

8+
sys.path.insert(0, here)
9+
import udsoncan
10+
711
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
812
long_description = f.read()
913

@@ -18,14 +22,14 @@
1822
'test': ['mypy', 'coverage'],
1923
'dev': ['mypy', 'ipdb', 'autopep8', 'coverage']
2024
},
21-
version='1.23.0',
25+
version=udsoncan.__version__,
2226
description='Implementation of the Unified Diagnostic Service (UDS) protocol (ISO-14229) used in the automotive industry.',
2327
long_description=long_description,
2428
author='Pier-Yves Lessard',
2529
author_email='[email protected]',
2630
license='MIT',
2731
url='https://github.com/pylessard/python-udsoncan',
28-
download_url='https://github.com/pylessard/python-udsoncan/archive/v1.23.0.tar.gz',
32+
download_url=f'https://github.com/pylessard/python-udsoncan/archive/v{udsoncan.__version__}.tar.gz',
2933
keywords=['uds', '14229', 'iso-14229', 'diagnostic', 'automotive'],
3034
python_requires='>=3.7',
3135
classifiers=[

udsoncan/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
from udsoncan.common.Units import *
2222
from udsoncan.typing import *
2323

24+
__version__ = '1.23.1'
25+
__license__ = 'MIT'
26+
__author__ = 'Pier-Yves Lessard'
27+
2428
latest_standard = 2020
2529
__default_log_config_file = path.join(path.dirname(path.abspath(__file__)), 'logging.conf')
2630

0 commit comments

Comments
 (0)