diff --git a/.gitattributes b/.gitattributes index 4f60070f77..e1e18ca6f3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,8 +20,9 @@ CMakeLists.txt text eol=lf # Adopted measurement manifests hash exact bytes; keep their artifacts unchanged. workbench/measurements/** -text -# Claude's plugin directory refuses a repository whose GitHub archive exceeds -# 50 MiB, and this one was at 50.4. These ~8 MB of README media are copies of -# files in public/, served from the tree (README, raw.githubusercontent links), -# never from an archive, so leaving them out of archives costs nothing. +# These ~8 MB of README media are copies of files in public/, served from the +# tree (README, raw.githubusercontent links), never from an archive, so leaving +# them out of archives costs nothing. This rule does not make the repository +# submittable to Claude's plugin directory, which refuses any `export-ignore`: +# the plugin is submitted from its mirror instead (.github/workflows/plugin-mirror.yml). docs/assets/** export-ignore diff --git a/.github/scripts/set-release-version.mjs b/.github/scripts/set-release-version.mjs index 1baf9ca4cf..82956f0181 100644 --- a/.github/scripts/set-release-version.mjs +++ b/.github/scripts/set-release-version.mjs @@ -18,7 +18,7 @@ // test pins that: if npm ever changes how it formats a lockfile, a release // commit would otherwise silently become a 40k-line reformat. -import { readFileSync, writeFileSync } from "node:fs"; +import { existsSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { argv } from "node:process"; @@ -32,6 +32,15 @@ import { argv } from "node:process"; // build metadata or a leading "v" would be a caller bug, not a version to honour. const RELEASE_VERSION = /^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/; +// The Claude Code and Codex plugin manifests. Claude's plugin directory only +// publishes a new plugin version when `version` goes up, so the plugin is +// versioned with the app. Only stable versions reach them: the plugin is +// mirrored from main, and a prerelease never lands there. +const PLUGIN_MANIFESTS = ["plugin/.claude-plugin/plugin.json", "plugin/.codex-plugin/plugin.json"]; +// Both are hand-formatted (one-line objects and arrays) that JSON.stringify +// would reflow, so only the version's own line is rewritten. +const PLUGIN_VERSION_LINE = /^(\t"version": )"[^"]*"/m; + export function setReleaseVersion(version, dir) { if (!version) throw new Error("a version is required"); // Truthiness alone let 123, " " and "not-a-version" through into both @@ -66,6 +75,18 @@ export function setReleaseVersion(version, dir) { ); } + const plugins = /-/.test(version) + ? [] + : PLUGIN_MANIFESTS.map((name) => join(dir, name)) + .filter((file) => existsSync(file)) + .map((file) => { + const text = readFileSync(file, "utf8"); + if (!PLUGIN_VERSION_LINE.test(text)) { + throw new Error(`${file} has no top-level "version" line to update`); + } + return { file, text: text.replace(PLUGIN_VERSION_LINE, `$1${JSON.stringify(version)}`) }; + }); + pkg.json.version = version; lock.json.version = version; lock.json.packages[""].version = version; @@ -73,6 +94,9 @@ export function setReleaseVersion(version, dir) { for (const { file, json } of [pkg, lock]) { writeFileSync(file, `${JSON.stringify(json, null, "\t")}\n`); } + for (const { file, text } of plugins) { + writeFileSync(file, text); + } } // Only run when invoked directly, so the test can import the function. @@ -83,5 +107,7 @@ if (import.meta.filename === argv[1]) { process.exit(1); } setReleaseVersion(version, process.cwd()); - console.log(`version ${version} set in package.json and package-lock.json`); + console.log( + `version ${version} set in package.json, package-lock.json and, for a stable version, the plugin manifests`, + ); } diff --git a/.github/scripts/set-release-version.test.mjs b/.github/scripts/set-release-version.test.mjs index 77d69e64ed..d7c32d5d9b 100644 --- a/.github/scripts/set-release-version.test.mjs +++ b/.github/scripts/set-release-version.test.mjs @@ -151,4 +151,47 @@ describe("setReleaseVersion", () => { expect(JSON.parse(read("package.json")).version).toBe("1.9.0"); expect(JSON.parse(read("package-lock.json")).packages[""].version).toBe("1.9.0"); }); + // Claude's plugin directory publishes a plugin version only when `version` + // goes up, so a stable release carries the plugin manifests with it. + describe("plugin manifests", () => { + const manifest = [ + "{", + '\t"name": "openscreen",', + '\t"version": "1.8.0",', + '\t"author": { "name": "Etienne Lescot", "url": "https://getopenscreen.com" },', + '\t"keywords": ["demo video", "screen recording"]', + "}", + "", + ].join("\n"); + const files = ["plugin/.claude-plugin/plugin.json", "plugin/.codex-plugin/plugin.json"]; + + beforeEach(() => { + for (const name of files) { + mkdirSync(join(dir, name, ".."), { recursive: true }); + writeFileSync(join(dir, name), manifest); + } + }); + + it("sets a stable version on the version line alone", () => { + setReleaseVersion("1.9.0", dir); + + for (const name of files) { + expect(read(name)).toBe(manifest.replace('"version": "1.8.0"', '"version": "1.9.0"')); + } + }); + + it("leaves them alone for a prerelease", () => { + setReleaseVersion("1.9.0-rc.1", dir); + + for (const name of files) expect(read(name)).toBe(manifest); + }); + + it("writes nothing when a manifest has no version line", () => { + writeFileSync(join(dir, files[1]), '{\n\t"name": "openscreen"\n}\n'); + + expect(() => setReleaseVersion("1.9.0", dir)).toThrow(/no top-level "version" line/); + expect(JSON.parse(read("package.json")).version).toBe("1.8.0"); + expect(read(files[0])).toBe(manifest); + }); + }); }); diff --git a/.github/workflows/plugin-mirror.yml b/.github/workflows/plugin-mirror.yml new file mode 100644 index 0000000000..b307fc876c --- /dev/null +++ b/.github/workflows/plugin-mirror.yml @@ -0,0 +1,109 @@ +name: Plugin mirror + +# Claude's plugin directory cannot validate this repository: its GitHub archive +# is over the directory's 50 MiB limit without the `export-ignore` rule in +# .gitattributes, and the directory refuses any repository whose .gitattributes +# uses `export-ignore` at all. A plugin in a subfolder is also always held for a +# reviewer. So the plugin is submitted from a small repository of its own, +# getopenscreen/openscreen-plugin, that holds plugin/ at its root. +# +# plugin/ stays the source of truth: never edit the mirror by hand, every push +# here overwrites it. The directory rescans the mirror on each push to it. +# +# Setup (once): create getopenscreen/openscreen-plugin, add a deploy key with +# write access to it, and store the private key here as the +# PLUGIN_MIRROR_DEPLOY_KEY secret. + +on: + push: + branches: [main] + paths: + - "plugin/**" + - "LICENSE" + - "package.json" + - ".github/workflows/plugin-mirror.yml" + pull_request: + branches: [main] + paths: + - "plugin/**" + - "package.json" + - ".github/workflows/plugin-mirror.yml" + workflow_dispatch: + +# Publishing runs (pushes and dispatches on main) queue in one group; every +# other run gets a group of its own, so it can never take the place of a +# pending publication. +concurrency: + group: plugin-mirror-${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && 'publish' || github.ref }} + cancel-in-progress: false + +permissions: + contents: read + +jobs: + mirror: + name: Check and mirror the plugin + runs-on: ubuntu-latest + steps: + # A publishing run builds from main's tip, not from the commit that queued + # it, so a run that starts late can never put older content back. + - uses: actions/checkout@v7 + with: + ref: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && 'main' || '' }} + + # The directory only publishes a new version when `version` goes up, so + # the plugin's version follows the app's, released together. + - name: Check the plugin's version matches the app's + run: | + node -e ' + const read = (f) => JSON.parse(require("fs").readFileSync(f, "utf8")); + const app = read("package.json").version; + const bad = ["plugin/.claude-plugin/plugin.json", "plugin/.codex-plugin/plugin.json"] + .map((f) => [f, read(f).version]) + .filter(([, v]) => v !== app); + for (const [f, v] of bad) console.log(`::error file=${f}::version is ${v}, the app is ${app}`); + process.exit(bad.length ? 1 : 0); + ' + + - name: Build the mirror's tree + run: | + mkdir -p "$RUNNER_TEMP/mirror" "$RUNNER_TEMP/tree" + # evals/ is development tooling (prompts, graders, mocks) and does not + # ship to users. + cp -a plugin/. "$RUNNER_TEMP/tree/" + rm -rf "$RUNNER_TEMP/tree/evals" + cp LICENSE "$RUNNER_TEMP/tree/LICENSE" + + - name: Push to getopenscreen/openscreen-plugin + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'getopenscreen/openscreen' + env: + DEPLOY_KEY: ${{ secrets.PLUGIN_MIRROR_DEPLOY_KEY }} + run: | + if [ -z "$DEPLOY_KEY" ]; then + echo "::warning::PLUGIN_MIRROR_DEPLOY_KEY is not set, so the mirror was not updated." + exit 0 + fi + install -m 700 -d ~/.ssh + printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/mirror_key + chmod 600 ~/.ssh/mirror_key + ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null + export GIT_SSH_COMMAND="ssh -i ~/.ssh/mirror_key -o IdentitiesOnly=yes" + + cd "$RUNNER_TEMP/mirror" + if git clone --depth 1 git@github.com:getopenscreen/openscreen-plugin.git repo 2>/dev/null; then + cd repo + else + mkdir repo && cd repo && git init -q -b main + git remote add origin git@github.com:getopenscreen/openscreen-plugin.git + fi + find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + + cp -a "$RUNNER_TEMP/tree/." . + git add -A + if git diff --cached --quiet; then + echo "The mirror is already up to date." + exit 0 + fi + git -c user.name="github-actions[bot]" \ + -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ + commit -q -m "Mirror plugin/ from getopenscreen/openscreen@${GITHUB_SHA::7}" + git push origin HEAD:main diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 43b4b19b1c..6873fc41c2 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -93,7 +93,7 @@ jobs: bash "$RUNNER_TEMP/refresh-nix-npm-hash.sh" git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add package.json package-lock.json nix/package.nix + git add package.json package-lock.json nix/package.nix plugin/.claude-plugin/plugin.json plugin/.codex-plugin/plugin.json git commit --allow-empty -m "chore(release): bump to ${STABLE_VERSION} [skip ci]" || true git push "https://x-access-token:${TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$BRANCH" @@ -206,7 +206,7 @@ jobs: # The lockfile's version is part of Nix's npm hash, and the hash must match # main's lockfile, not the release's. bash .github/scripts/refresh-nix-npm-hash.sh - git add package.json package-lock.json nix/package.nix + git add package.json package-lock.json nix/package.nix plugin/.claude-plugin/plugin.json plugin/.codex-plugin/plugin.json git commit -m "chore(release): release v${STABLE_VERSION} into main" # --force: a rerun commits again on top of a newer main. git push --force "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "${BRANCH}-sync" diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json index c64b2a5cef..c2730b2193 100644 --- a/plugin/.claude-plugin/plugin.json +++ b/plugin/.claude-plugin/plugin.json @@ -2,9 +2,19 @@ "name": "openscreen", "displayName": "OpenScreen", "description": "Make a demo video from one sentence: record the screen, edit and export it with OpenScreen.", + "version": "2.4.0", "author": { "name": "Etienne Lescot", "url": "https://getopenscreen.com" }, "homepage": "https://getopenscreen.com/docs/ai-editing", "repository": "https://github.com/getopenscreen/openscreen", "license": "MIT", - "keywords": ["demo video", "screen recording", "video editing", "pull request"] + "keywords": ["demo video", "screen recording", "video editing", "pull request"], + "network": { + "hosts": [ + "github.com", + "api.github.com", + "uploads.github.com", + "objects.githubusercontent.com", + "release-assets.githubusercontent.com" + ] + } } diff --git a/plugin/.codex-plugin/plugin.json b/plugin/.codex-plugin/plugin.json index d181ddcc0f..653e7a41b5 100644 --- a/plugin/.codex-plugin/plugin.json +++ b/plugin/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "openscreen", - "version": "2.3.0", + "version": "2.4.0", "description": "Make a demo video from one sentence: record the screen, edit and export it with OpenScreen.", "author": { "name": "Etienne Lescot", "url": "https://getopenscreen.com" }, "homepage": "https://getopenscreen.com/docs/ai-editing",