-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
5 changed files
with
110 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters