Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit 9e83cb5

Browse files
authored
update pypi publish workflow (#120)
1 parent 0a1ea52 commit 9e83cb5

File tree

2 files changed

+80
-15
lines changed

2 files changed

+80
-15
lines changed

.github/workflows/pypipublish.yaml

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,85 @@
1-
name: Upload Python Package
2-
1+
name: Build distribution
32
on:
43
release:
5-
types: [created]
4+
types:
5+
- published
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
616

717
jobs:
8-
deploy:
18+
build-artifacts:
19+
runs-on: ubuntu-latest
20+
if: github.repository == 'xarray-contrib/datatree'
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
25+
- uses: actions/setup-python@v2
26+
name: Install Python
27+
with:
28+
python-version: 3.8
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install build
34+
35+
- name: Build tarball and wheels
36+
run: |
37+
git clean -xdf
38+
git restore -SW .
39+
python -m build --sdist --wheel .
40+
41+
42+
- uses: actions/upload-artifact@v2
43+
with:
44+
name: releases
45+
path: dist
46+
47+
test-built-dist:
48+
needs: build-artifacts
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/setup-python@v2
52+
name: Install Python
53+
with:
54+
python-version: '3.10'
55+
- uses: actions/download-artifact@v2
56+
with:
57+
name: releases
58+
path: dist
59+
- name: List contents of built dist
60+
run: |
61+
ls -ltrh
62+
ls -ltrh dist
63+
64+
- name: Verify the built dist/wheel is valid
65+
if: github.event_name == 'push'
66+
run: |
67+
python -m pip install --upgrade pip
68+
python -m pip install dist/xarray-datatree*.whl
69+
python -c "import datatree; print(datatree.__version__)"
70+
71+
upload-to-pypi:
72+
needs: test-built-dist
73+
if: github.event_name == 'release'
974
runs-on: ubuntu-latest
1075
steps:
11-
- uses: actions/checkout@v3
12-
- name: Build distributions
13-
run: |
14-
$CONDA/bin/python -m pip install build
15-
$CONDA/bin/python -m build
16-
- name: Publish a Python distribution to PyPI
17-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
18-
uses: pypa/gh-action-pypi-publish@release/v1
19-
with:
20-
user: ${{ secrets.PYPI_USERNAME }}
21-
password: ${{ secrets.PYPI_PASSWORD }}
76+
- uses: actions/download-artifact@v2
77+
with:
78+
name: releases
79+
path: dist
80+
- name: Publish package to PyPI
81+
uses: pypa/[email protected]
82+
with:
83+
user: __token__
84+
password: ${{ secrets.PYPI_PASSWORD }}
85+
verbose: true

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ requires = [
44
"wheel",
55
"setuptools_scm[toml]>=3.4",
66
"setuptools_scm_git_archive",
7+
"check-manifest"
78
]
89

910
[tool.setuptools_scm]

0 commit comments

Comments
 (0)