Skip to content

Commit 104f96e

Browse files
add deploy to pypi (#236)
* add deploy to pypi * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * use hatch to build/deploy * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add hatch build options * Update pyproject.toml * add hatch-vcs * make version dynamic --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 012c815 commit 104f96e

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Test
33
on:
44
push:
55
branches: [main]
6+
tags:
7+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
68
pull_request:
79
branches: [main]
810

@@ -60,3 +62,29 @@ jobs:
6062
with:
6163
name: coverage
6264
verbose: true
65+
deploy:
66+
# this will run when you have tagged a commit, starting with "v*"
67+
# and requires that you have put your twine API key in your
68+
# github secrets (see readme for details)
69+
needs: [test]
70+
runs-on: ubuntu-latest
71+
if: contains(github.ref, 'tags')
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v3
75+
76+
- name: Set up Python 3.10
77+
uses: actions/setup-python@v4
78+
with:
79+
python-version: "3.10"
80+
81+
- name: Install hatch
82+
run: pip install hatch
83+
84+
- name: Build project for distribution
85+
run: hatch build
86+
87+
- name: Publish a Python distribution to PyPI
88+
uses: pypa/gh-action-pypi-publish@release/v1
89+
with:
90+
password: ${{ secrets.PYPI_API_TOKEN }}

pyproject.toml

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

55

66
[project]
@@ -15,8 +15,10 @@ maintainers = [
1515
urls.Documentation = "https://spatialdata.readthedocs.io/"
1616
urls.Source = "https://github.com/scverse/spatialdata.git"
1717
urls.Home-page = "https://github.com/scverse/spatialdata.git"
18-
version = "0.0.1.dev1"
1918
requires-python = ">=3.9"
19+
dynamic= [
20+
"version" # allow version to be set by git tags
21+
]
2022
license = {file = "LICENSE"}
2123
readme = "README.md"
2224
dependencies = [
@@ -112,6 +114,15 @@ exclude = '''
112114
[tool.jupytext]
113115
formats = "ipynb,md"
114116

117+
[tool.hatch.build.targets.wheel]
118+
packages = ['src/spatialdata']
119+
120+
[tool.hatch.version]
121+
source = "vcs"
122+
123+
[tool.hatch.build.hooks.vcs]
124+
version-file = "_version.py"
125+
115126
[tool.hatch.metadata]
116127
allow-direct-references = true
117128

0 commit comments

Comments
 (0)