diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 2543e97..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,14 +0,0 @@ -[bumpversion] -current_version = 0.7.1 -parse = (?P\d+)\.(?P\d+)\.(?P\d+) -serialize = {major}.{minor}.{patch} -commit = True -tag = True - -[bumpversion:file:pyproject.toml] -search = version = "{current_version}" -replace = version = "{new_version}" - -[bumpversion:file:napari_aicsimageio/__init__.py] -search = {current_version} -replace = {new_version} diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 8f0fc85..fb66dc8 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "v*" pull_request: branches: - main @@ -78,7 +80,7 @@ jobs: run: pre-commit run --all-files publish: - if: "contains(github.event.head_commit.message, 'Bump version')" + if: "success() && startsWith(github.ref, 'refs/tags/')" needs: [check-manifest, test, lint] runs-on: ubuntu-latest @@ -90,6 +92,7 @@ jobs: python-version: 3.9 - name: Install Dependencies run: | + git tag python -m pip install --upgrade pip pip install build wheel - name: Build Package diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3984ad..c670e4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,13 +64,17 @@ Ready to contribute? Here's how to set up `napari-aicsimageio` for local develop ## Deploying A reminder for the maintainers on how to deploy. -Make sure all your changes are committed. -Then run: +Make sure the main branch is checked out and all desired changes +are merged. Then run: ```bash -$ bumpversion patch # possible: major / minor / patch -$ git push -$ git push --tags +$ git tag -a "vX.Y.Z" -m "vX.Y.Z" +$ git push upstream --follow-tags ``` -This will release a new package version on Git + GitHub and publish to PyPI. +(The `-a` flag indicates an [annotated tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging)) + +The presence of a tag starting with "v" will trigger the `publish` step in the +main github workflow, which will build the package and upload it to PyPI. The +version will be injected into the package metadata by +[`setuptools-scm`](https://github.com/pypa/setuptools_scm) \ No newline at end of file diff --git a/napari_aicsimageio/__init__.py b/napari_aicsimageio/__init__.py index 2c3410f..8507bbe 100644 --- a/napari_aicsimageio/__init__.py +++ b/napari_aicsimageio/__init__.py @@ -1,12 +1,15 @@ # -*- coding: utf-8 -*- - """Top-level package for napari-aicsimageio.""" +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("napari-aicsimageio") +except PackageNotFoundError: + __version__ = "uninstalled" + __author__ = "Eva Maxfield Brown" __email__ = "evamaxfieldbrown@gmail.com" -# Do not edit this string manually, always use bumpversion -# Details in CONTRIBUTING.md -__version__ = "0.7.1" def get_module_version() -> str: diff --git a/pyproject.toml b/pyproject.toml index 36e2515..60c9d57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,13 @@ # https://peps.python.org/pep-0517/ [build-system] -requires = ["setuptools>=45", "wheel"] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] + # https://peps.python.org/pep-0621/ [project] name = "napari-aicsimageio" -# Do not edit this string manually, always use bumpversion -# Details in CONTRIBUTING.rst -version = "0.7.1" description = "AICSImageIO bindings for napari" keywords = [ "aicsimageio", @@ -44,7 +43,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Visualization", "Topic :: Scientific/Engineering", ] -dynamic = [] +dynamic = ["version"] dependencies = [ "aicsimageio[all]>=4.6.3", "fsspec[http]", # no version pin, we pull from aicsimageio @@ -76,7 +75,6 @@ test = [ ] dev = [ "black>=19.10b0", - "bump2version>=1.0.1", "coverage>=5.1", "docutils>=0.10,<0.16", "flake8-debugger>=3.2.1", @@ -119,7 +117,6 @@ use_parentheses = true # https://github.com/mgedmin/check-manifest#configuration [tool.check-manifest] ignore = [ - ".bumpversion.cfg", ".editorconfig", ".napari/**/*", ".pre-commit-config.yaml",