M22: Publish GitHub Release for v0.2.0 & Guard Duplicate PyPI Workflow Trigger¶
- Task ID:
M22 - Priority:
P1(Master Rank#11, Track B — Simple Fixes, Docs & CI Hygiene) - Status:
Done - Dependencies:
M6,M11 - Target Repository:
/Users/ivan/Project/3t.tools.intellij/verityredteam-free(verity-redteam-core) - GitHub Project #5: Verity RedTeam Free Task Board
1. Context & Problem Statement¶
Tag v0.2.0 was published to PyPI, but the repository JMartynov/verityredteam-free has zero GitHub Releases — there is no structured, human-readable changelog entry for v0.2.0, no release assets, and no link from the GitHub UI to the shipped distribution.
Blocking issue: .github/workflows/workflow.yaml (lines 3–9) triggers the publish pipeline on both push: tags: ["v*"] and release: types: [published]:
Creating a GitHub Release for v0.2.0 therefore re-runs pypi-publish after the tag push already uploaded the artifacts, and pypa/gh-action-pypi-publish fails with 400 File already exists (duplicate filename for the same version). Without a guard, this task's core deliverable (the GitHub Release) is impossible to complete on a green CI run.
2. Requirements & Target Files¶
- Guard
.github/workflows/workflow.yamlagainst duplicate PyPI upload, using exactly one of: - remove the
release: types: [published]trigger so only tag pushes publish, or - keep both triggers and add
skip-existing: trueto thepypa/gh-action-pypi-publish@release/v1step. The chosen guard must be explicit and verifiable by parsing the YAML (no comments-only guard). - Add
tests/unit/test_workflow_hygiene.pythat loads.github/workflows/workflow.yamlwithyaml.safe_loadand asserts: - the effective trigger set is a subset of
{push, release, workflow_dispatch}, andpush.tags(if present) coversv*; - a duplicate-upload guard exists: either
releaseabsent fromon, or the publish step carrieswith.skip-existing: true; pypi-publishdeclaresneeds: full-tests,environment.name == pypi, andpermissions.id-token: write.- Publish the
v0.2.0GitHub Release with structured notes covering theM7–M11deliverables, verified against the actual repository state, including anINSTALL_SOURCE=pypicontainer E2E confirmation. - No regression to the existing release flow: a
pushof a new tag must still build, lint, test, and publish exactly once.
3. Automated Tests to Verify (tests/unit/test_workflow_hygiene.py)¶
workflow.yamlparses cleanly withyaml.safe_loadand exposes anonmapping (or list) with only known trigger keys.push.tags(whenpushis present) contains a pattern matchingv*(e.g."v*").- Duplicate-upload guard assertion:
releasenot in triggers → pass, orreleasein triggers and thepypa/gh-action-pypi-publishstep haswith: {skip-existing: true}→ pass.- any other combination → fail with an explicit message naming both remedies.
pypi-publishjob contract:needs == "full-tests",environment.name == "pypi",permissions["id-token"] == "write".- Parametrized negative test: a mutated in-memory copy with
releasepresent and noskip-existingis rejected by the guard helper (pure-function check, no file writes). gh release view v0.2.0 --json tagName,bodyoutput contains theM7–M11sections, the PyPI URL forverity-redteam-core==0.2.0, and theINSTALL_SOURCE=pypiE2E line (asserted via recorded fixture captured after publishing, not live network).
4. Acceptance Scenario in Clean Container with INSTALL_SOURCE=pypi¶
- Apply the workflow guard, then run
uv run pytest tests/unit/test_workflow_hygiene.py -vlocally — green. - Push the guard commit and create the release:
(or
--notes "…"with the same content) with sections forM7,M8,M9,M10,M11. - Confirm the release exists and the notes are intact:
- Confirm the test matrix stays green: the
releaseevent run ofworkflow.yamlmust reachpypi-publishand either skip the already-present files (skip-existing) or not run at all because thereleasetrigger was removed — no400 File already existsfailure. - Container E2E against the PyPI artifact:
- Assertions:
gh release view v0.2.0exits0and shows tagv0.2.0; the release-triggered run does not fail on duplicate upload;INSTALL_SOURCE=pypi ./tests/e2e_containers/run_e2e.shpasses and installsverity-redteam-core==0.2.0from PyPI.
5. Verification Commands¶
cd /Users/ivan/Project/3t.tools.intellij/verityredteam-free
uv run ruff check src tests
uv run pytest tests/unit/test_workflow_hygiene.py -v
uv run pytest tests/
gh release view v0.2.0
INSTALL_SOURCE=pypi ./tests/e2e_containers/run_e2e.sh
6. Acceptance Criteria¶
- [ ]
.github/workflows/workflow.yamlhas an explicit duplicate-upload guard (either therelease: types: [published]trigger is removed, orpypa/gh-action-pypi-publishsetsskip-existing: true). - [ ]
tests/unit/test_workflow_hygiene.pyvalidates the workflow triggers and guard, including the parametrized negative case, and passes. - [ ] GitHub Release
v0.2.0is published onJMartynov/verityredteam-freewith structured notes coveringM7–M11and a PyPI install link, verified bygh release view v0.2.0. - [ ] Re-triggering
pypi-publishfor an existingv0.2.0no longer fails with a duplicate-filename error. - [ ]
uv run pytest tests/,uv run ruff check src tests, andINSTALL_SOURCE=pypi ./tests/e2e_containers/run_e2e.shpass cleanly.