Skip to content

promptfoo-python release by @jbeckwith-oai #36

promptfoo-python release by @jbeckwith-oai

promptfoo-python release by @jbeckwith-oai #36

name: release-please
run-name: promptfoo-python release by @${{ github.actor }}
concurrency:
group: release-please-${{ github.ref }}
cancel-in-progress: false
on:
push:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: "Release tag to re-publish (e.g. promptfoo-v0.1.3). Use when a release build failed."
required: true
type: string
jobs:
release-please:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ inputs.tag || steps.release.outputs.tag_name }}
steps:
# Only run the bot on push events; skip it for manual re-publish triggers.
- uses: googleapis/release-please-action@v4
id: release
if: github.event_name == 'push'
with:
token: ${{ secrets.GITHUB_TOKEN }}
build:
if: |
inputs.tag != '' ||
needs.release-please.outputs.release_created == 'true'
needs: release-please
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.tag_name }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Pin Python version
run: uv python pin 3.12
- name: Install dependencies
run: uv sync --extra dev
- name: Run unit tests
run: uv run pytest -m 'not smoke' -q
- name: Build package
run: uv build
- name: Verify package version matches release tag
env:
TAG: ${{ needs.release-please.outputs.tag_name }}
run: |
EXPECTED_VERSION="${TAG#promptfoo-v}"
if ls dist/*-${EXPECTED_VERSION}-*.whl 1> /dev/null 2>&1; then
echo "✓ Package version ${EXPECTED_VERSION} matches release tag ${TAG}"
else
echo "ERROR: Package version mismatch!"
echo "Expected: ${EXPECTED_VERSION} (from tag: ${TAG})"
echo "Built packages:"
ls -la dist/
exit 1
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
publish-pypi:
if: |
inputs.tag != '' ||
needs.release-please.outputs.release_created == 'true'
needs: [build, release-please]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/promptfoo/
permissions:
contents: read
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true