Files
pyannote-audio/.github/workflows/version-guard.yml
T
ea18bc70d8 Align audio CI and releases; require Python 3.11 (#2081)
* feat(cli): add --subfolder option to benchmark command (#2063)
* fix(utils): fix `SpeakerDiarizationMixin.optimal_mapping` when `reference` is a mapping
* fix(task): fix `balance` option crashing training with `KeyError: 'metadata'` (#2067)
* fix(io): fix `Audio.crop` raising when an in-memory waveform is cropped up to its very end (#2068)
* fix(model): make Model.default_activation return identity for unsupported tasks
* fix: compute sample duration from preloaded waveform
* fix(pipeline): omit unset runtime options from model references (#2080)

Co-authored-by: abeeranajam31 <128603901+abeeranajam31@users.noreply.github.com>
Co-authored-by: antoinelaurent <antoinelaurent@me.com>
Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com>
Co-authored-by: Mohammad Hijjawi <51020382+MohammadHijjawi97@users.noreply.github.com>
2026-10-22 15:07:01 +02:00

71 lines
2.7 KiB
YAML

name: Version Guard
on:
workflow_call:
inputs:
release-tag:
description: Release tag expected to match the package version
required: true
type: string
permissions:
contents: read
jobs:
not-already-published:
name: pyannote-audio
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version-file: .python-version
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-package-distributions
path: dist/
- name: Compare distributions with PyPI
env:
RELEASE_TAG: ${{ inputs.release-tag }}
shell: python
run: |
import hashlib
import json
import os
from pathlib import Path
from urllib.error import HTTPError
from urllib.request import urlopen
from zipfile import ZipFile
from email.parser import BytesParser
directory = Path("dist")
tag = os.environ["RELEASE_TAG"]
wheels = list(directory.glob("*.whl"))
sources = list(directory.glob("*.tar.gz"))
if len(wheels) != 1 or len(sources) != 1:
raise ValueError("Expected exactly one wheel and one source distribution")
with ZipFile(wheels[0]) as wheel:
metadata_path, = [n for n in wheel.namelist() if n.endswith(".dist-info/METADATA")]
metadata = BytesParser().parsebytes(wheel.read(metadata_path))
version = metadata["Version"]
if metadata["Name"] != "pyannote-audio" or version != tag.removeprefix("v"):
raise ValueError(f"Release tag {tag!r} does not match pyannote-audio {version}")
try:
with urlopen(f"https://pypi.org/pypi/pyannote-audio/{version}/json", timeout=30) as response:
published = json.load(response)["urls"]
except HTTPError as error:
if error.code != 404:
raise
published = []
hashes = {item["filename"]: item["digests"]["sha256"] for item in published}
for artifact in wheels + sources:
if artifact.name not in hashes:
print(f"{artifact.name}: not published yet")
elif hashlib.sha256(artifact.read_bytes()).hexdigest() == hashes[artifact.name]:
print(f"{artifact.name}: already published with identical contents")
else:
raise ValueError(f"{artifact.name} already exists with different contents. Use a new version.")