diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 6310803f..8023b47e 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -1,45 +1,62 @@ name: Publish package to PyPI + on: push: tags: - - '*' + - "*" + jobs: publish: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 + steps: - - uses: actions/checkout@master - - name: Set up Python 3.9 - uses: actions/setup-python@v1 + - name: Checkout + uses: actions/checkout@v4 with: - python-version: 3.9 + fetch-depth: 0 # ensures full history/tags are available if you ever need them + + - name: Set up Python 3.13 + uses: actions/setup-python@v6 + with: + python-version: "3.13" + - name: Get release version + shell: bash run: | - echo "CHANGELOG_VERSION=$(cat CHANGELOG.md | grep -oP '(?<=###\s)(.*)(?=\s\-)' | head -n 1 | sed 's/Version\s/v/')" >> $GITHUB_ENV - echo "TAG_VERSION=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV + echo "CHANGELOG_VERSION=$(grep -oP '(?<=###\s)(.*)(?=\s\-)' CHANGELOG.md | head -n 1 | sed 's/Version\s/v/')" >> "$GITHUB_ENV" + echo "TAG_VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" + - name: Check changelog release version - if: ${{ env.TAG_VERSION != env.CHANGELOG_VERSION }} + shell: bash run: | - echo "CHANGELOG_VERSION($CHANGELOG_VERSION) is different from TAG_VERSION($TAG_VERSION)" - exit 1 + if [[ "${TAG_VERSION}" != "${CHANGELOG_VERSION}" ]]; then + echo "CHANGELOG_VERSION(${CHANGELOG_VERSION}) is different from TAG_VERSION(${TAG_VERSION})" + exit 1 + fi + - name: Install dependencies run: | python -m pip install --upgrade pip pip install build - - name: Get all git tags - run: git fetch --tags -f + - name: Build package run: | python -m build --sdist --wheel - - name: Get package size - run: echo "PKG_SIZE=$(find dist -maxdepth 1 -regex '.*gz' | xargs stat --format='%s')" >> $GITHUB_ENV - - name: Check package size - if: ${{ env.PKG_SIZE > 1e+8 }} + + - name: Check package size (100MB max) + shell: bash run: | - echo "PKG_SIZE($PKG_SIZE bytes) is greater than 100MB" - exit 1 + PKG_SIZE="$(find dist -maxdepth 1 -name '*.tar.gz' -print0 | xargs -0 stat --format='%s' | head -n 1)" + echo "PKG_SIZE=${PKG_SIZE}" >> "$GITHUB_ENV" + if [[ -n "${PKG_SIZE}" ]] && (( PKG_SIZE > 100000000 )); then + echo "PKG_SIZE(${PKG_SIZE} bytes) is greater than 100MB" + exit 1 + fi + - name: Publish package - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + if: startsWith(github.ref, 'refs/tags/') + uses: pypa/gh-action-pypi-publish@release/v1 with: - skip_existing: true + user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} + skip-existing: true diff --git a/CHANGELOG.md b/CHANGELOG.md index f4be3811..ea233ebe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ## Xarray-Spatial Changelog ----------- + +### Version 0.5.1 - 2025-12-16 +- updated runner, python setup action and checkout actions for PyPI publish + + ### Version 0.5.0 - 2025-12-15 - Python 3.14 is now supported! - Fixed bug in curvature dask+cupy args and added unit test for curvature(#824)