diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a9cae5..479fbf1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ # Sestavení a vydání NetMonitoru pro Windows, Linux a macOS (Intel i Apple Silicon). # Spuštění: # a) push na main se zvýšenou verzí v src/netmonitor/__init__.py => release v se založí sám -# (poznámky z CHANGELOG.md); pokud release té verze už existuje, nic se nevydává +# (poznámky z CHANGELOG.md); pokud release té verze už existuje, doplní se chybějící platformy z commitu tagu # b) vytvořením release / tagu "v*" na GitHubu # c) ručně: Actions → Build & Release → Run workflow → zadat existující tag (např. v1.0.1) # Každý build nahraje své soubory PŘÍMO do release – nepoužívá Actions artefakty @@ -94,6 +94,8 @@ jobs: steps: - uses: actions/checkout@v5 if: env.DO_BUILD == 'true' + with: + ref: refs/tags/${{ needs.prepare.outputs.tag }} - uses: actions/setup-python@v6 if: env.DO_BUILD == 'true' with: diff --git a/tests/test_release_workflow.py b/tests/test_release_workflow.py new file mode 100644 index 0000000..f9ce40e --- /dev/null +++ b/tests/test_release_workflow.py @@ -0,0 +1,22 @@ +"""Regrese L30: doplnění release musí stavět z commitu tagu vydané verze.""" +from pathlib import Path +import re + + +ROOT = Path(__file__).resolve().parent.parent + + +def test_build_checks_out_release_tag(): + workflow = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8") + build = re.search(r"^ build:\n.*?(?=^ [\w-]+:|\Z)", workflow, re.M | re.S) + assert build is not None, "Chybí job build" + + checkout = re.search( + r"^ - uses: actions/checkout@v5\n(?P(?: .*\n)*)", + build.group(), + re.M, + ) + assert checkout is not None, "V jobu build chybí checkout" + assert " with:\n ref: refs/tags/${{ needs.prepare.outputs.tag }}\n" in checkout.group("options"), ( + "Checkout v jobu build musí použít tag z jobu prepare" + )