Skip to content

Commit 6e182b6

Browse files
committed
add GHA PyPI
1 parent 5fd7515 commit 6e182b6

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/pypi.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
pull_request:
5+
push:
6+
release:
7+
types:
8+
- published
9+
10+
jobs:
11+
pypi-publish:
12+
name: Upload release to PyPI
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/xarray_subset_grid/
17+
permissions:
18+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
19+
steps:
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
# Should be enough for setuptools-scm
23+
fetch-depth: 100
24+
persist-credentials: false
25+
26+
- name: Get tags
27+
run: git fetch origin 'refs/tags/*:refs/tags/*'
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
31+
with:
32+
python-version: "3.x"
33+
34+
- name: Install build tools
35+
run: |
36+
python -m pip install --upgrade pip build twine
37+
38+
- name: Build binary wheel
39+
run: python -m build --sdist --wheel . --outdir dist
40+
41+
- name: CheckFiles
42+
run: |
43+
ls -lh dist
44+
45+
- name: Test wheels
46+
run: |
47+
cd dist && python -m pip install xarray_subset_grid*.whl
48+
python -m twine check *
49+
50+
- name: Publish package distributions to PyPI
51+
if: success() && github.event_name == 'release'
52+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

0 commit comments

Comments
 (0)