diff --git a/.github/workflows/pypipublish.yaml b/.github/workflows/pypipublish.yaml index 8703473..abf36b9 100644 --- a/.github/workflows/pypipublish.yaml +++ b/.github/workflows/pypipublish.yaml @@ -1,26 +1,85 @@ -name: Upload Python Package - +name: Build distribution on: release: - types: [created] + types: + - published + push: jobs: - deploy: + build-artifacts: runs-on: ubuntu-latest + if: github.repository == 'carbonplan/xarray-schema' steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3.1.0 + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v3 + name: Install Python with: - python-version: "3.x" + python-version: 3.9 + - 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 }} + python -m pip install setuptools setuptools-scm wheel twine check-manifest + + - name: Build tarball and wheels + run: | + git clean -xdf + git restore -SW . + python -m build --sdist --wheel . + + - name: Check built artifacts run: | - python setup.py sdist bdist_wheel - twine upload dist/* + python -m twine check dist/* + pwd + if [ -f dist/xarray-schema-unknown.tar.gz ]; then + echo "❌ INVALID VERSION NUMBER" + exit 1 + else + echo "✅ Looks good" + fi + - uses: actions/upload-artifact@v2 + with: + name: releases + path: dist + + test-built-dist: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v3 + name: Install Python + with: + python-version: 3.9 + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + - name: List contents of built dist + run: | + ls -ltrh + ls -ltrh dist + + - name: Verify the built dist/wheel is valid + if: github.event_name == 'push' + run: | + python -m pip install --upgrade pip + python -m pip install dist/xarray_schema*.whl + python -c "import xarray_schema; print(xarray_schema.__version__)" + + upload-to-pypi: + needs: test-built-dist + if: github.event_name == 'release' + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + verbose: true diff --git a/requirements.txt b/requirements.txt index 3215cff..36846b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ xarray>=0.16 -numpy>=1.20 +numpy>=1.21 diff --git a/xarray_schema/types.py b/xarray_schema/types.py index d2bacb7..bd76b89 100644 --- a/xarray_schema/types.py +++ b/xarray_schema/types.py @@ -1,8 +1,7 @@ from typing import Dict, Tuple, Union -import numpy as np +from numpy.typing import DTypeLike # noqa: F401 -DTypeLike = np.typing.DTypeLike DimsT = Tuple[Union[str, None]] ShapeT = Tuple[Union[int, None]] ChunksT = Union[bool, Dict[str, Union[int, None]]]