diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..da50a89 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +on: + push: + branches: [ main ] + tags: [ v* ] + pull_request: + branches: [ main ] + +name: Publish package +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: | + python -m pip install build + - name: Build a binary wheel and a source tarball + run: | + python -m build + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + if-no-files-found: error + name: python-artifacts + path: dist + + # This assumes a PyPI Trusted Publisher has been configured for the `pyorderly` package. + # See https://docs.pypi.org/trusted-publishers/ for more details. + publish-to-pypi: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + name: Publish Python distribution to PyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pyorderly + permissions: + # This permission is needed for the workflow to authenticate against PyPI + id-token: write + steps: + - name: Download the artifacts + uses: actions/download-artifact@v3 + with: + name: python-artifacts + path: dist/ + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index e60362a..0608c54 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,17 @@ checkout: hatch run pip install /path/to/outpack_server ``` +## Releasing + +- Increment the version number using [the `hatch version` command](https://hatch.pypa.io/latest/version/#updating). +- Commit the changes and create a PR. +- Get the PR approved and merged to main. +- Create a [GitHub release](https://github.com/mrc-ide/pyorderly/releases/new): + - Set the tag name as `vX.Y.Z`, matching the version reported by hatch. + - Write some release notes (possibly using the `Generate release notes` button). + - Publish the release! +- Sit back and relax while the release gets built and published. +- Check that the new version is available on [PyPI](https://pypi.org/project/pyorderly/#history). ## License diff --git a/src/pyorderly/__about__.py b/src/pyorderly/__about__.py index 1ad9aa8..4e4a009 100644 --- a/src/pyorderly/__about__.py +++ b/src/pyorderly/__about__.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: 2023-present Rich FitzJohn # # SPDX-License-Identifier: MIT -__version__ = "0.0.1" +__version__ = "0.1.0" __name__ = "pyorderly" diff --git a/src/pyorderly/outpack/filestore.py b/src/pyorderly/outpack/filestore.py index 82174ba..5990ff9 100644 --- a/src/pyorderly/outpack/filestore.py +++ b/src/pyorderly/outpack/filestore.py @@ -79,6 +79,11 @@ def onerror(func, path, _exc_info): if not os.access(path, os.W_OK): os.chmod(path, stat.S_IWUSR) func(path) + else: + # This is always called by rmtree from within a try-catch + # block, but the linter doesn't see that and complains about + # the argument-less `raise` statement. + raise # noqa: PLE0704 shutil.rmtree(self._path, onerror=onerror)