Skip to content

Local video editor for coding agents: 42 FFmpeg tools with a machine-readable contract and an MCP server, for Claude Code, Cursor and Codex. Cut, captions, reframe, loudness, platform exports. No cloud, no API keys.

Auto-bump the release version too, not just tag/release/npm publish (#129)

Shogo Kajiyamabae10b1e680f
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
index 54794ec..0b9d772 100644
--- a/.github/release-drafter.yml
+++ b/.github/release-drafter.yml
@@ -1,9 +1,11 @@
-# Config for release-drafter/release-drafter. Maintains a running DRAFT release (updated on
-# every push to main) summarizing merged PRs since the last tag -- a cross-check against
-# CHANGELOG.md's hand-written notes, not a replacement for them. Actual publishing still stays a
-# deliberate, manual act: tag a commit (`git tag vX.Y.Z && git push origin vX.Y.Z`), which
-# .github/workflows/release.yml picks up and publishes using CHANGELOG.md's own section for that
-# version. This draft is never auto-published.
+# Config for release-drafter/release-drafter, used two ways:
+# - release-drafter.yml (the workflow) runs it live on every push to main, keeping a running
+# DRAFT release as a human-readable cross-check -- this draft is never auto-published.
+# - release.yml runs it with dry-run: true to resolve the *actual* next version (via
+# version-resolver below) whenever nobody bumped package.json by hand, then bumps the
+# version and writes CHANGELOG.md itself and releases for real. So the labels below (and
+# "default: patch" for an unlabeled PR) now drive real releases, not just this draft --
+# label a PR "minor"/"feature"/"major" when it needs more than a patch bump.
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
categories:
@@ -45,4 +47,5 @@ template: |
$CHANGES
- Cross-check this against CHANGELOG.md's own entry for this version before tagging a release.
+ Cross-check this against CHANGELOG.md's entry for this version (release.yml writes it
+ automatically unless a PR already bumped package.json and wrote its own).
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
index aaba78a..faf2e2d 100644
--- a/.github/workflows/release-drafter.yml
+++ b/.github/workflows/release-drafter.yml
@@ -1,7 +1,10 @@
# Keeps a draft GitHub Release up to date with merged-PR summaries as main moves forward. This is
-# purely a convenience cross-check against CHANGELOG.md's hand-written notes -- it never publishes
-# anything itself; publishing a real release stays the deliberate, manual `git tag` act described
-# in release.yml / README's "Development" -> "Releasing" section.
+# purely a human-readable cross-check against CHANGELOG.md -- both the hand-written sections a PR
+# may still add itself and the ones release.yml now generates automatically -- and it never
+# publishes anything itself. release.yml is the one that actually decides and cuts a release; it
+# uses this same repo's release-drafter.yml config (via its own dry-run call) to resolve the next
+# version, it doesn't read this draft. See release.yml / README's "Development" -> "Releasing"
+# section for the real, fully-automated release flow.
#
# push-to-main only, deliberately: release-drafter reads its config from the DEFAULT branch, so a
# pull_request trigger fails with "Configuration file .github/release-drafter.yml is not found"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 96ed45c..6db4583 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,20 +1,39 @@
name: release
-# Fully automated release: on every push to main, if package.json's current
-# version has no matching vX.Y.Z tag yet, this creates that tag, publishes a
-# GitHub Release (notes taken from CHANGELOG.md's matching section) and
-# publishes to npm -- all in one job. Bumping package.json's version (and
-# writing the matching CHANGELOG.md section) stays a deliberate, manual part
-# of each PR: this workflow only reacts to that bump already having landed on
-# main, it never chooses a version number itself. A push to main whose
-# version is already tagged (most pushes, since not every PR bumps the
-# version) is a no-op: every step below is skipped.
+# Fully automated release: on every push to main, this decides the next version
+# itself, then creates the vX.Y.Z tag, publishes a GitHub Release, and publishes
+# to npm -- all in one job. Nothing about a release needs to be done by hand
+# anymore, PR merges are the only input:
+#
+# - If package.json's version still matches the latest release tag (the
+# normal case -- nobody touched it in the merged PR), this job asks
+# release-drafter to resolve the next version from the labels on every PR
+# merged since that tag (same major/minor/patch rules as
+# .github/release-drafter.yml; an unlabeled PR defaults to patch), bumps
+# package.json and docs/contract.md to that version, writes a CHANGELOG.md
+# section listing those merged PRs, and pushes that bump commit to main
+# itself before continuing -- see "Auto-bump" below.
+# - If a PR *did* bump package.json's version by hand (and, by this repo's
+# convention, wrote its own CHANGELOG.md section and docs/contract.md
+# edits), that manual choice is left alone and used as-is -- auto-bump
+# only fills in when nobody made the call already.
+#
+# Either way, once package.json's version has no matching tag, this creates
+# that tag, publishes a GitHub Release with notes extracted from
+# CHANGELOG.md's matching section, and publishes to npm. A push to main that
+# ends up not changing the version at all (nothing mergeable since the last
+# release, e.g. this very bump commit -- see below) is a no-op: every
+# remaining step is skipped.
#
# This runs as one job triggered directly by the push to main, not chained
-# through a separate tag-push trigger, because a tag pushed by the built-in
-# GITHUB_TOKEN does not itself trigger another workflow run (a deliberate
-# GitHub Actions anti-recursion rule) -- splitting this into "push a tag" /
-# "react to that tag" workflows would silently never fire the second one.
+# through a separate tag-push trigger, because a tag (or, now, a bump commit)
+# pushed by the built-in GITHUB_TOKEN does not itself trigger another workflow
+# run (a deliberate GitHub Actions anti-recursion rule) -- splitting any of
+# this into "push a commit/tag" / "react to that push" workflows would
+# silently never fire the second one. That anti-recursion rule is also why
+# the auto-bump commit below is safe to push straight from this job without
+# looping: it never starts a second run of this workflow, this same run just
+# continues on past it with the new version.
on:
push:
@@ -22,7 +41,8 @@ on:
permissions:
contents: write
- id-token: write # required for `npm publish --provenance`
+ pull-requests: read # release-drafter reads merged PRs' labels to resolve the next version
+ id-token: write # required for `npm publish --provenance`
jobs:
release:
@@ -32,6 +52,105 @@ jobs:
with:
fetch-depth: 0
+ - name: Decide whether an automatic version bump is needed
+ id: setup
+ run: |
+ PKG_VERSION=$(node -p "require('./package.json').version")
+ LAST_TAG=$(git tag --list 'v*' --sort=-v:refname | head -n1)
+ LAST_VERSION="${LAST_TAG#v}"
+ LAST_VERSION="${LAST_VERSION:-0.0.0}"
+ echo "pkg_version=$PKG_VERSION" >> "$GITHUB_OUTPUT"
+ echo "last_version=$LAST_VERSION" >> "$GITHUB_OUTPUT"
+ if [ "$PKG_VERSION" = "$LAST_VERSION" ]; then
+ echo "needs_auto_bump=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "needs_auto_bump=false" >> "$GITHUB_OUTPUT"
+ fi
+
+ # Computes (but does not publish or tag) the next version from the labels on every
+ # PR merged since the last vX.Y.Z tag, using the same rules as release-drafter.yml /
+ # release-drafter.yml's own always-on draft release. dry-run: true makes this call
+ # read-only.
+ - name: Resolve the next version from merged PR labels
+ id: drafter
+ if: steps.setup.outputs.needs_auto_bump == 'true'
+ uses: release-drafter/release-drafter@v6
+ with:
+ dry-run: true
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ # Nobody bumped package.json by hand, and release-drafter found something new to
+ # release: bump package.json/docs/contract.md ourselves and write a CHANGELOG.md
+ # section listing the merged PRs (and any issues they closed) since the last tag,
+ # then push that commit to main before the rest of this job continues. Reads PR
+ # titles via `git log` at runtime rather than interpolating them into this script,
+ # since PR titles are attacker-controlled text and GitHub Actions expression
+ # interpolation into a run: block is a known script-injection vector -- only our own
+ # already-resolved, numeric version strings pass through ${{ }} here.
+ - name: Auto-bump package.json / docs/contract.md / CHANGELOG.md
+ if: |
+ steps.setup.outputs.needs_auto_bump == 'true' &&
+ steps.drafter.outputs.resolved_version != '' &&
+ steps.drafter.outputs.resolved_version != steps.setup.outputs.last_version
+ env:
+ OLD_VERSION: ${{ steps.setup.outputs.last_version }}
+ NEW_VERSION: ${{ steps.drafter.outputs.resolved_version }}
+ run: |
+ python3 - <<'PY'
+ import os, re, subprocess, pathlib
+
+ old = os.environ["OLD_VERSION"]
+ new = os.environ["NEW_VERSION"]
+ root = pathlib.Path(".")
+
+ pkg_path = root / "package.json"
+ pkg = pkg_path.read_text(encoding="utf-8")
+ pkg_new = re.sub(r'("version":\s*")[^"]+(")', rf'\g<1>{new}\g<2>', pkg, count=1)
+ assert pkg != pkg_new, "package.json version field not found/replaced"
+ pkg_path.write_text(pkg_new, encoding="utf-8")
+
+ contract_path = root / "docs" / "contract.md"
+ contract = contract_path.read_text(encoding="utf-8")
+ contract_path.write_text(contract.replace(old, new), encoding="utf-8")
+
+ last_tag = f"v{old}" if old != "0.0.0" else None
+ rev_range = f"{last_tag}..HEAD" if last_tag else "HEAD"
+ log = subprocess.run(
+ ["git", "log", rev_range, "--format=%s----BODY----%b----COMMIT----"],
+ capture_output=True, text=True, check=True,
+ ).stdout
+ commits = [c for c in log.split("----COMMIT----") if c.strip()]
+ subjects, issues = [], set()
+ for c in commits:
+ subject, _, body = c.partition("----BODY----")
+ subject = subject.strip()
+ if subject:
+ subjects.append(subject)
+ issues.update(int(n) for n in re.findall(r"(?im)^closes\s+#(\d+)\.?\s*$", body))
+
+ bullets = "\n".join(f"- {s}" for s in subjects) or "- (no commit subjects found)"
+ closes_line = f"\n\nCloses: {', '.join(f'#{n}' for n in sorted(issues))}" if issues else ""
+ section = (
+ f"## {new}\n\n"
+ f"_Automated release: version and notes generated from pull requests merged "
+ f"since {old}._\n\n"
+ f"{bullets}{closes_line}\n\n"
+ )
+
+ changelog_path = root / "CHANGELOG.md"
+ changelog = changelog_path.read_text(encoding="utf-8")
+ anchor = "## Unreleased\n\n(nothing yet)\n\n"
+ assert anchor in changelog, "CHANGELOG.md's Unreleased anchor not found"
+ changelog_path.write_text(changelog.replace(anchor, anchor + section, 1), encoding="utf-8")
+ PY
+
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git add package.json docs/contract.md CHANGELOG.md
+ git commit -m "chore(release): bump version to ${NEW_VERSION}"
+ git push origin HEAD:main
+
- name: Check whether this version is already released
id: check
run: |
diff --git a/README.md b/README.md
index b4b2574..503496b 100644
--- a/README.md
+++ b/README.md
@@ -395,7 +395,7 @@ CI (`.github/workflows/ci.yml`) runs on every pull request and on pushes to `mai
`tests/test_contract.py` runs on all three OSes, but a handful of its tests build a fake `ffmpeg` as a `#!/bin/sh` script on a PATH shim to force specific FFmpeg 6/7/8/9 fixture layouts through `doctor`'s parser — that technique isn't portable to Windows, so `test_dry_run_never_runs_ffmpeg_and_writes_nothing` and the whole `DoctorDetectionTests` class (fixture-driven layout parsing) are individually `skipIf`'d there and show as `skipped`, not silently absent, in the Windows job's log. Everything else — contract schema, `reencodes_*`, `doctor.tools`, MCP derivation, and every tool exercised through the contract, including `cut.py`'s provenance fields — runs against the real Windows `ffmpeg` on every PR. See [references/ci-platform-pitfalls.md](references/ci-platform-pitfalls.md) for this and other per-OS behaviour differences already diagnosed, before spending a CI cycle re-diagnosing a platform-only failure.
-**Releasing** is fully automated: bump `version` in `package.json` and add the matching `CHANGELOG.md` section in a PR, same as any other change. Once that PR merges to `main`, `.github/workflows/release.yml` takes it from there — no manual tag, no manual npm publish. It checks whether the new version already has a `vX.Y.Z` tag; if not, it creates that tag, publishes a GitHub Release with notes extracted from `CHANGELOG.md`'s matching section, and publishes the package to npm. A push to `main` that doesn't bump the version is a no-op release-wise. npm publishing needs an `NPM_TOKEN` repo secret (an npm access token with publish rights on this package) — without it the tag and GitHub Release still happen, only the npm step is skipped. A repo that depends on this one (an editing skill, an agent) should pin an `ffmpeg-skill` version by tag or npm version, not by tracking `main` — a merged-but-not-yet-released commit on `main` can be ahead of the last published npm version for the few minutes between merge and this workflow completing.
+**Releasing** is fully automated end to end, including the version number itself — a PR doesn't need to touch `package.json`, `docs/contract.md`, or `CHANGELOG.md` at all. Once a PR merges to `main`, `.github/workflows/release.yml` takes it from there: if nobody bumped the version by hand, it asks [release-drafter](.github/release-drafter.yml) to resolve the next version from the labels on every PR merged since the last tag (`major`/`minor`/`feature`/`enhancement`/`fix`/`bug`/... — an unlabeled PR defaults to `patch`), bumps `package.json` and `docs/contract.md`, writes a `CHANGELOG.md` section listing those PRs (and any issues they closed), and pushes that commit to `main` itself. Either way — auto-bumped or hand-bumped in the PR — it then creates the `vX.Y.Z` tag, publishes a GitHub Release with notes extracted from `CHANGELOG.md`'s matching section, and publishes the package to npm. A PR that still wants to write its own version bump and `CHANGELOG.md` prose (e.g. to explain the "why" of a release by hand) can — the automation only fills in when nobody made that call already. A push to `main` with nothing new to release is a no-op. npm publishing needs an `NPM_TOKEN` repo secret (an npm access token with publish rights on this package) — without it the tag and GitHub Release still happen, only the npm step is skipped. A repo that depends on this one (an editing skill, an agent) should pin an `ffmpeg-skill` version by tag or npm version, not by tracking `main` — a merged-but-not-yet-released commit on `main` can be ahead of the last published npm version for the few minutes between merge and this workflow completing.
Contributing a change: see [CONTRIBUTING.md](CONTRIBUTING.md).