Skip to content

Commit 1978709

Browse files
mldangeloclaude
andcommitted
fix: checkout release tag in build job and add manual re-publish trigger
Root cause of 0.1.3 not publishing to PyPI: the build job used actions/checkout@v6 without a ref, so it checked out GITHUB_SHA (the triggering commit) rather than the release tag. When the release-please action tags a release during an earlier push, the build job can check out a commit where pyproject.toml still has the old version, causing a version mismatch and build failure. Fixes: - Build job now checks out the release tag ref explicitly, ensuring pyproject.toml always matches the tagged version - Derive expected version from the tag name instead of the release-please version output (more reliable) - Add workflow_dispatch with a tag input so failed releases can be re-published without needing a new commit: run the workflow manually with tag=promptfoo-v0.1.3 to re-trigger build+publish - Run unit tests in the build job before publishing (was just an import check before) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ecd2226 commit 1978709

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

.github/workflows/release-please.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ on:
1010
branches:
1111
- main
1212
workflow_dispatch:
13+
inputs:
14+
tag:
15+
description: "Release tag to publish (e.g. promptfoo-v0.1.3). Use to re-publish a failed release."
16+
required: false
17+
type: string
1318

1419
jobs:
1520
release-please:
1621
runs-on: ubuntu-latest
22+
# Skip the release-please bot when manually re-publishing
23+
if: github.event_name != 'workflow_dispatch'
1724
permissions:
1825
contents: write
1926
pull-requests: write
@@ -28,13 +35,28 @@ jobs:
2835
token: ${{ secrets.GITHUB_TOKEN }}
2936

3037
build:
31-
if: needs.release-please.outputs.release_created == 'true'
3238
runs-on: ubuntu-latest
33-
needs: release-please
3439
permissions:
3540
contents: read
41+
# Normal release: triggered by release-please creating a release
42+
# Manual re-publish: triggered by workflow_dispatch with a tag input
43+
if: |
44+
(github.event_name == 'workflow_dispatch' && inputs.tag != '') ||
45+
(needs.release-please.result == 'success' && needs.release-please.outputs.release_created == 'true')
46+
needs: release-please
3647
steps:
48+
- name: Resolve tag
49+
id: resolve
50+
run: |
51+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
52+
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
53+
else
54+
echo "tag=${{ needs.release-please.outputs.tag_name }}" >> "$GITHUB_OUTPUT"
55+
fi
56+
3757
- uses: actions/checkout@v6
58+
with:
59+
ref: ${{ steps.resolve.outputs.tag }}
3860

3961
- uses: astral-sh/setup-uv@v7
4062
with:
@@ -46,22 +68,21 @@ jobs:
4668
- name: Install dependencies
4769
run: uv sync --extra dev
4870

49-
- name: Run tests
50-
run: |
51-
# Quick smoke test before publishing
52-
uv run python -c "import promptfoo; print(promptfoo.__version__)"
71+
- name: Run unit tests
72+
run: uv run pytest -m 'not smoke' -q
5373

5474
- name: Build package
5575
run: uv build
5676

57-
- name: Verify package version matches release
77+
- name: Verify package version matches release tag
5878
run: |
59-
EXPECTED_VERSION="${{ needs.release-please.outputs.version }}"
79+
TAG="${{ steps.resolve.outputs.tag }}"
80+
EXPECTED_VERSION="${TAG#promptfoo-v}"
6081
if ls dist/*-${EXPECTED_VERSION}-*.whl 1> /dev/null 2>&1; then
61-
echo "✓ Package version ${EXPECTED_VERSION} matches release"
82+
echo "✓ Package version ${EXPECTED_VERSION} matches release tag ${TAG}"
6283
else
6384
echo "ERROR: Package version mismatch!"
64-
echo "Expected version: ${EXPECTED_VERSION}"
85+
echo "Expected version: ${EXPECTED_VERSION} (from tag: ${TAG})"
6586
echo "Built packages:"
6687
ls -la dist/
6788
exit 1
@@ -74,7 +95,9 @@ jobs:
7495
path: dist/
7596

7697
publish-pypi:
77-
if: needs.release-please.outputs.release_created == 'true'
98+
if: |
99+
(github.event_name == 'workflow_dispatch' && inputs.tag != '') ||
100+
(needs.release-please.result == 'success' && needs.release-please.outputs.release_created == 'true')
78101
needs: [build, release-please]
79102
runs-on: ubuntu-latest
80103
environment:

0 commit comments

Comments
 (0)