Skip to content

Commit 6217a33

Browse files
authored
Merge pull request #114 from jo-mueller/new-publishing-workflow
New publishing workflow
2 parents 8443a7b + 1955b18 commit 6217a33

6 files changed

Lines changed: 52 additions & 21 deletions

File tree

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,46 @@ jobs:
2828
uses: mikepenz/action-junit-report@v2
2929
with:
3030
report_paths: "junit/test-results*.xml"
31+
32+
build:
33+
name: Build distribution 📦
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.x"
42+
- name: Install pypa/build
43+
run: >-
44+
python3 -m pip install build --user
45+
- name: Build a binary wheel and a source tarball
46+
run: python3 -m build
47+
- name: Store the distribution packages
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: python-package-distributions
51+
path: dist/
52+
53+
publish-to-pypi:
54+
name: >-
55+
Publish Python 🐍 distribution 📦 to PyPI
56+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
57+
needs:
58+
- build
59+
runs-on: ubuntu-latest
60+
environment:
61+
name: pypi
62+
url: https://pypi.org/project/multiscale_spatial_image/
63+
permissions:
64+
id-token: write # IMPORTANT: mandatory for trusted publishing
65+
66+
steps:
67+
- name: Download all the dists
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Publish distribution 📦 to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ examples/dask-worker-space/
1111
.pixi/
1212
examples/Cell_Colony.zarr/
1313
.idea/
14+
_version.py
1415

1516
# Byte-compiled / optimized / DLL files
1617
__pycache__/

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,9 @@ We use the standard [GitHub flow].
251251

252252
This section is relevant only for maintainers.
253253

254-
1. Pull `git`'s `main` branch.
255-
2. `pixi install -a`
256-
3. `pixi run pre-commit-install`
257-
4. `pixi run -e test test`
258-
5. `pixi shell`
259-
6. `hatch version <new-version>`
260-
7. `git add .`
261-
8. `git commit -m "ENH: Bump version to <version>"`
262-
9. `hatch build`
263-
10. `hatch publish`
264-
11. `git push upstream main`
265-
12. Create a new tag and Release via the GitHub UI. Auto-generate release notes
266-
and add additional notes as needed.
254+
Create a new tag and Release via the GitHub UI. Auto-generate release notes and
255+
add additional notes as needed. The version number is automatically updated via
256+
[hatch-vcs](https://hatch.pypa.io/latest/plugins/build/hooks/vcs/).
267257

268258
[spatial-image]: https://github.com/spatial-image/spatial-image
269259
[Xarray]: https://xarray.pydata.org/en/stable/

multiscale_spatial_image/__about__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

multiscale_spatial_image/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
"to_multiscale",
99
"itk_image_to_multiscale",
1010
"skip_non_dimension_nodes",
11-
"__version__",
1211
]
1312

14-
from .__about__ import __version__
1513
from .multiscale_spatial_image import MultiscaleSpatialImage
1614
from .to_multiscale import Methods, to_multiscale, itk_image_to_multiscale
1715
from .utils import skip_non_dimension_nodes

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
@@ -76,7 +76,10 @@ notebooks = [
7676
line-length = 88
7777

7878
[tool.hatch.version]
79-
path = "multiscale_spatial_image/__about__.py"
79+
source = "vcs"
80+
81+
[tool.hatch.build.hooks.vcs]
82+
version-file = "multiscale_spatial_image/_version.py"
8083

8184
[tool.pixi.workspace]
8285
channels = ["conda-forge"]

0 commit comments

Comments
 (0)