Skip to content

Commit cd81592

Browse files
PythonFZclaude
andauthored
build: switch to hatchling + hatch-vcs and add PyPI publish workflow (#15)
Replace uv_build with hatchling/hatch-vcs for automatic git-tag versioning. Add GitHub Actions workflow for publishing to PyPI on release via trusted publishing. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4ae859c commit cd81592

4 files changed

Lines changed: 55 additions & 5 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
build:
11+
name: Build distribution
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
- uses: astral-sh/setup-uv@v5
18+
- name: Build sdist and wheel
19+
run: uv build
20+
- name: Upload artifacts
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: dist
24+
path: dist/*
25+
26+
upload_pypi:
27+
needs: [build]
28+
environment:
29+
name: pypi
30+
url: https://pypi.org/p/asebytes
31+
permissions:
32+
id-token: write
33+
runs-on: ubuntu-latest
34+
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'published')
35+
steps:
36+
- name: Download all artifacts
37+
uses: actions/download-artifact@v4
38+
with:
39+
name: dist
40+
path: dist
41+
- name: Publish to PyPI
42+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ benchmark_results.json
1919

2020
# Git worktrees
2121
.worktrees/
22+
23+
# hatch-vcs generated version file
24+
src/asebytes/_version.py

pyproject.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "asebytes"
3-
version = "0.3.0"
3+
dynamic = ["version"]
44
description = "Fast binary serialization and storage for ASE Atoms."
55
authors = [
66
{ name = "Fabian Zills", email = "fzills@icp.uni-stuttgart.de" },
@@ -15,8 +15,8 @@ dependencies = [
1515
]
1616

1717
[build-system]
18-
requires = ["uv_build>=0.9.6,<0.10.0"]
19-
build-backend = "uv_build"
18+
requires = ["hatchling", "hatch-vcs"]
19+
build-backend = "hatchling.build"
2020

2121
[dependency-groups]
2222
dev = [
@@ -62,6 +62,12 @@ redis = [
6262
"redis>=5.0",
6363
]
6464

65+
[tool.hatch.version]
66+
source = "vcs"
67+
68+
[tool.hatch.build.hooks.vcs]
69+
version-file = "src/asebytes/_version.py"
70+
6571
[tool.pytest.ini_options]
6672
testpaths = ["tests"]
6773
python_files = ["test_*.py"]

uv.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)