Merge pull request #1492 from element-hq/dependabot/uv/gitpython-3.1.57 #1218
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2024-2025 New Vector Ltd | |
| # Copyright 2025-2026 Element Creations Ltd | |
| # | |
| # SPDX-License-Identifier: AGPL-3.0-only | |
| name: Packages linting, testing & releasing | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - 'maintenance/*' | |
| tags: | |
| # Publish on any tag starting with a `v`, e.g., v0.1.0 | |
| - ess-migration-tool-v* | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| python: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| - "3.14" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| enable-cache: true | |
| activate-environment: true | |
| python-version: ${{ matrix.python-version }} | |
| - name: Set up UV environment | |
| run: uv sync --all-packages --resolution lowest-direct | |
| - name: Run ruff check | |
| run: | | |
| ruff check | |
| - name: Run ruff format | |
| run: | | |
| ruff format --check | |
| - name: mypy | |
| run: | | |
| mypy packages/ess-migration-tool | |
| - name: pytest packages | |
| run: | | |
| pytest packages | |
| - name: Build with lowest resolution | |
| run: uv build --package ess-migration-tool | |
| - name: pytest packages (wheel) | |
| run: uv run --isolated --no-project --with dist/*.whl pytest packages/ess-migration-tool/tests | |
| - name: pytest packages (source distribution) | |
| run: uv run --isolated --no-project --with dist/*.tar.gz pytest packages/ess-migration-tool/tests | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - python | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| # We disable cache for releases to avoid cache poisoning | |
| enable-cache: ${{ github.ref_type != 'tag' }} | |
| activate-environment: true | |
| - name: Set up UV environment | |
| run: uv sync --all-packages --resolution lowest-direct | |
| - name: Set version | |
| env: | |
| GITHUB_RUN_ID: "${{ github.run_id }}" | |
| run: | | |
| if [ "$GITHUB_REF_TYPE" = "tag" ]; then | |
| uv --directory packages/ess-migration-tool version "${GITHUB_REF_NAME#ess-migration-tool-v}" | |
| else | |
| uv version --directory packages/ess-migration-tool --bump "dev=$GITHUB_RUN_ID" | |
| fi | |
| - name: Build | |
| run: uv build --package ess-migration-tool | |
| # Check that basic features work and we didn't miss to include crucial files | |
| - name: Smoke test (wheel) | |
| run: |- | |
| for version in 3.11 3.12 3.13 3.14; do | |
| uv run --python "$version" --isolated --resolution lowest --no-project --with dist/*.whl ess-migration-tool --help | |
| done | |
| - name: Smoke test (source distribution) | |
| run: | | |
| for version in 3.11 3.12 3.13 3.14; do | |
| uv run --python "$version" --isolated --resolution lowest --no-project --with dist/*.tar.gz ess-migration-tool --help | |
| done | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ess-migration-tool-dist | |
| path: | | |
| dist/* | |
| retention-days: 1 | |
| publish: | |
| needs: | |
| - build | |
| environment: | |
| name: pypi | |
| permissions: | |
| id-token: write | |
| contents: write | |
| packages: read | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| # We are creating a commit changing the chart version for the next version PR | |
| persist-credentials: true | |
| - name: Grab packaged dists | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ess-migration-tool-dist | |
| path: ./dist | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 | |
| with: | |
| enable-cache: true | |
| activate-environment: true | |
| - name: Set up UV environment | |
| run: uv sync | |
| - name: Generate changelog | |
| run: | | |
| version=$(find dist -name 'ess_migration_tool-*.tar.gz' | sed 's/.*ess_migration_tool-//;s/.tar.gz//') | |
| # Add changes to CHANGELOG.md | |
| uv run towncrier build --version "$version" --yes --dir packages/ess-migration-tool | |
| echo "CHANGELOG.md will look like:" | |
| cat packages/ess-migration-tool/CHANGELOG.md | |
| echo "" | |
| - name: Bump version for next PR | |
| id: versions | |
| run: | | |
| if [ "$GITHUB_REF_TYPE" = "tag" ]; then | |
| uv --directory packages/ess-migration-tool version "${GITHUB_REF_NAME#ess-migration-tool-v}" | |
| fi | |
| this_version=$(uv --directory packages/ess-migration-tool version --short) | |
| uv --directory packages/ess-migration-tool version --bump patch --bump dev=1 | |
| next_version=$(uv --directory packages/ess-migration-tool version --short) | |
| echo "this-version=$this_version" | tee -a "$GITHUB_OUTPUT" | |
| echo "next-version=$next_version" | tee -a "$GITHUB_OUTPUT" | |
| - name: Publish | |
| env: | |
| REF_TYPE: ${{ github.ref_type }} | |
| run: | | |
| if [ "${REF_TYPE}" = "tag" ]; then | |
| uv publish dist/* | |
| else | |
| uv publish --dry-run dist/* | |
| fi | |
| - name: Create PR for next patch version | |
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| if: github.ref_type == 'tag' | |
| with: | |
| branch: "gha/bump-ess-migration-tool-to-${{ steps.versions.outputs.next-version }}" | |
| base: "main" | |
| commit-message: "Bump ess-migration-tool version to ${{ steps.versions.outputs.next-version }}" | |
| title: "Bump ess-migration-tool version to ${{ steps.versions.outputs.next-version }} after release" | |
| labels: automated,version-bump | |
| body: | | |
| ${{ steps.versions.outputs.this-version }} has just been released. | |
| This PR prepares ess-migration-tool package for the next release: | |
| ${{ steps.versions.outputs.next-version }}. | |
| The target branch may be wrong. In which case this PR should be taken over and manually adjusted. |