Skip to content

Commit

Permalink
Publish to PyPI. (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar authored Aug 20, 2024
1 parent 486c4cd commit 0facc71
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/pyorderly/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2023-present Rich FitzJohn <r.fitzjohn@imperial.ac.uk>
#
# SPDX-License-Identifier: MIT
__version__ = "0.0.1"
__version__ = "0.1.0"
__name__ = "pyorderly"
5 changes: 5 additions & 0 deletions src/pyorderly/outpack/filestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0facc71

Please sign in to comment.