Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run a publish workflow on Pypi #3328

Merged
merged 6 commits into from
Dec 21, 2023
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
65 changes: 65 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on:
push:
tags:
- '*'

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"

- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Print environment
run: |
python --version
node --version
npm --version

- name: Build Admin UI
run: make build-kinto-admin

- name: Install pypa/build
run: python3 -m pip install build

- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
# only publish to PyPI on tag pushes
if: startsWith(github.ref, 'refs/tags/debug-publish-action-') != true
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/kinto
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include *.rst LICENSE Makefile tox.ini .coveragerc app.wsgi requirements.txt dev-requirements.txt
include *.rst LICENSE Makefile tox.ini app.wsgi requirements.txt dev-requirements.txt
include kinto/config/kinto.tpl
recursive-include kinto *.sql *.html *.ini *.yaml
recursive-include kinto *.sql *.html
recursive-include docs *.rst *.png *.svg *.css *.html conf.py piwik.js
include kinto/plugins/admin/VERSION
recursive-include kinto/plugins/admin/build *
prune docs/_build/*
59 changes: 22 additions & 37 deletions docs/community.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,13 @@ How to release

In order to prepare a new release, we are following the following steps.

The `prerelease` and `postrelease` commands are coming from `zest.releaser
<https://pypi.python.org/pypi/zest.releaser>`_.

Install `zest.releaser` with the `recommended` dependencies. They contain
`wheel` and `twine`, which are required to release a new version.

.. code-block:: bash

$ pip install "zest.releaser[recommended]"
The ``prerelease`` and ``postrelease`` commands are coming from `zest.releaser
<https://pypi.python.org/pypi/zest.releaser>`_, which should already be
installed along with other development requirements.

Step 1
------

.. code-block:: bash

$ git checkout -b prepare-X.Y.Z
$ make test-description
$ prerelease

- Merge remaining pull requests
- Update ``CHANGELOG.rst``
- Update supported version in ``SECURITY.md``
Expand All @@ -317,6 +305,14 @@ Step 1

$ git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' | sort

- Leverage zest.releaser to update setup file and changelog:

.. code-block:: bash

$ git checkout -b prepare-X.Y.Z
$ make test-description
$ prerelease

- Open a pull-request to release the new version.

.. code-block:: bash
Expand All @@ -328,40 +324,29 @@ Step 1
Step 2
------

Once the pull-request is validated, merge it and do a release.
Use the ``release`` command to invoke the ``setup.py``, which builds and uploads to PyPI.

.. important::

The Kinto Admin bundle will be built during the release process. Make sure
a recent version of ``npm`` is available in your shell when running ``release``.
Once the pull-request is approved, merge it and initiate a release.

.. code-block:: bash

$ git checkout master
$ git merge --no-ff prepare-X.Y.Z
$ release
$ postrelease
$ git tag -a X.Y.Z -m "X.Y.Z"
$ git push origin X.Y.Z

With this tag push, a Github Action will take care of publishing the package on Pypi.

Step 3
------

As a final step:

- Close the milestone in GitHub
- Create next milestone in GitHub in the case of a major release
- Add entry in GitHub release page
- Add entry in GitHub releases page
- Check that the version in ReadTheDocs is up-to-date
- Check that a Docker image was built
- Send mail to ML (If major release)
- Check that a Pypi package was built
- Tweet about it!

Upgrade:
You can now use the ``postrelease`` command to add a new empty section in the changelog and bump the next version with a ``.dev0`` suffix.

- Deploy new version on demo server
- Upgrade dependency in ``kinto-dist`` repo
- Upgrade version targetted in ``kinto-heroku`` repo
- Upgrade version of Kinto server for the tests of clients and plugins repos
(*kinto-http.js, kinto-http.py, kinto-attachment, etc.*)

That's all folks!
.. note::

Dependabot will take care of upgrading the ``kinto`` package via pull-requests on the various repositories of the Kinto ecosystem.
17 changes: 0 additions & 17 deletions kinto/plugins/admin/release_hook.py

This file was deleted.

5 changes: 0 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ monitoring =
[aliases]
test=pytest

[zest.releaser]
create-wheel = yes
releaser.after_checkout = kinto.plugins.admin.release_hook.after_checkout

[bdist_wheel]
python_tag=cp3

[coverage:run]
branch = True
omit = kinto/plugins/admin/release_hook.py

[flake8]
max-line-length = 99
Expand Down