From e42965ad6d8e1aba16ff666966afbe4573f08d08 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 10 Jun 2025 10:55:47 -0600 Subject: [PATCH 1/7] Add typing_extensions to dependencies. --- pyproject.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c980c204b5f..c9d0eee7f06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,12 @@ name = "xarray" readme = "README.md" requires-python = ">=3.10" -dependencies = ["numpy>=1.24", "packaging>=23.2", "pandas>=2.1"] +dependencies = [ + "numpy>=1.24", + "packaging>=23.2", + "pandas>=2.1", + "typing_extensions>=4.8", +] # We don't encode minimum requirements here (though if we can write a script to # generate the text from `min_deps_check.py`, that's welcome...). We do add From 3bc922fc1bca33a242b6c60ebafdf163f02a5774 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 10 Jun 2025 11:10:10 -0600 Subject: [PATCH 2/7] Add test PyPi action --- .github/workflows/test-pypi-release.yaml | 90 ++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/test-pypi-release.yaml diff --git a/.github/workflows/test-pypi-release.yaml b/.github/workflows/test-pypi-release.yaml new file mode 100644 index 00000000000..2e599048f98 --- /dev/null +++ b/.github/workflows/test-pypi-release.yaml @@ -0,0 +1,90 @@ +name: Test PyPI build and upload +on: + pull_request: + types: [opened, reopened, synchronize, labeled] + workflow_dispatch: + +jobs: + build-artifacts: + runs-on: ubuntu-latest + if: ${{ contains( github.event.pull_request.labels.*.name, 'Release') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'}} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build twine + + - name: Build tarball and wheels + run: | + git clean -xdf + git restore -SW . + python -m build + + - name: Check built artifacts + run: | + python -m twine check --strict dist/* + pwd + if [ -f dist/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 + + test-built-dist: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: "3.12" + - uses: actions/download-artifact@v4 + 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*.whl + python -m xarray.util.print_versions + + upload-to-test-pypi: + needs: test-built-dist + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://test.pypi.org/p/xarray + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v4 + with: + name: releases + path: dist + - name: Publish package to TestPyPI + if: github.event_name == 'push' + uses: pypa/gh-action-pypi-publish@v1.12.4 + with: + repository_url: https://test.pypi.org/legacy/ + verbose: true From 1948908b7a1cbca2ee9be6cb35edcbc89d6cb488 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 10 Jun 2025 11:14:01 -0600 Subject: [PATCH 3/7] Add to HOW_TO_RELEASE --- HOW_TO_RELEASE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HOW_TO_RELEASE.md b/HOW_TO_RELEASE.md index d4ca0d9c2af..06550131881 100644 --- a/HOW_TO_RELEASE.md +++ b/HOW_TO_RELEASE.md @@ -48,6 +48,8 @@ upstream https://github.com/pydata/xarray (push) release. 5. Open a PR with the release summary and whatsnew changes; in particular the release headline should get feedback from the team on what's important to include. + Apply the `Release` label to the PR to trigger a test build action, and upload to TestPyPI. + 6. After merging, again ensure your main branch is synced to upstream: ```sh git pull upstream main From 538f811d121e479f229f954550c0a5cd5e54f1df Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 11 Jun 2025 06:34:35 -0600 Subject: [PATCH 4/7] Revert "Add typing_extensions to dependencies." This reverts commit e42965ad6d8e1aba16ff666966afbe4573f08d08. --- pyproject.toml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c9d0eee7f06..c980c204b5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,12 +19,7 @@ name = "xarray" readme = "README.md" requires-python = ">=3.10" -dependencies = [ - "numpy>=1.24", - "packaging>=23.2", - "pandas>=2.1", - "typing_extensions>=4.8", -] +dependencies = ["numpy>=1.24", "packaging>=23.2", "pandas>=2.1"] # We don't encode minimum requirements here (though if we can write a script to # generate the text from `min_deps_check.py`, that's welcome...). We do add From bee65b90ab4ee065947a102d9f8cf45574bd6cf7 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 11 Jun 2025 06:39:54 -0600 Subject: [PATCH 5/7] edit workflow --- .github/workflows/pypi-release.yaml | 1 - .github/workflows/test-pypi-release.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index add9261fcaf..53a905e8a60 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -64,7 +64,6 @@ jobs: 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*.whl diff --git a/.github/workflows/test-pypi-release.yaml b/.github/workflows/test-pypi-release.yaml index 2e599048f98..6e23271948a 100644 --- a/.github/workflows/test-pypi-release.yaml +++ b/.github/workflows/test-pypi-release.yaml @@ -61,7 +61,6 @@ jobs: 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*.whl From c5fdd1b021e36466b71f640bae58e677b23fe73e Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 11 Jun 2025 06:48:37 -0600 Subject: [PATCH 6/7] more complex release --- .github/workflows/pypi-release.yaml | 10 ++- .github/workflows/test-pypi-release.yaml | 89 ------------------------ HOW_TO_RELEASE.md | 2 +- 3 files changed, 10 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/test-pypi-release.yaml diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 53a905e8a60..9df929d2cfd 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -6,11 +6,19 @@ on: push: tags: - "v*" + pull_request: + types: [opened, reopened, synchronize, labeled] + workflow_dispatch: jobs: build-artifacts: runs-on: ubuntu-latest - if: github.repository == 'pydata/xarray' + if: ${{ github.repository == 'pydata/xarray' && ( + (contains(github.event.pull_request.labels.*.name, 'Release') && github.event_name == 'pull_request') || + github.event_name == 'release' || + github.event_name == 'workflow_dispatch' || + startsWith(github.ref, 'refs/tags/v') + ) }} steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/test-pypi-release.yaml b/.github/workflows/test-pypi-release.yaml deleted file mode 100644 index 6e23271948a..00000000000 --- a/.github/workflows/test-pypi-release.yaml +++ /dev/null @@ -1,89 +0,0 @@ -name: Test PyPI build and upload -on: - pull_request: - types: [opened, reopened, synchronize, labeled] - workflow_dispatch: - -jobs: - build-artifacts: - runs-on: ubuntu-latest - if: ${{ contains( github.event.pull_request.labels.*.name, 'Release') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'}} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: "3.12" - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install build twine - - - name: Build tarball and wheels - run: | - git clean -xdf - git restore -SW . - python -m build - - - name: Check built artifacts - run: | - python -m twine check --strict dist/* - pwd - if [ -f dist/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 - - test-built-dist: - needs: build-artifacts - runs-on: ubuntu-latest - steps: - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: "3.12" - - uses: actions/download-artifact@v4 - 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 - run: | - python -m pip install --upgrade pip - python -m pip install dist/xarray*.whl - python -m xarray.util.print_versions - - upload-to-test-pypi: - needs: test-built-dist - runs-on: ubuntu-latest - - environment: - name: pypi - url: https://test.pypi.org/p/xarray - permissions: - id-token: write - - steps: - - uses: actions/download-artifact@v4 - with: - name: releases - path: dist - - name: Publish package to TestPyPI - if: github.event_name == 'push' - uses: pypa/gh-action-pypi-publish@v1.12.4 - with: - repository_url: https://test.pypi.org/legacy/ - verbose: true diff --git a/HOW_TO_RELEASE.md b/HOW_TO_RELEASE.md index 06550131881..e775d63871d 100644 --- a/HOW_TO_RELEASE.md +++ b/HOW_TO_RELEASE.md @@ -48,7 +48,7 @@ upstream https://github.com/pydata/xarray (push) release. 5. Open a PR with the release summary and whatsnew changes; in particular the release headline should get feedback from the team on what's important to include. - Apply the `Release` label to the PR to trigger a test build action, and upload to TestPyPI. + Apply the `Release` label to the PR to trigger a test build action. 6. After merging, again ensure your main branch is synced to upstream: ```sh From 15cb00acdd744bc614c3a7d0813144639592aa3f Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Wed, 2 Jul 2025 21:12:31 -0600 Subject: [PATCH 7/7] lint --- .github/workflows/pypi-release.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 9df929d2cfd..55be8059306 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -14,11 +14,11 @@ jobs: build-artifacts: runs-on: ubuntu-latest if: ${{ github.repository == 'pydata/xarray' && ( - (contains(github.event.pull_request.labels.*.name, 'Release') && github.event_name == 'pull_request') || - github.event_name == 'release' || - github.event_name == 'workflow_dispatch' || - startsWith(github.ref, 'refs/tags/v') - ) }} + (contains(github.event.pull_request.labels.*.name, 'Release') && github.event_name == 'pull_request') || + github.event_name == 'release' || + github.event_name == 'workflow_dispatch' || + startsWith(github.ref, 'refs/tags/v') + ) }} steps: - uses: actions/checkout@v4 with: