Merge pull request #703 from greyhaven-ai/codex/release-0.4.2 #14
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: publish-python | |
| on: | |
| push: | |
| tags: | |
| - "py-v*" | |
| workflow_dispatch: | |
| concurrency: | |
| group: publish-python-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-python: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: autocontext | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Validate tag matches Python package version | |
| if: startsWith(github.ref, 'refs/tags/py-v') | |
| run: | | |
| python - <<'PY' | |
| import os | |
| import sys | |
| import tomllib | |
| with open("pyproject.toml", "rb") as fh: | |
| version = tomllib.load(fh)["project"]["version"] | |
| tag = os.environ["GITHUB_REF_NAME"] | |
| expected = tag.removeprefix("py-v") | |
| if version != expected: | |
| print( | |
| f"Tag {tag!r} does not match autocontext/pyproject.toml version {version!r}.", | |
| file=sys.stderr, | |
| ) | |
| sys.exit(1) | |
| PY | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: Build Python package | |
| run: uv build | |
| - name: Upload Python dist | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: python-dist | |
| path: autocontext/dist/* | |
| retention-days: 7 | |
| publish-pypi: | |
| needs: build-python | |
| runs-on: ubuntu-latest | |
| environment: publish-python | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download Python dist | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: python-dist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist |