From b053ea17f2d7cdc322a668d07273eb98ab4281b1 Mon Sep 17 00:00:00 2001 From: Alex Leith Date: Wed, 17 Aug 2022 13:13:30 +1000 Subject: [PATCH 1/2] Initial commit of auto-versioning --- .bumpversion.cfg | 18 ------------------ .gitignore | 3 +++ README.md | 11 ++++++++++- aodntools/__init__.py | 5 ++++- bumpversion.sh | 14 -------------- setup.py | 3 ++- 6 files changed, 19 insertions(+), 35 deletions(-) delete mode 100644 .bumpversion.cfg delete mode 100755 bumpversion.sh diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 61534232..00000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,18 +0,0 @@ -[bumpversion] -commit = False -tag = False -tag_name = {new_version} -tag_message = Bump version to {new_version} -message = Bump version to {new_version} -parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? -serialize = - {major}.{minor}.{patch} - -[bumpversion:file:setup.py] -search = version='0.0.0' -replace = version='{new_version}' - -[bumpversion:file:aodntools/__init__.py] -search = __version__ = '0.0.0' -replace = __version__ = '{new_version}' - diff --git a/.gitignore b/.gitignore index eef60be9..652fdcee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ # PyCharm settings .idea + +.hypothesis +build diff --git a/README.md b/README.md index 745c25b1..0d6ca4e4 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,22 @@ # python-aodntools + ![python-aodntools](https://github.com/aodn/python-aodntools/workflows/python-aodntools/badge.svg) + [![coverage](https://codecov.io/gh/aodn/python-aodntools/branch/master/graph/badge.svg)](https://codecov.io/gh/aodn/python-aodntools) Repository for code used to generate and manipulate data products for the Australia Ocean Data Network (AODN). Sub-packages: + * [ncwriter](aodntools/ncwriter): a basic tool for creating netCDF files based on templates. * [timeseries_products](aodntools/timeseries_products): code used to generate value-added data products for time-series data. See the [examples](examples) folder for sample scripts demonstrating usage of these packages. + +## Versioning + +New versions can be published using the GitHub release tool. + ## Licensing -This project is licensed under the terms of the GNU GPLv3 license. \ No newline at end of file + +This project is licensed under the terms of the GNU GPLv3 license. diff --git a/aodntools/__init__.py b/aodntools/__init__.py index c57bfd58..368d1d8b 100644 --- a/aodntools/__init__.py +++ b/aodntools/__init__.py @@ -1 +1,4 @@ -__version__ = '0.0.0' +try: + from ._version import version as __version__ +except ImportError: + __version__ = "Unknown/Not Installed" diff --git a/bumpversion.sh b/bumpversion.sh deleted file mode 100755 index 45594752..00000000 --- a/bumpversion.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -euxo pipefail - -main() { - git fetch --prune origin "+refs/tags/*:refs/tags/*" - OLD_VERSION=$(git tag -l '*.*.*' --sort=-version:refname | head -n 1) - NEW_VERSION=$(bump2version --current-version $OLD_VERSION --list --tag --commit --allow-dirty patch | grep -oP '^new_version=\K.*$') - git push origin tag $NEW_VERSION - - exit 0 -} - -main "$@" diff --git a/setup.py b/setup.py index be441988..4e3c9c0e 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,8 @@ ] TESTS_REQUIRE = [ - 'pytest' + 'pytest', + 'setuptools_scm' ] EXTRAS_REQUIRE = { From ad61a455b70161b345c24cced7e2219083d9c274 Mon Sep 17 00:00:00 2001 From: Alex Leith Date: Wed, 17 Aug 2022 13:14:22 +1000 Subject: [PATCH 2/2] Add toml file --- .gitignore | 1 + pyproject.toml | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 652fdcee..2eddfd8b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ .hypothesis build +aodntools/_version.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..ef3da947 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] + +[tool.setuptools_scm] +write_to = "aodntools/_version.py"