Skip to content

ci: commit uv.lock so setup-uv can cache #2

ci: commit uv.lock so setup-uv can cache

ci: commit uv.lock so setup-uv can cache #2

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
already-published: ${{ steps.check.outputs.already-published }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Sync deps
run: uv sync
- name: Read version
id: version
run: |
VERSION=$(uv run python -c "from postio._version import __version__; print(__version__)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version: $VERSION"
- name: Check tag matches version
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG="${GITHUB_REF#refs/tags/v}"
VERSION="${{ steps.version.outputs.version }}"
if [ "$TAG" != "$VERSION" ]; then
echo "::error::Tag v$TAG does not match package version $VERSION"
exit 1
fi
- name: Check if already on PyPI (idempotent)
id: check
run: |
VERSION="${{ steps.version.outputs.version }}"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/postio/$VERSION/json")
if [ "$STATUS" = "200" ]; then
echo "postio==$VERSION already on PyPI — skipping publish"
echo "already-published=true" >> "$GITHUB_OUTPUT"
else
echo "postio==$VERSION not yet published"
echo "already-published=false" >> "$GITHUB_OUTPUT"
fi
- name: Run lint + tests
if: steps.check.outputs.already-published == 'false'
run: |
uv run ruff check postio/ tests/
uv run ruff format --check postio/ tests/
uv run mypy postio/
uv run pytest tests/test_offline.py -v
- name: Build sdist + wheel
if: steps.check.outputs.already-published == 'false'
run: uv build
- name: Upload dist
if: steps.check.outputs.already-published == 'false'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
needs: build
if: needs.build.outputs.already-published == 'false'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/postio/
permissions:
id-token: write # PyPI Trusted Publishers (OIDC)
steps:
- name: Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1