From 1fc7913d34192089afb5d621298b64f73d11635c Mon Sep 17 00:00:00 2001 From: Yurii Serhiichuk Date: Tue, 23 Dec 2025 21:26:54 +0100 Subject: [PATCH] feat(pypi): add support for `v2` branch in release workflow and streamline build/publish process using `uv` Signed-off-by: Yurii Serhiichuk --- .github/workflows/pypi-release.yml | 40 +++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index a9605a2..1c917fe 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -5,6 +5,7 @@ on: push: branches: - main + - v2 - 'tag/v**' jobs: @@ -15,9 +16,15 @@ jobs: - uses: actions/checkout@v5 with: fetch-depth: 0 + - name: Install uv + uses: astral-sh/setup-uv@v7 + - name: Set up Python + run: uv python install 3.12 + - name: Install the project + run: uv sync --all-extras --dev - name: Build SDist and wheel - run: pipx run build + run: uv run build - uses: actions/upload-artifact@v5 with: @@ -25,7 +32,7 @@ jobs: path: dist/* - name: Check metadata - run: pipx run twine check dist/* + run: uv run twine check dist/* publish: runs-on: ubuntu-24.04 if: github.event_name == 'push' @@ -34,17 +41,8 @@ jobs: - uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: "3.11" - cache: 'pip' - - name: Install build dependencies - run: pip install -U setuptools wheel build - uses: actions/download-artifact@v5 with: - # unpacks default artifact into dist/ - # if `name: artifact` is omitted, the action will create extra parent dir name: artifact path: dist - name: Publish @@ -52,7 +50,19 @@ jobs: with: user: __token__ password: ${{ secrets.pypi_password }} - - name: Install GitPython and cloudevents for pypi_packaging - run: pip install -U -r requirements/publish.txt - - name: Create Tag - run: python pypi_packaging.py + tag: + runs-on: ubuntu-24.04 + needs: [ publish ] + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Extract version + id: version + run: | + echo "version=$(grep -oP '__version__ = \"\K[^\"]+' src/cloudevents/__init__.py)" >> $GITHUB_OUTPUT + - name: Create and push tag + uses: pxpm/github-tag-action@1.0.1 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + tag: ${{ steps.version.outputs.version }}