Skip to content

FunASR-powered video transcription, subtitle generation, and LLM-assisted clipping tool with a local Gradio UI.

release: prepare FunClip v2.1.0 (#194)

zhifu gao6f29319e1b36
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..3df10a3
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,130 @@
+name: Release
+
+on:
+ push:
+ tags: ["v*.*.*"]
+
+permissions:
+ contents: write
+
+concurrency:
+ group: release-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out tagged source
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 0
+
+ - name: Set up Python
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: "3.12"
+
+ - name: Install release-test dependency
+ run: python -m pip install --disable-pip-version-check pytest==8.3.5
+
+ - name: Verify tag and release notes
+ shell: bash
+ run: |
+ version="$(<VERSION)"
+ test "$GITHUB_REF_NAME" = "v${version}"
+ test -f "docs/releases/${GITHUB_REF_NAME}.md"
+
+ - name: Test release contract
+ run: python -m pytest -q tests/test_release_contract.py
+
+ - name: Build release archives
+ run: python scripts/build_release_assets.py --ref "$GITHUB_SHA" --output-dir dist
+
+ - name: Publish GitHub release
+ env:
+ GH_TOKEN: ${{ github.token }}
+ shell: bash
+ run: |
+ set -u
+ release_assets=(dist/FunClip-*.tar.gz dist/FunClip-*.zip dist/SHA256SUMS)
+
+ if ! release_state="$(
+ gh release view "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --json apiUrl,isDraft,isImmutable 2>/dev/null
+ )"; then
+ gh release create "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --verify-tag \
+ --draft \
+ --title "FunClip ${GITHUB_REF_NAME}" \
+ --notes-file "docs/releases/${GITHUB_REF_NAME}.md"
+ release_state="$(
+ gh release view "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --json apiUrl,isDraft,isImmutable
+ )"
+ fi
+
+ release_api="$(jq -r '.apiUrl' <<<"$release_state")"
+ draft="$(jq -r '.isDraft' <<<"$release_state")"
+ immutable="$(jq -r '.isImmutable' <<<"$release_state")"
+
+ verify_release_assets() {
+ local actual expected
+ expected="$(
+ for asset in "${release_assets[@]}"; do
+ printf '%s\t%s\tsha256:%s\n' \
+ "$(basename "$asset")" \
+ "$(wc -c < "$asset")" \
+ "$(sha256sum "$asset" | cut -d ' ' -f 1)"
+ done | sort
+ )"
+ actual="$(
+ gh api "$release_api" \
+ --jq '.assets[] | [.name, (.size | tostring), .digest] | @tsv' | sort
+ )"
+ if [[ "$actual" != "$expected" ]]; then
+ printf 'Expected release assets:\n%s\nActual release assets:\n%s\n' \
+ "$expected" "$actual" >&2
+ return 1
+ fi
+ }
+
+ if [[ "$draft" == "false" ]]; then
+ verify_release_assets
+ echo "Release is already published and verified (immutable=${immutable})."
+ exit 0
+ fi
+
+ gh release edit "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --draft \
+ --title "FunClip ${GITHUB_REF_NAME}" \
+ --notes-file "docs/releases/${GITHUB_REF_NAME}.md"
+ gh release upload "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --clobber \
+ "${release_assets[@]}"
+
+ verified=false
+ for _attempt in 1 2 3 4 5; do
+ if verify_release_assets; then
+ verified=true
+ break
+ fi
+ sleep 2
+ done
+ test "$verified" = true
+
+ gh release edit "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --draft=false \
+ --latest
+ test "$(
+ gh release view "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --json isDraft \
+ --jq '.isDraft'
+ )" = false
diff --git a/README.md b/README.md
index 96b4cc1..4ecbf26 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@
<a name="What's New"></a>
## What's New🚀
+- 2026/07/24 [FunClip v2.1.0](https://github.com/modelscope/FunClip/releases/tag/v2.1.0) is the first versioned GitHub release. It packages the current Fun-ASR-Nano, SenseVoice, Paraformer, and LLM-assisted clipping application as checksum-protected source archives for a stable rollback point.
- 2026/05/20 FunClip now supports [Fun-ASR-Nano](https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512) and [SenseVoice](https://huggingface.co/FunAudioLLM/SenseVoiceSmall) models. The `fun-asr-nano` option loads the flagship Fun-ASR-Nano-2512 checkpoint for Mandarin, English, Japanese, 7 Chinese dialect groups, and 26 regional accents; it does not load the separate 31-language Fun-ASR-MLT-Nano-2512 checkpoint. SenseVoice adds emotion recognition and audio event detection. Run `python funclip/launch.py -m fun-asr-nano` or `-m sensevoice` to try. For precise text-based clipping, use Paraformer because the released Nano checkpoint does not provide reliable character-level timestamps.
- 2024/06/12 FunClip now supports recognizing and clipping English audio files. Run `python funclip/launch.py -l en` to try.
- 🔥2024/05/13 FunClip v2.0.0 now supports smart clipping with large language models, integrating models from the qwen series, GPT series, etc., providing default prompts. You can also explore and share tips for setting prompts, the usage is as follows:
@@ -74,6 +75,8 @@ cd FunClip
pip install -r ./requirements.txt
```
+For a versioned snapshot, download [FunClip-2.1.0.tar.gz](https://github.com/modelscope/FunClip/releases/download/v2.1.0/FunClip-2.1.0.tar.gz) or [FunClip-2.1.0.zip](https://github.com/modelscope/FunClip/releases/download/v2.1.0/FunClip-2.1.0.zip), then verify it with the published [SHA256SUMS](https://github.com/modelscope/FunClip/releases/download/v2.1.0/SHA256SUMS). Model weights are downloaded separately when FunClip starts and are not included in these source archives.
+
FunClip's Fun-ASR-Nano, SenseVoice, and subtitle compatibility paths require `funasr>=1.3.29`. This release returns every SenseVoice VAD region through `sentence_info` when token timestamps are unavailable, so clipping and subtitle clients receive segment boundaries instead of an empty timeline. It also includes the real-time final-text and short-tail fixes from 1.3.28. If you installed FunClip before this requirement was updated, run `pip install -U "funasr>=1.3.29"` before starting the Gradio service. [Release notes](https://github.com/modelscope/FunASR/releases/tag/v1.3.29) · [PyPI](https://pypi.org/project/funasr/1.3.29/)
### imagemagick install (Optional)
diff --git a/README_zh.md b/README_zh.md
index e69aa70..552578f 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -36,6 +36,7 @@
<a name="近期更新"></a>
## 近期更新🚀
+- 2026/07/24 [FunClip v2.1.0](https://github.com/modelscope/FunClip/releases/tag/v2.1.0) 是首个带版本号的 GitHub Release,将当前支持 Fun-ASR-Nano、SenseVoice、Paraformer 与大模型智能剪辑的应用打包为带 SHA-256 校验的源码归档,提供稳定的下载与回退节点。
- 2026/05/20 FunClip 现在支持 [Fun-ASR-Nano](https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512) 与 [SenseVoice](https://huggingface.co/FunAudioLLM/SenseVoiceSmall) 模型。`fun-asr-nano` 选项加载旗舰版 Fun-ASR-Nano-2512,支持普通话、英语、日语、7 类中文方言和 26 种地域口音;该选项不会加载独立的 31 语种 Fun-ASR-MLT-Nano-2512。SenseVoice 支持多语种识别,并额外输出情绪识别与音频事件检测标签。可通过 `python funclip/launch.py -m fun-asr-nano` 或 `python funclip/launch.py -m sensevoice` 启动体验。需要精确按文本裁剪时请使用 Paraformer,因为当前发布的 Nano checkpoint 不提供可靠的字符级时间戳。
- 2024/06/12 FunClip现在支持识别与裁剪英文视频,通过`python funclip/launch.py -l en`来启动英文版本服务。
- 🔥2024/05/13 FunClip v2.0.0加入大语言模型智能裁剪功能,集成qwen系列,gpt系列等模型,提供默认prompt,您也可以探索并分享prompt的设置技巧,使用方法如下:
@@ -75,6 +76,8 @@ cd FunClip
pip install -r ./requirements.txt
```
+如需固定版本,可下载 [FunClip-2.1.0.tar.gz](https://github.com/modelscope/FunClip/releases/download/v2.1.0/FunClip-2.1.0.tar.gz) 或 [FunClip-2.1.0.zip](https://github.com/modelscope/FunClip/releases/download/v2.1.0/FunClip-2.1.0.zip),并使用发布页提供的 [SHA256SUMS](https://github.com/modelscope/FunClip/releases/download/v2.1.0/SHA256SUMS) 校验文件。模型权重会在 FunClip 启动时单独下载,不包含在源码归档中。
+
FunClip 的 Fun-ASR-Nano、SenseVoice 与字幕兼容路径需要 `funasr>=1.3.29`。当 SenseVoice 没有 token 时间戳时,该版本会通过 `sentence_info` 返回每个 VAD 语音区域,让智能剪辑与字幕客户端获得分段边界,而不再收到空时间线;同时包含 1.3.28 的实时最终文本和短尾语音修复。如果你之前已经安装过 FunClip,请先执行 `pip install -U "funasr>=1.3.29"`,再启动 Gradio 服务。[发布说明](https://github.com/modelscope/FunASR/releases/tag/v1.3.29) · [PyPI](https://pypi.org/project/funasr/1.3.29/)
### 安装imagemagick(可选)
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..7ec1d6d
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2.1.0
diff --git a/docs/releases/v2.1.0.md b/docs/releases/v2.1.0.md
new file mode 100644
index 0000000..f741c47
--- /dev/null
+++ b/docs/releases/v2.1.0.md
@@ -0,0 +1,34 @@
+# FunClip v2.1.0
+
+FunClip v2.1.0 is the project's first versioned GitHub release and a stable rollback point for the current local video-clipping application.
+
+## Highlights
+
+- Select Paraformer for precise timestamp-based clipping, Fun-ASR-Nano for high-accuracy transcription, or SenseVoice for multilingual ASR with emotion and audio-event tags.
+- Use transcript-driven LLM clipping through the supported providers, or optional TwelveLabs Pegasus for content-aware video selection.
+- Require `funasr>=1.3.29`, including SenseVoice VAD-region `sentence_info` timestamps plus the real-time final-text and short-tail fixes from 1.3.28.
+- Run the same public application in the [FunClip Hugging Face Space](https://huggingface.co/spaces/FunAudioLLM/FunClip).
+
+## Install
+
+Download either source archive below, verify it with `SHA256SUMS`, extract it, and install the declared dependencies:
+
+```bash
+sha256sum -c SHA256SUMS --ignore-missing
+pip install -r requirements.txt
+python funclip/launch.py
+```
+
+Windows users can verify a downloaded archive with `Get-FileHash -Algorithm SHA256` and compare the result with `SHA256SUMS`.
+
+## Assets
+
+- `FunClip-2.1.0.tar.gz`: versioned source archive for Linux and macOS workflows.
+- `FunClip-2.1.0.zip`: versioned source archive for Windows and general-purpose extraction.
+- `SHA256SUMS`: SHA-256 digests for both archives.
+
+The archives contain the tracked FunClip application source, documentation, and dependency manifest. Runtime dependencies and model weights are not bundled; model weights are not bundled because each model retains its own license and distribution terms.
+
+---
+
+FunClip v2.1.0 是项目首个带版本号的 GitHub Release,为当前本地视频剪辑应用提供稳定下载和回退节点。版本支持 Paraformer、Fun-ASR-Nano、SenseVoice、基于字幕的大模型智能剪辑及可选的 TwelveLabs Pegasus,并要求 `funasr>=1.3.29`。下载 `tar.gz` 或 `zip` 后,请先使用 `SHA256SUMS` 校验,再安装 `requirements.txt`。归档仅包含 Git 已跟踪的应用源码、文档和依赖清单,不包含运行依赖或模型权重。
diff --git a/scripts/build_release_assets.py b/scripts/build_release_assets.py
new file mode 100644
index 0000000..b31b2ae
--- /dev/null
+++ b/scripts/build_release_assets.py
@@ -0,0 +1,140 @@
+import argparse
+import hashlib
+import os
+import re
+import subprocess
+import tarfile
+import tempfile
+import zipfile
+from pathlib import Path
+
+VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
+REQUIRED_FILES = {"VERSION", "README.md", "requirements.txt", "LICENSE"}
+
+
+def git_output(repository, *args):
+ return subprocess.run(
+ ["git", "-C", str(repository), *args],
+ check=True,
+ capture_output=True,
+ text=True,
+ ).stdout
+
+
+def sha256(path):
+ digest = hashlib.sha256()
+ with path.open("rb") as stream:
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
+ digest.update(chunk)
+ return digest.hexdigest()
+
+
+def resolve_commit(repository, ref):
+ try:
+ return git_output(
+ repository, "rev-parse", "--verify", f"{ref}^{{commit}}"
+ ).strip()
+ except subprocess.CalledProcessError as error:
+ raise RuntimeError("release ref must resolve to a commit") from error
+
+
+def archive_members(path):
+ if path.suffix == ".zip":
+ with zipfile.ZipFile(path) as archive:
+ return {name for name in archive.namelist() if not name.endswith("/")}
+ with tarfile.open(path, "r:gz") as archive:
+ return {member.name for member in archive.getmembers() if member.isfile()}
+
+
+def validate_members(members, prefix):
+ if not members or any(not member.startswith(prefix) for member in members):
+ raise RuntimeError(f"release archive contains a path outside {prefix}")
+
+ relative_members = {member.removeprefix(prefix) for member in members}
+ missing = REQUIRED_FILES - relative_members
+ if missing:
+ raise RuntimeError("release archive is missing: " + ", ".join(sorted(missing)))
+
+ unsafe = [
+ member
+ for member in relative_members
+ if ".git" in Path(member).parts
+ or "__pycache__" in Path(member).parts
+ or member.endswith((".pyc", ".pyo"))
+ ]
+ if unsafe:
+ raise RuntimeError(
+ "release archive contains generated metadata: " + ", ".join(unsafe)
+ )
+
+
+def build_release_assets(repository, ref, output_dir):
+ repository = repository.resolve()
+ output_dir = output_dir.resolve()
+ commit = resolve_commit(repository, ref)
+ version = git_output(repository, "show", f"{commit}:VERSION").strip()
+ if not VERSION_PATTERN.fullmatch(version):
+ raise RuntimeError(f"VERSION must be semantic x.y.z, got {version!r}")
+
+ prefix = f"FunClip-{version}/"
+ archive_names = [f"FunClip-{version}.tar.gz", f"FunClip-{version}.zip"]
+ output_dir.mkdir(parents=True, exist_ok=True)
+
+ with tempfile.TemporaryDirectory(
+ prefix=".funclip-release-", dir=output_dir
+ ) as temporary:
+ temporary_dir = Path(temporary)
+ temporary_archives = []
+ for archive_name in archive_names:
+ archive_path = temporary_dir / archive_name
+ archive_format = "zip" if archive_name.endswith(".zip") else "tar.gz"
+ subprocess.run(
+ [
+ "git",
+ "-C",
+ str(repository),
+ "archive",
+ f"--format={archive_format}",
+ f"--prefix={prefix}",
+ f"--output={archive_path}",
+ commit,
+ ],
+ check=True,
+ )
+ validate_members(archive_members(archive_path), prefix)
+ temporary_archives.append(archive_path)
+
+ first_members = archive_members(temporary_archives[0])
+ if archive_members(temporary_archives[1]) != first_members:
+ raise RuntimeError("tar.gz and zip archives contain different files")
+
+ checksum_path = temporary_dir / "SHA256SUMS"
+ checksum_path.write_text(
+ "".join(
+ f"{sha256(archive_path)} {archive_path.name}\n"
+ for archive_path in temporary_archives
+ ),
+ encoding="utf-8",
+ )
+
+ for path in [*temporary_archives, checksum_path]:
+ os.replace(path, output_dir / path.name)
+
+ return [output_dir / name for name in [*archive_names, "SHA256SUMS"]]
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description="Build versioned FunClip release archives"
+ )
+ parser.add_argument("--repository", type=Path, default=Path.cwd())
+ parser.add_argument("--ref", default="HEAD")
+ parser.add_argument("--output-dir", type=Path, default=Path("dist"))
+ args = parser.parse_args()
+
+ for path in build_release_assets(args.repository, args.ref, args.output_dir):
+ print(f"{sha256(path)} {path.name}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/test_release_contract.py b/tests/test_release_contract.py
new file mode 100644
index 0000000..8c6ea08
--- /dev/null
+++ b/tests/test_release_contract.py
@@ -0,0 +1,234 @@
+import hashlib
+import os
+import re
+import subprocess
+import sys
+import tarfile
+import tempfile
+import time
+import zipfile
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[1]
+VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
+
+
+def _git(repository, *args):
+ return subprocess.run(
+ ["git", *args],
+ cwd=repository,
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+
+
+def _sha256(path):
+ return hashlib.sha256(path.read_bytes()).hexdigest()
+
+
+def _create_fixture_repository(repository):
+ repository.mkdir()
+ _git(repository, "init", "-b", "main")
+ _git(repository, "config", "user.name", "FunClip Release Test")
+ _git(repository, "config", "user.email", "[email protected]")
+
+ fixture_files = {
+ "VERSION": "2.1.0\n",
+ "README.md": "# FunClip\n",
+ "requirements.txt": "funasr>=1.3.29\n",
+ "LICENSE": "MIT\n",
+ "funclip/__init__.py": "\n",
+ }
+ for relative_path, content in fixture_files.items():
+ path = repository / relative_path
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(content, encoding="utf-8")
+ _git(repository, "add", ".")
+ _git(repository, "commit", "-m", "fixture")
+
+
+def test_release_version_and_public_download_routes_are_in_sync():
+ version = (ROOT / "VERSION").read_text(encoding="utf-8").strip()
+ assert version == "2.1.0"
+ assert VERSION_PATTERN.fullmatch(version)
+
+ release_url = f"https://github.com/modelscope/FunClip/releases/tag/v{version}"
+ for readme in ("README.md", "README_zh.md"):
+ text = (ROOT / readme).read_text(encoding="utf-8")
+ assert release_url in text
+ assert f"FunClip-{version}.tar.gz" in text
+ assert f"FunClip-{version}.zip" in text
+ assert "SHA256SUMS" in text
+
+
+def test_release_notes_define_installation_and_asset_boundaries():
+ notes = (ROOT / "docs/releases/v2.1.0.md").read_text(encoding="utf-8")
+ assert "funasr>=1.3.29" in notes
+ assert "Fun-ASR-Nano" in notes
+ assert "SenseVoice" in notes
+ assert "TwelveLabs" in notes
+ assert "FunClip-2.1.0.tar.gz" in notes
+ assert "FunClip-2.1.0.zip" in notes
+ assert "SHA256SUMS" in notes
+ assert "model weights are not bundled" in notes
+
+
+def test_tag_workflow_builds_and_publishes_all_release_assets():
+ workflow = (ROOT / ".github/workflows/release.yml").read_text(encoding="utf-8")
+ assert 'tags: ["v*.*.*"]' in workflow
+ assert "contents: write" in workflow
+ assert "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1" in workflow
+ assert "actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97" in workflow
+ assert "actions/checkout@v" not in workflow
+ assert "actions/setup-python@v" not in workflow
+ assert "pytest==8.3.5" in workflow
+ assert "python scripts/build_release_assets.py" in workflow
+ assert "python -m pytest -q tests/test_release_contract.py" in workflow
+ assert "gh release view" in workflow
+ assert "gh release create" in workflow
+ assert "gh release edit" in workflow
+ assert "gh release upload" in workflow
+ assert "--clobber" in workflow
+ assert "--json apiUrl,isDraft,isImmutable" in workflow
+ assert ".apiUrl" in workflow
+ assert ".isDraft" in workflow
+ assert ".isImmutable" in workflow
+ assert "releases/tags/" not in workflow
+ assert "--draft" in workflow
+ assert "--draft=false" in workflow
+ assert "sha256:" in workflow
+ assert "already published and verified" in workflow
+ assert "--verify-tag" in workflow
+ assert "docs/releases/${GITHUB_REF_NAME}.md" in workflow
+ assert "dist/FunClip-*.tar.gz" in workflow
+ assert "dist/FunClip-*.zip" in workflow
+ assert "dist/SHA256SUMS" in workflow
+
+
+def test_release_builder_creates_reproducible_scoped_archives(tmp_path):
+ repository = tmp_path / "fixture"
+ _create_fixture_repository(repository)
+
+ outputs = []
+ for directory_name in ("dist-one", "dist-two"):
+ if outputs:
+ time.sleep(2)
+ output_dir = tmp_path / directory_name
+ subprocess.run(
+ [
+ sys.executable,
+ str(ROOT / "scripts/build_release_assets.py"),
+ "--repository",
+ str(repository),
+ "--ref",
+ "HEAD",
+ "--output-dir",
+ str(output_dir),
+ ],
+ check=True,
+ )
+ outputs.append(output_dir)
+
+ expected_names = {
+ "FunClip-2.1.0.tar.gz",
+ "FunClip-2.1.0.zip",
+ "SHA256SUMS",
+ }
+ assert {path.name for path in outputs[0].iterdir()} == expected_names
+
+ for name in expected_names:
+ assert (outputs[0] / name).read_bytes() == (outputs[1] / name).read_bytes()
+
+ tar_path = outputs[0] / "FunClip-2.1.0.tar.gz"
+ zip_path = outputs[0] / "FunClip-2.1.0.zip"
+ with tarfile.open(tar_path, "r:gz") as archive:
+ tar_members = {
+ member.name for member in archive.getmembers() if member.isfile()
+ }
+ with zipfile.ZipFile(zip_path) as archive:
+ zip_members = {name for name in archive.namelist() if not name.endswith("/")}
+
+ required_members = {
+ "FunClip-2.1.0/VERSION",
+ "FunClip-2.1.0/README.md",
+ "FunClip-2.1.0/requirements.txt",
+ "FunClip-2.1.0/LICENSE",
+ }
+ assert required_members <= tar_members
+ assert tar_members == zip_members
+ assert all(member.startswith("FunClip-2.1.0/") for member in tar_members)
+
+ checksum_lines = (outputs[0] / "SHA256SUMS").read_text().splitlines()
+ assert checksum_lines == [
+ f"{_sha256(tar_path)} {tar_path.name}",
+ f"{_sha256(zip_path)} {zip_path.name}",
+ ]
+
+
+def test_release_builder_rejects_non_commit_refs(tmp_path):
+ repository = tmp_path / "fixture"
+ repository.mkdir()
+ _git(repository, "init", "-b", "main")
+ _git(repository, "config", "user.name", "FunClip Release Test")
+ _git(repository, "config", "user.email", "[email protected]")
+ for relative_path in ("VERSION", "README.md", "requirements.txt", "LICENSE"):
+ (repository / relative_path).write_text("2.1.0\n", encoding="utf-8")
+ _git(repository, "add", ".")
+ tree_ref = _git(repository, "write-tree").stdout.strip()
+
+ result = subprocess.run(
+ [
+ sys.executable,
+ str(ROOT / "scripts/build_release_assets.py"),
+ "--repository",
+ str(repository),
+ "--ref",
+ tree_ref,
+ "--output-dir",
+ str(tmp_path / "dist"),
+ ],
+ capture_output=True,
+ check=False,
+ text=True,
+ )
+
+ assert result.returncode != 0
+ assert "release ref must resolve to a commit" in result.stderr
+
+
+def test_release_builder_supports_cross_filesystem_outputs(tmp_path):
+ cross_filesystem_root = Path("/dev/shm")
+ if not cross_filesystem_root.is_dir() or (
+ os.stat(tmp_path).st_dev == os.stat(cross_filesystem_root).st_dev
+ ):
+ pytest.skip("a second writable filesystem is not available")
+
+ repository = tmp_path / "fixture"
+ _create_fixture_repository(repository)
+ with tempfile.TemporaryDirectory(
+ prefix="funclip-release-test-", dir=cross_filesystem_root
+ ) as temporary:
+ output_dir = Path(temporary) / "dist"
+ result = subprocess.run(
+ [
+ sys.executable,
+ str(ROOT / "scripts/build_release_assets.py"),
+ "--repository",
+ str(repository),
+ "--ref",
+ "HEAD",
+ "--output-dir",
+ str(output_dir),
+ ],
+ capture_output=True,
+ check=False,
+ text=True,
+ )
+
+ assert result.returncode == 0, result.stderr
+ assert (output_dir / "FunClip-2.1.0.tar.gz").is_file()
+ assert (output_dir / "FunClip-2.1.0.zip").is_file()
+ assert (output_dir / "SHA256SUMS").is_file()