Skip to content

Commit f608329

Browse files
committed
maintain version number in __init__.py
1 parent 1d58e0d commit f608329

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

MAINTAINING.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ These notes are for maintenance of the Git / PyPI source and releases / versions
77
All the tasks we need to do, in order, when releasing a new version:
88

99
1. **Check the main branch!** - we should have all the changes we want to include merged/picked and tested
10-
2. **Update setup.py** - this might include other dependency or project description changes, but usually will just be a case of incrementing the version number, e.g. `0.1.9` -> `0.1.10`. Note the new number.
11-
3. **Update publish.sh** - this simple publish script performs the publish to PyPI and will need the new version number
12-
4. **Update CHANGELOG.md** - new versions go at the top of the file. See previous release blocks for formatting. I include a 'thanks' or 'reported by' attribution for PRs contributed or issues reported. The new version number from `setup.py` is used for the heading and the (future) PyPI URL
10+
2. **Update version number** - edit `dspace_rest_client/__init__.py` and update the version. Usually, this will just be a case of incrementing the version number, e.g. `0.1.9` -> `0.1.10`.
11+
3. **Update CHANGELOG.md** - new versions go at the top of the file. See previous release blocks for formatting. I include a 'thanks' or 'reported by' attribution for PRs contributed or issues reported. The new version number is used for the heading and the (future) PyPI URL
1312
4. **Commit release preparation** - once you are happy with the steps above, commit with a message like 'Prepare release 0.1.10'
1413
5. **Push branch** - making sure github is up to date, (in future: CI)
1514
6. **Clear out build and dist directories**: OPTIONAL, but nice to start with a clean Python build environment before making this new version
16-
7. **Run publish script** - this will run `setup.py` to build a new version then upload to PyPI with twine - you will need an API token and publish access in PyPI to do this.
17-
18-
TODO: If we just keep a `version` file around or base builds on a version number extracted from tag name, some of these steps can be more easily automated or derived instead of updated by hand, but for now it's all pretty simple.
15+
7. **Run publish script** - with version number as an argument, e.g. `./publish.sh 0.1.10`. This will run `setup.py` to build a new version then upload to PyPI with twine - you will need an API token and publish access in PyPI to do this.

dspace_rest_client/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import *
2+
__version__ = '0.1.12'

publish.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
11
#!/bin/bash
2-
python setup.py bdist_wheel
3-
twine upload --repository dspace-rest-client dist/dspace_rest_client-0.1.12-py3-none-any.whl
2+
3+
version=$1
4+
5+
if ! [[ $version =~ ^[0-9]+\.+[0-9]+\.[0-9]+$ ]]; then
6+
echo "Usage: publish.sh <version>"
7+
echo "Version must match the form x.y.z where all parts are numbers e.g. 0.1.13"
8+
exit 1
9+
fi
10+
11+
echo "Building dspace_rest_client version ${version}"
12+
if ! python setup.py bdist_wheel; then
13+
echo "Error: Failed to build the package"
14+
exit 1
15+
fi
16+
17+
echo "Uploading dspace_rest_client version ${version}"
18+
if ! twine upload --repository dspace-rest-client dist/dspace_rest_client-0.1.13-py3-none-any.whl; then
19+
echo "Error: Failed to upload to PyPI"
20+
exit 1
21+
fi
22+
23+
echo "...done"
24+
exit 0

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import setuptools
2+
from dspace_rest_client import __version__
23

34
with open("README.md", "r") as fh:
45
long_description = fh.read()
56

67
setuptools.setup(
78
name="dspace-rest-client",
8-
version="0.1.12",
9+
version=__version__,
910
author="Kim Shepherd",
1011
author_email="[email protected]",
1112
description="A DSpace 7 REST API client library",

0 commit comments

Comments
 (0)