79 lines
2.5 KiB
YAML
79 lines
2.5 KiB
YAML
name: CI
|
|
|
|
# Every push to devel/release (or a manual run from the UI) tests the code and
|
|
# publishes it to the Gitea PyPI registry of the repository owner as a
|
|
# post-release of the current version. A version tag (v1.18.0) publishes the
|
|
# clean version instead.
|
|
on:
|
|
push:
|
|
branches: [devel, release]
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
# Tested natively on both architectures the library runs on.
|
|
test:
|
|
strategy:
|
|
matrix:
|
|
arch: [amd64, arm64]
|
|
runs-on: ${{ matrix.arch }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.14"
|
|
|
|
- name: Install Poetry
|
|
run: pip install "poetry==2.4.1"
|
|
|
|
- name: Install dependencies (incl. dev group)
|
|
run: poetry install --no-interaction
|
|
|
|
- name: Ruff
|
|
run: poetry run ruff check .
|
|
|
|
- name: Mypy
|
|
run: poetry run mypy src
|
|
|
|
- name: Pytest
|
|
run: poetry run pytest -q
|
|
|
|
# Pure-Python wheel (py3-none-any) — built once, works on every architecture.
|
|
publish:
|
|
needs: test
|
|
runs-on: amd64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.14"
|
|
|
|
- name: Install Poetry
|
|
run: pip install "poetry==2.4.1"
|
|
|
|
# Tag: publish the pyproject version as-is (and refuse a tag that doesn't match it).
|
|
# Branch push: the registry rejects re-uploading a version, so every commit gets a
|
|
# unique post-release (1.17.0.post12). Post-releases are not pre-releases, so a plain
|
|
# `^1.17` constraint picks them up.
|
|
- name: Set package version
|
|
run: |
|
|
VERSION="$(poetry version --short)"
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
if [ "v$VERSION" != "${{ github.ref_name }}" ]; then
|
|
echo "Tag ${{ github.ref_name }} does not match pyproject version $VERSION" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
poetry version "$VERSION.post${{ github.run_number }}"
|
|
fi
|
|
echo "Publishing $(poetry version --short) from ${{ github.sha }}"
|
|
|
|
- name: Build and publish to Gitea PyPI registry
|
|
env:
|
|
POETRY_REPOSITORIES_GITEA_URL: https://gitea.doubynet.eu/api/packages/${{ github.repository_owner }}/pypi
|
|
POETRY_HTTP_BASIC_GITEA_USERNAME: ${{ github.repository_owner }}
|
|
POETRY_HTTP_BASIC_GITEA_PASSWORD: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: poetry publish --build -r gitea --no-interaction
|