Skip to content

Commit 9b28958

Browse files
committed
workflow to publish to pypi
1 parent bd810fa commit 9b28958

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/pypi.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions: {}
8+
9+
jobs:
10+
build:
11+
name: Build packages
12+
runs-on: ubuntu-latest
13+
if: github.owner == 'xarray-contrib'
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: false
20+
- name: Set up Python
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: "3.x"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install build twine
28+
- name: Build
29+
run: |
30+
python -m build --outdir dist/ .
31+
- name: Check the built archives
32+
run: |
33+
twine check dist/*
34+
pip install dist/*.whl
35+
minimum-versions --help
36+
- name: Upload build artifacts
37+
uses: actions/upload-artifact@v5
38+
with:
39+
name: packages
40+
path: dist/*
41+
42+
publish:
43+
name: Upload to PyPI
44+
runs-on: ubuntu-latest
45+
needs: build
46+
if: github.event_name == 'release'
47+
48+
environment:
49+
name: pypi
50+
url: https://pypi.org/p/xarray-minimum-dependency-policy
51+
permissions:
52+
id-token: write
53+
54+
steps:
55+
- name: Download build artifacts
56+
uses: actions/download-artifact@v6
57+
with:
58+
name: packages
59+
path: dist/
60+
61+
- name: Publish to PyPI
62+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
63+
with:
64+
verify_metadata: true
65+
verbose: true

0 commit comments

Comments
 (0)