Skip to content

Commit

Permalink
Use PyPI's trusted publisher system (#218)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
abkfenris authored Jul 21, 2023
1 parent e26418f commit 9d09885
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 69 deletions.
46 changes: 34 additions & 12 deletions .github/workflows/pypipublish.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
name: Upload Python Package
name: Build Python distribution and upload to PyPI on release

on:
pull_request:
push:
branches:
- main
release:
types: [created]
types:
- published

jobs:
deploy:
name: Build and Publish
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools setuptools-scm wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

- name: Install build tools
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
python -m pip install --upgrade build
- name: Build binary wheel
run: python -m build --sdist --wheel . --outdir dist

- name: Check files
run: >
ls dist
&& python -m pip install --upgrade check-manifest
&& check-manifest --verbose
- name: Test wheels
run: >
cd dist
&& python -m pip install *.whl
&& python -m pip install --upgrade build twine
&& python -m twine check *
- name: Publish a Python distribution to PyPI
if: success() && github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
xpublish/_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
22 changes: 22 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include *.txt
include README.md
include pyproject.toml

graft xpublish

prune docs
prune tests
prune notebooks
prune *.egg-info

global-exclude *.nc

exclude .pre-commit-config.yaml
exclude *.yml
exclude *.enc
exclude .gitignore
exclude .binder/*
exclude .coveragerc
exclude .readthedocs.yml
exclude **/*.ipynb
exclude **/*.pyc
53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=42",
"setuptools_scm[toml]>=6.2",
]

[project]
name = "xpublish"
description = "Publish Xarray Datasets via a REST API."
readme = "README.md"
keywords = [
'api',
'xarray',
'zarr',
]
license = { file = "LICENSE" }
maintainers = [
{ name = "Joe Hamman", email = "jhamman@ucar.edu" },
{ name = "Alex Kerney", email = "akerney@gmri.org" },
]
requires-python = ">=3.9"
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Scientific/Engineering',
]
dynamic = [
"dependencies",
"version",
]
[project.urls]
"documentation" = "https://xpublish.readthedocs.io/"
"repository" = "https://github.com/xpublish-community/xpublish"
[project.entry-points."xpublish.plugin"]
dataset_info = "xpublish.plugins.included.dataset_info:DatasetInfoPlugin"
module_version = "xpublish.plugins.included.module_version:ModuleVersionPlugin"
plugin_info = "xpublish.plugins.included.plugin_info:PluginInfoPlugin"
zarr = "xpublish.plugins.included.zarr:ZarrPlugin"

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "dirty-tag"

[tool.black]
line-length = 100
Expand Down
57 changes: 0 additions & 57 deletions setup.py

This file was deleted.

0 comments on commit 9d09885

Please sign in to comment.