From 667a33e3428c3ad4c038078054e396cbf0d99f59 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Tue, 19 Dec 2023 17:13:19 +0100 Subject: [PATCH 1/6] Run a publish workflow on Pypi --- .github/workflows/publish.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..d3358ce6b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,56 @@ +name: Publish Python 🐍 distribution 📦 to PyPI + +on: push + +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" + - run: python --version + + - uses: actions/setup-node@v3 + with: + node-version: "14" + - run: npm --version + + - name: Install release tools + run: pip install "zest.releaser[recommended]" + + - name: Build a binary wheel and a source tarball + run: release --no-input + + - 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/') + 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 + From 3aa1d041b596e8345f7f42a53f29a3247781cf4a Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Tue, 19 Dec 2023 17:34:23 +0100 Subject: [PATCH 2/6] Update docs steps --- docs/community.rst | 57 +++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/docs/community.rst b/docs/community.rst index 884d59c7a..d8e7690a3 100644 --- a/docs/community.rst +++ b/docs/community.rst @@ -284,24 +284,12 @@ 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 -`_. - -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]" +`_, 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`` @@ -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 @@ -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. From 0370dbe5c4ed956956e3e9c7251322d124a9aced Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Tue, 19 Dec 2023 18:23:46 +0100 Subject: [PATCH 3/6] Run publish workflow on tag only --- .github/workflows/publish.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d3358ce6b..06a13cdf0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,9 @@ name: Publish Python 🐍 distribution 📦 to PyPI -on: push +on: + push: + tags: + - '*' jobs: build: @@ -36,7 +39,7 @@ jobs: publish-to-pypi: name: Publish Python 🐍 distribution 📦 to PyPI # only publish to PyPI on tag pushes - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/debug-publish-action-') != true needs: - build runs-on: ubuntu-latest @@ -53,4 +56,3 @@ jobs: path: dist/ - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - From dec883450ed60d1914d4473a8efcfd7268f49a81 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Wed, 20 Dec 2023 10:11:47 +0100 Subject: [PATCH 4/6] Do not use zest.releaser in release action --- .github/workflows/publish.yml | 9 ++++++--- docs/community.rst | 2 +- kinto/plugins/admin/release_hook.py | 17 ----------------- setup.cfg | 5 ----- 4 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 kinto/plugins/admin/release_hook.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 06a13cdf0..3bf9d5734 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,11 +24,14 @@ jobs: node-version: "14" - run: npm --version - - name: Install release tools - run: pip install "zest.releaser[recommended]" + - 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: release --no-input + run: python3 -m build - name: Store the distribution packages uses: actions/upload-artifact@v3 diff --git a/docs/community.rst b/docs/community.rst index d8e7690a3..d5221a4d9 100644 --- a/docs/community.rst +++ b/docs/community.rst @@ -283,7 +283,7 @@ 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 +The ``prerelease`` and ``postrelease`` commands are coming from `zest.releaser `_, which should already be installed along with other development requirements. diff --git a/kinto/plugins/admin/release_hook.py b/kinto/plugins/admin/release_hook.py deleted file mode 100644 index c89950799..000000000 --- a/kinto/plugins/admin/release_hook.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -This module is a release hook for `zest.releaser `_ -in order to build the Kinto Admin UI bundle just before it is packaged. - -* See hooks in :file:`setup.cfg` -* `Documentation `_ -""" - -import subprocess - - -def after_checkout(data): - """During the ``release`` process, the current tag is checked out in a - temporary folder. We build the Kinto Admin at this step, just before - the files are gathered for the final Python package.""" - - subprocess.run(["make", "build-kinto-admin"]) diff --git a/setup.cfg b/setup.cfg index d3759ce4f..3a12e4a29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 From 8ce63eeef51ea47e3d31d58662d7860ae3212975 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Wed, 20 Dec 2023 10:18:37 +0100 Subject: [PATCH 5/6] Upgrade node --- .github/workflows/publish.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3bf9d5734..52ad9d5ee 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,12 +17,16 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.x" - - run: python --version - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: "14" - - run: npm --version + node-version: "20" + + - name: Print environment + run: | + python --version + node --version + npm --version - name: Build Admin UI run: make build-kinto-admin From a071f127079587b3e1d8fbf421741df93197efd2 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Wed, 20 Dec 2023 10:44:15 +0100 Subject: [PATCH 6/6] Fix packaging warnings --- MANIFEST.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 040ac79b2..2efe4f8f9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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/*