Skip to content
Snippets Groups Projects
Commit 52f63c77 authored by Adam Williamson's avatar Adam Williamson Committed by Adam Williamson
Browse files

Add a GitHub Actions-based release workflow

This is based on
https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#defining-a-workflow-job-environment
. It's the sample config from there, with versions updated and
our project name substituted in the appropriate places. I dropped
the publish-to-testpypi bit because of
https://github.com/pypa/packaging.python.org/issues/804

 , and left
the Github release part left out for now. We can add that later if
we like, but we never published releases to Github before, so it
doesn't seem required yet. I also tweaked the conditionals a bit
to avoid running the build job on forks and publish only tags
that start with 'v', as that's our convention for versions.

Signed-off-by: default avatarAdam Williamson <awilliam@redhat.com>
parent 087eb657
No related branches found
No related tags found
No related merge requests found
name: Build and publish Python distribution to PyPI and TestPyPI
on: push
jobs:
build:
name: Build distribution
if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on version tag pushes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5.1.0
with:
python-version: "3.x"
- name: Install pypa/build
run: python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish Python distribution to PyPI
if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on version tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/mwclient
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
...@@ -109,3 +109,18 @@ When it is ready, push your branch to your remote: ...@@ -109,3 +109,18 @@ When it is ready, push your branch to your remote:
Then you can open a pull request on GitHub. You should see a URL to do this Then you can open a pull request on GitHub. You should see a URL to do this
when you push your branch. when you push your branch.
Making a release
----------------
These instructions are for maintainers of the project.
To cut a release, ensure ``CHANGELOG.md`` is updated, then use
`bump-my-version <https://callowayproject.github.io/bump-my-version/>`_:
.. code:: bash
$ pip install bump-my-version
$ bump-my-version bump major|minor|patch
Then check the commit looks correct and is tagged vX.Y.Z, and push. The
``.github/workflows/release.yml`` action will publish to PyPI.
...@@ -10,7 +10,9 @@ needs_pytest = set(['pytest', 'test', 'ptr']).intersection(sys.argv) ...@@ -10,7 +10,9 @@ needs_pytest = set(['pytest', 'test', 'ptr']).intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else [] pytest_runner = ['pytest-runner'] if needs_pytest else []
setup(name='mwclient', setup(name='mwclient',
version='0.10.1', # Use bumpversion to update # See https://mwclient.readthedocs.io/en/latest/development/#making-a-release
# for how to update this field and release a new version.
version='0.10.1',
description='MediaWiki API client', description='MediaWiki API client',
long_description=README, long_description=README,
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment