diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 08c38a69..57e99808 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -2,31 +2,66 @@ name: Upload Package to PyPI on: release: - types: [created] + types: + - published jobs: - deploy: + build-artifacts: runs-on: ubuntu-latest if: github.repository == 'xarray-contrib/pint-xarray' steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 with: - python-version: '3.x' + fetch-depth: 0 + + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: "3.x" + - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install build twine - - name: Build + + - name: Build tarball and wheels run: | - python -m build --sdist --wheel --outdir dist/ . - - name: Check the built archives + git clean -xdf + git restore -SW . + python -m build --outdir dist/ . + + - name: Check built artifacts run: | - twine check dist/* - - name: Publish to PyPI + python -m twine check --strict dist/* + pwd + if [ -f dist/pint-xarray-0.0.0.tar.gz ]; then + echo "❌ INVALID VERSION NUMBER" + exit 1 + else + echo "✅ Looks good" + fi + - uses: actions/upload-artifact@v4 + with: + name: releases + path: dist + + upload-to-pypi: + needs: build-artifacts + if: github.event_name == 'release' + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://pypi.org/p/pint-xarray + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v4 + with: + name: releases + path: dist + - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 with: - user: __token__ - password: ${{ secrets.pypi_password }} - repository_url: https://upload.pypi.org/legacy/ + verbose: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e21d23e..9da55995 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,6 @@ repos: - repo: https://github.com/psf/black rev: 24.4.2 hooks: - - id: black - id: black-jupyter - repo: https://github.com/keewis/blackdoc rev: v0.3.9