Skip to content

Commit 9d09885

Browse files
authored
Use PyPI's trusted publisher system (#218)
* Use PyPI's trusted publisher system Also build and check wheels and sdists on main and PRs. Closes #217 * Add manifest to control inclusion into wheel and sdist * Migrate setup.py to pyproject.toml
1 parent e26418f commit 9d09885

File tree

5 files changed

+110
-69
lines changed

5 files changed

+110
-69
lines changed

.github/workflows/pypipublish.yaml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
1-
name: Upload Python Package
1+
name: Build Python distribution and upload to PyPI on release
22

33
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
48
release:
5-
types: [created]
9+
types:
10+
- published
611

712
jobs:
813
deploy:
14+
name: Build and Publish
915
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
1018
steps:
1119
- uses: actions/checkout@v3
20+
1221
- name: Set up Python
1322
uses: actions/setup-python@v4
1423
with:
1524
python-version: "3.x"
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
python -m pip install setuptools setuptools-scm wheel twine
20-
- name: Build and publish
21-
env:
22-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
25+
26+
- name: Install build tools
2427
run: |
25-
python setup.py sdist bdist_wheel
26-
twine upload dist/*
28+
python -m pip install --upgrade build
29+
30+
- name: Build binary wheel
31+
run: python -m build --sdist --wheel . --outdir dist
32+
33+
- name: Check files
34+
run: >
35+
ls dist
36+
&& python -m pip install --upgrade check-manifest
37+
&& check-manifest --verbose
38+
39+
- name: Test wheels
40+
run: >
41+
cd dist
42+
&& python -m pip install *.whl
43+
&& python -m pip install --upgrade build twine
44+
&& python -m twine check *
45+
46+
- name: Publish a Python distribution to PyPI
47+
if: success() && github.event_name == 'release'
48+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ share/python-wheels/
2626
.installed.cfg
2727
*.egg
2828
MANIFEST
29+
xpublish/_version.py
2930

3031
# PyInstaller
3132
# Usually these files are written by a python script from a template

MANIFEST.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include *.txt
2+
include README.md
3+
include pyproject.toml
4+
5+
graft xpublish
6+
7+
prune docs
8+
prune tests
9+
prune notebooks
10+
prune *.egg-info
11+
12+
global-exclude *.nc
13+
14+
exclude .pre-commit-config.yaml
15+
exclude *.yml
16+
exclude *.enc
17+
exclude .gitignore
18+
exclude .binder/*
19+
exclude .coveragerc
20+
exclude .readthedocs.yml
21+
exclude **/*.ipynb
22+
exclude **/*.pyc

pyproject.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools>=42",
5+
"setuptools_scm[toml]>=6.2",
6+
]
7+
8+
[project]
9+
name = "xpublish"
10+
description = "Publish Xarray Datasets via a REST API."
11+
readme = "README.md"
12+
keywords = [
13+
'api',
14+
'xarray',
15+
'zarr',
16+
]
17+
license = { file = "LICENSE" }
18+
maintainers = [
19+
{ name = "Joe Hamman", email = "[email protected]" },
20+
{ name = "Alex Kerney", email = "[email protected]" },
21+
]
22+
requires-python = ">=3.9"
23+
classifiers = [
24+
'Development Status :: 4 - Beta',
25+
'Intended Audience :: Science/Research',
26+
'License :: OSI Approved :: MIT License',
27+
'Operating System :: OS Independent',
28+
'Programming Language :: Python',
29+
'Programming Language :: Python :: 3 :: Only',
30+
'Programming Language :: Python :: 3.9',
31+
'Programming Language :: Python :: 3.10',
32+
'Programming Language :: Python :: 3.11',
33+
'Topic :: Scientific/Engineering',
34+
]
35+
dynamic = [
36+
"dependencies",
37+
"version",
38+
]
39+
[project.urls]
40+
"documentation" = "https://xpublish.readthedocs.io/"
41+
"repository" = "https://github.com/xpublish-community/xpublish"
42+
[project.entry-points."xpublish.plugin"]
43+
dataset_info = "xpublish.plugins.included.dataset_info:DatasetInfoPlugin"
44+
module_version = "xpublish.plugins.included.module_version:ModuleVersionPlugin"
45+
plugin_info = "xpublish.plugins.included.plugin_info:PluginInfoPlugin"
46+
zarr = "xpublish.plugins.included.zarr:ZarrPlugin"
47+
48+
[tool.setuptools.dynamic]
49+
dependencies = { file = ["requirements.txt"] }
50+
51+
[tool.setuptools_scm]
52+
version_scheme = "post-release"
53+
local_scheme = "dirty-tag"
154

255
[tool.black]
356
line-length = 100

setup.py

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

0 commit comments

Comments
 (0)