Skip to content

fix(ci): keep lockfile in sync #4

fix(ci): keep lockfile in sync

fix(ci): keep lockfile in sync #4

Workflow file for this run

name: CI and Release
on:
pull_request:
push:
branches:
- master
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install dependencies
run: uv sync --python 3.14 --locked
- name: Test
run: bash scripts/tests.sh
- name: Build docs
run: uv run --python 3.14 mkdocs build --strict
- name: Build package
run: uv build
- name: Coveralls
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: uv run --python 3.14 coveralls --service=github
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: validate
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
commit_sha: ${{ steps.release-metadata.outputs.commit_sha }}
released: ${{ steps.release-plan.outputs.released }}
tag: ${{ steps.release-plan.outputs.tag }}
version: ${{ steps.release-plan.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install dependencies
run: uv sync --python 3.14 --locked
- name: Configure git author
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Check release baseline
id: release-baseline
run: |
current_version="$(python - <<'PY'
from pathlib import Path
import tomllib
pyproject = tomllib.loads(Path("pyproject.toml").read_text())
print(pyproject["project"]["version"])
PY
)"
if ! git rev-parse "v${current_version}" >/dev/null 2>&1; then
echo "::warning::No v${current_version} tag exists yet. Create a bootstrap tag for the current project version before relying on fully automated version bumps."
echo "ready=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "ready=true" >> "$GITHUB_OUTPUT"
- name: Plan release
if: steps.release-baseline.outputs.ready == 'true'
id: release-plan
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_version="$(python - <<'PY'
from pathlib import Path
import tomllib
pyproject = tomllib.loads(Path("pyproject.toml").read_text())
print(pyproject["project"]["version"])
PY
)"
next_version="$(uv run --python 3.14 semantic-release version --print)"
if [ "$next_version" = "$current_version" ]; then
echo "released=false" >> "$GITHUB_OUTPUT"
echo "version=$current_version" >> "$GITHUB_OUTPUT"
echo "tag=v$current_version" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "released=true" >> "$GITHUB_OUTPUT"
echo "version=$next_version" >> "$GITHUB_OUTPUT"
echo "tag=v$next_version" >> "$GITHUB_OUTPUT"
- name: Run semantic release
if: steps.release-baseline.outputs.ready == 'true' && steps.release-plan.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: uv run --python 3.14 semantic-release version --strict
- name: Capture release metadata
if: steps.release-baseline.outputs.ready == 'true' && steps.release-plan.outputs.released == 'true'
id: release-metadata
run: echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
publish-package:
if: needs.release.outputs.released == 'true'
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.commit_sha }}
- uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install dependencies
run: uv sync --python 3.14 --locked
- name: Build package
run: uv build
- name: Install Twine
run: python -m pip install --upgrade twine
- name: Publish package
env:
TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
TWINE_USERNAME: ${{ github.actor }}
run: python -m twine upload --repository-url https://api.github.com/orgs/${{ github.repository_owner }}/packages/pypi/upload dist/*
build-release-docs:
if: needs.release.outputs.released == 'true'
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.commit_sha }}
- uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: actions/configure-pages@v5
- name: Install dependencies
run: uv sync --python 3.14 --locked
- name: Build docs
run: uv run --python 3.14 mkdocs build --strict
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: site
deploy-release-docs:
if: needs.release.outputs.released == 'true'
needs:
- build-release-docs
- publish-package
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4