Skip to content

feat: M4 polish — pip-resolvable /simple/, llms.txt, catalog.json, md… #13

feat: M4 polish — pip-resolvable /simple/, llms.txt, catalog.json, md…

feat: M4 polish — pip-resolvable /simple/, llms.txt, catalog.json, md… #13

Workflow file for this run

name: Publish to PyPI
on:
push:
branches: [main]
paths:
- "pyproject.toml"
- "culture_tools/**"
pull_request:
branches: [main]
paths:
- "pyproject.toml"
- "culture_tools/**"
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- run: uv run pytest -n auto -v
test-publish:
# Skip on fork PRs — no OIDC/environment context is available there, so the
# publish step would fail and block external contributor CI.
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
needs: test
runs-on: ubuntu-latest
environment: testpypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- name: Set dev version
run: |
BASE=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
DEV_VERSION="${BASE}.dev${{ github.run_number }}"
sed -i "s/^version = .*/version = \"${DEV_VERSION}\"/" pyproject.toml
echo "DEV_VERSION=${DEV_VERSION}" >> "$GITHUB_ENV"
echo "Publishing ${DEV_VERSION} to TestPyPI"
- name: Build and publish to TestPyPI
run: |
uv build
uv publish --publish-url https://test.pypi.org/legacy/ --trusted-publishing always --check-url https://test.pypi.org/simple/
- name: Print install commands
if: always()
run: |
echo "::notice::Test with: uv tool install --index-url https://test.pypi.org/simple/ --index-strategy unsafe-best-match culture-tools==${DEV_VERSION}"
publish:
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4
- run: uv python install 3.12
- run: uv sync
- name: Build and publish to PyPI
run: |
uv build
uv publish --trusted-publishing always --check-url https://pypi.org/simple/