Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/create-release.yml

This file was deleted.

79 changes: 71 additions & 8 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,37 @@ on:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Publish distributions to PyPI
name: Publish distributions

jobs:
build-and-publish:
name: Build and Publish
release-notes:
name: Extract release notes from HISTORY.md
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Extract section for this version
run: |
ver='${{ github.ref_name }}'
ver="${ver#v}"
awk -v ver="$ver" '
$0 ~ "^## " ver "( |$)" { found = 1; next }
found && /^## / { exit }
found { print }
' HISTORY.md > notes.md
if [ ! -s notes.md ]; then
echo "No section for $ver found in HISTORY.md; finalize HISTORY.md before tagging." >&2
exit 1
fi
cat notes.md
- uses: actions/upload-artifact@v4
with:
name: release-notes
path: notes.md

build:
name: Build distributions
needs: release-notes
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.14
Expand All @@ -21,12 +45,51 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -U build twine
- name: Build and check source tarball
- name: Build sdist and wheel
run: python -m build
- name: Twine check
run: twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment: release-the-hounds
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Draft GitHub release
needs: [build, publish-pypi]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: actions/download-artifact@v4
with:
name: release-notes
- name: Create draft release
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
GH_TOKEN: ${{ github.token }}
run: >-
gh release create '${{ github.ref_name }}'
--repo '${{ github.repository }}'
--draft
--title 'Release ${{ github.ref_name }}'
--notes-file notes.md
dist/*
68 changes: 48 additions & 20 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,22 @@ Ready to contribute? Here's how to set up `yt_xarray` for local development.
$ git clone git@github.com:your_name_here/yt_xarray.git


3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
3. Install your local copy into a virtual environment. Using a plain `venv`
(any other environment manager works just as well)::

$ mkvirtualenv yt_xarray
$ cd yt_xarray/
$ python -m pip install -e .
$ python -m pip install -r requirements_dev.txt
$ python -m venv .venv
$ source .venv/bin/activate
$ python -m pip install -e ".[full,test]"

4. (optional) Setup pre-commit::
The `full` extra pulls in the optional runtime dependencies (netCDF4, scipy,
dask, cf_xarray) and `test` adds pytest and friends. To also run the type
checker locally, use ``".[typecheck]"`` instead, which includes both.

4. (optional) Setup pre-commit. The hooks run `ruff check --fix` and
`ruff format`, the same checks that pre-commit.ci runs on pull requests::

$ python -m pip install pre-commit
$ pre-commit install

5. Create a branch for local development::
Expand All @@ -84,9 +91,15 @@ Now you can make your changes locally.
tests::


$ pytest
$ pytest yt_xarray

7. (optional) Run the type checker. This requires the `typecheck` extra from
step 3 and is also run by CI on pull requests::


$ mypy yt_xarray

7. Commit your changes and push your branch to GitHub::
8. Commit your changes and push your branch to GitHub::


$ git add .
Expand All @@ -101,7 +114,7 @@ Now your branch is ready to push::

$ git push origin name-of-your-bugfix-or-feature

8. Submit a pull request through the GitHub website.
9. Submit a pull request through the GitHub website.

Pull Request Guidelines
#######################
Expand All @@ -118,7 +131,8 @@ Tips

To run a subset of tests::

$ pytest tests.test_yt_xarray
$ pytest yt_xarray/tests/test_accesor.py
$ pytest yt_xarray/tests/test_accesor.py::test_name


Deploying
Expand All @@ -128,28 +142,42 @@ A reminder for the maintainers on how to deploy.

First, make sure that:

* all your changes are committed (including an entry in HISTORY.md).
* all your changes are committed.
* the version in `yt_xarray/__init__.py` matches the version you are releasing.

Then, double check your `main` branch mactches upstream (assuming that `git remote -v` lists
* HISTORY.md is finalized and merged into `main` **before** you tag: the tagged
commit must contain a ``## <version>`` heading (without the leading ``v``,
e.g. ``## 1.1.2``) with the release notes for this version. The release
workflow reads HISTORY.md from the tagged commit and fails before building
any wheels if that section is missing or empty, so a leftover
``## 1.1.2dev`` heading will stop the release.

Then, double check your `main` branch matches upstream (assuming that `git remote -v` lists
`git@github.com:data-exp-lab/yt_xarray.git` as the upstream repo)::

$ git fetch --all
$ git checkout main
$ git rebase upstream/main

And then create a tag for your new release. For example, if you are releasing
version `1.1.2`::
Confirm that HISTORY.md at this commit has the finalized ``## 1.1.2`` section
(if not, fix it, merge it, and rebase again before continuing). Then create a
tag for your new release. For example, if you are releasing version `1.1.2`::


$ git tav v1.1.2
$ git tag v1.1.2

Now push that tag to the upstream repo::

$ git push upstream v1.1.2

This will trigger a number of automated Github actions that include an
automated push to PyPI (if tests pass) and the creation of a draft release
on Github. Wait for the push to PyPI to finish then go edit the draft release
that should be visible at https://github.com/data-exp-lab/yt_xarray/releases and
hit publish after editing release notes.
This triggers a single Github action (`.github/workflows/publish-to-pypi.yml`)
that runs the following jobs in order:

1. extract the release notes for this version from HISTORY.md (fails if missing).
2. build the sdist and wheel and run `twine check`.
3. publish the distributions to PyPI via trusted publishing.
4. create a draft release on Github with the HISTORY.md section as the body and
the sdist and wheel attached as assets.

The draft is only created if the PyPI upload succeeds. Once the action finishes,
go to https://github.com/data-exp-lab/yt_xarray/releases, review the draft, and
hit publish.
Loading