mirror of
https://github.com/element-hq/ess-helm.git
synced 2026-11-20 17:11:31 -08:00
208 lines
6.4 KiB
YAML
208 lines
6.4 KiB
YAML
# 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"
|
|
- "3.15"
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
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@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
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 3.15; 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 3.15; do
|
|
uv run --python "$version" --isolated --resolution lowest --no-project --with dist/*.tar.gz ess-migration-tool --help
|
|
done
|
|
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
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@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
with:
|
|
name: ess-migration-tool-dist
|
|
path: ./dist
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
|
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
|
|
|
|
- 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@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
|
|
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.
|