diff --git a/.github/workflows/pythonpublish.yaml b/.github/workflows/pythonpublish.yaml index 977264a4..1e6d940f 100644 --- a/.github/workflows/pythonpublish.yaml +++ b/.github/workflows/pythonpublish.yaml @@ -1,5 +1,11 @@ name: Build and Upload xmip to PyPI on: + push: + branches: + - "main" + pull_request: + branches: + - "*" release: types: - published @@ -12,82 +18,25 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 - name: Install Python + - name: Set up Python + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: "3.x" - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install setuptools setuptools-scm[toml] wheel twine - - name: Check python version + python -m pip install --upgrade setuptools setuptools-scm build twine + - name: Build only + if: github.event_name != 'release' run: | - python --version - - name: Check current package version + python -m build + twine check dist/* + - name: Build and publish + if: github.event_name == 'release' + env: + TWINE_USERNAME: "__token__" + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - python setup.py --version - - name: Build tarball and wheels - run: | - git clean -xdf - git restore -SW . - python setup.py sdist bdist_wheel - - name: Check built artifacts - run: | - python -m twine check dist/* - pwd - if [ -f dist/xmip-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 - test-built-dist: - needs: build-artifacts - runs-on: ubuntu-latest - steps: - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: 3.8 - - uses: actions/download-artifact@v4 - with: - name: releases - path: dist - - name: List contents of built dist - run: | - ls -ltrh - ls -ltrh dist - upload-to-testpypi: - needs: test-built-dist - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v4 - with: - name: releases - path: dist - - name: Publish package to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.8.14 - with: - user: __token__ - repository_url: https://test.pypi.org/legacy/ - password: ${{ secrets.TESTPYPI_TOKEN }} - verbose: true - upload-to-pypi: - needs: upload-to-testpypi - if: "!github.event.release.prerelease" - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v4 - with: - name: releases - path: dist - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.14 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} - verbose: true + python -m build + twine check dist/* + twine upload dist/* diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 748e3dd6..1089a16b 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -11,6 +11,7 @@ Internal Changes ~~~~~~~~~~~~~~~~ - Add `longitude_bnds` and `latitude_bnds` to `cmip_renaming_dict` (:pull:`300`). By `Joran Angevaare ` - Updated pre-commit linting to use ruff (:pull:`359`). By `Julius Busecke ` +- Modernized packaging workflow, that runs on each PR (:pull:`361`). By `Julius Busecke ` - Added 'nvertices' -> 'vertex' to renaming preprocessor (:pull:`357`). By `Julius Busecke ` .. _whats-new.0.7.2: