Skip to content

Open-source skills for designing and reviewing software with AI agents

Prepare versioned runtime releases

Oliver Newth7b3b4fff713c
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..4204bd4
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,84 @@
+# Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0
+name: Prepare draft release
+
+on:
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: Existing main-branch tag (vMAJOR.MINOR.PATCH)
+ required: true
+ type: string
+
+permissions: {}
+
+concurrency:
+ group: prepare-release-${{ inputs.tag }}
+ cancel-in-progress: false
+
+jobs:
+ build:
+ runs-on: ubuntu-24.04
+ outputs:
+ commit: ${{ steps.source.outputs.commit }}
+ permissions:
+ contents: read
+ steps:
+ - name: Require default-branch workflow
+ env:
+ WORKFLOW_REF: ${{ github.ref }}
+ run: test "$WORKFLOW_REF" = refs/heads/main
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+ - name: Check out an existing tag contained in main
+ id: source
+ env:
+ RELEASE_TAG: ${{ inputs.tag }}
+ run: |
+ [[ "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]
+ git rev-parse --verify "refs/tags/$RELEASE_TAG^{commit}"
+ git merge-base --is-ancestor "refs/tags/$RELEASE_TAG^{commit}" origin/main
+ git checkout --detach "refs/tags/$RELEASE_TAG"
+ echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: '3.12'
+ - run: pip install pytest==8.3.5 pyyaml==6.0.2
+ - run: pytest tests/unit
+ - name: Prepare archives and notes
+ env:
+ RELEASE_TAG: ${{ inputs.tag }}
+ run: python scripts/prepare_release.py --tag "$RELEASE_TAG" --commit "$(git rev-parse HEAD)" --output release
+ - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
+ with:
+ name: release-candidate
+ path: |
+ release/*.zip
+ release/SHA256SUMS
+ release/RELEASE_NOTES.md
+ if-no-files-found: error
+ retention-days: 7
+
+ draft:
+ needs: build
+ runs-on: ubuntu-24.04
+ permissions:
+ actions: read
+ contents: write
+ steps:
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
+ with:
+ name: release-candidate
+ path: release
+ - name: Create draft only
+ env:
+ GH_TOKEN: ${{ github.token }}
+ GH_REPO: ${{ github.repository }}
+ RELEASE_TAG: ${{ inputs.tag }}
+ SOURCE_COMMIT: ${{ needs.build.outputs.commit }}
+ run: |
+ cd release
+ sha256sum -c SHA256SUMS
+ test "$(gh api "repos/$GH_REPO/commits/$RELEASE_TAG" --jq .sha)" = "$SOURCE_COMMIT"
+ gh release create "$RELEASE_TAG" --verify-tag --draft --title "EGM $RELEASE_TAG" --notes-file RELEASE_NOTES.md ./*.zip SHA256SUMS
diff --git a/distributions/claude/docs/releases.md b/distributions/claude/docs/releases.md
new file mode 100644
index 0000000..90a46fb
--- /dev/null
+++ b/distributions/claude/docs/releases.md
@@ -0,0 +1,39 @@
+# Versioned releases
+
+The canonical version is `plugin.json`'s `version`. Claude and Codex manifests
+must match it. Keep one EGM version across these hosts; marketplace catalogs
+without a version field do not need one. Other host adapters need explicit
+packaging and verification before being added to release support.
+
+While EGM is pre-1.0, use patch bumps for compatible fixes and minor bumps for
+features or incompatible workflow changes. Explain breaking changes in release
+notes. Version 1.0 requires a stable contract for skill names, parameters, output
+paths, and report formats. Do not change published artifacts under the same tag.
+
+## Prepare a candidate
+
+1. Update the root, Claude, and Codex manifest versions in a reviewed PR.
+2. Regenerate `distributions/claude` using the runtime builder and run
+ `pytest tests/unit`. Include any migration notes in the PR.
+3. After merge, a maintainer creates and pushes an annotated `vMAJOR.MINOR.PATCH`
+ tag on the selected main commit. Never move an existing release tag.
+4. Run **Prepare draft release** from `main`, supplying that existing tag.
+ The tagged commit must include the release scripts and pass unit tests.
+5. Review the draft's two runtime ZIPs, `SHA256SUMS`, and source commit. Replace
+ placeholder notes with changes, compatibility/migration details, and exact
+ artifact host-verification evidence. Unverified hosts remain unverified.
+6. Publish the draft manually only after review. Directory publication is separate.
+
+The workflow does not create tags, overwrite releases, publish automatically,
+or run paid live tests. A duplicate release attempt fails instead of replacing
+an existing release. Fix a failed build before creating a new candidate version.
+For local preparation, use a fresh output directory:
+
+```sh
+python scripts/prepare_release.py --tag v0.1.0 --commit "$(git rev-parse HEAD)" --output /tmp/egm-0.1.0-candidate
+```
+
+The local command checks manifest versions and builds artifacts; it does not
+verify Git tag ancestry or run tests. Those checks belong to the workflow.
+Exact installed-bundle verification remains tracked in
+[#60](https://github.com/google/elephant-goldfish-model/issues/60).
diff --git a/docs/releases.md b/docs/releases.md
new file mode 100644
index 0000000..90a46fb
--- /dev/null
+++ b/docs/releases.md
@@ -0,0 +1,39 @@
+# Versioned releases
+
+The canonical version is `plugin.json`'s `version`. Claude and Codex manifests
+must match it. Keep one EGM version across these hosts; marketplace catalogs
+without a version field do not need one. Other host adapters need explicit
+packaging and verification before being added to release support.
+
+While EGM is pre-1.0, use patch bumps for compatible fixes and minor bumps for
+features or incompatible workflow changes. Explain breaking changes in release
+notes. Version 1.0 requires a stable contract for skill names, parameters, output
+paths, and report formats. Do not change published artifacts under the same tag.
+
+## Prepare a candidate
+
+1. Update the root, Claude, and Codex manifest versions in a reviewed PR.
+2. Regenerate `distributions/claude` using the runtime builder and run
+ `pytest tests/unit`. Include any migration notes in the PR.
+3. After merge, a maintainer creates and pushes an annotated `vMAJOR.MINOR.PATCH`
+ tag on the selected main commit. Never move an existing release tag.
+4. Run **Prepare draft release** from `main`, supplying that existing tag.
+ The tagged commit must include the release scripts and pass unit tests.
+5. Review the draft's two runtime ZIPs, `SHA256SUMS`, and source commit. Replace
+ placeholder notes with changes, compatibility/migration details, and exact
+ artifact host-verification evidence. Unverified hosts remain unverified.
+6. Publish the draft manually only after review. Directory publication is separate.
+
+The workflow does not create tags, overwrite releases, publish automatically,
+or run paid live tests. A duplicate release attempt fails instead of replacing
+an existing release. Fix a failed build before creating a new candidate version.
+For local preparation, use a fresh output directory:
+
+```sh
+python scripts/prepare_release.py --tag v0.1.0 --commit "$(git rev-parse HEAD)" --output /tmp/egm-0.1.0-candidate
+```
+
+The local command checks manifest versions and builds artifacts; it does not
+verify Git tag ancestry or run tests. Those checks belong to the workflow.
+Exact installed-bundle verification remains tracked in
+[#60](https://github.com/google/elephant-goldfish-model/issues/60).
diff --git a/scripts/prepare_release.py b/scripts/prepare_release.py
new file mode 100644
index 0000000..b9bcd7b
--- /dev/null
+++ b/scripts/prepare_release.py
@@ -0,0 +1,59 @@
+# Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0
+"""Build versioned runtime archives and a checksum manifest for a draft release."""
+
+import argparse
+import hashlib
+import json
+from pathlib import Path
+import re
+
+from pack_plugin import build
+
+
+def version_for_tag(root: Path, tag: str) -> str:
+ """Require a normal vMAJOR.MINOR.PATCH tag matching every shipped manifest."""
+ if not re.fullmatch(r"v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)", tag):
+ raise ValueError("Tag must be vMAJOR.MINOR.PATCH without leading zeroes")
+ version = tag[1:]
+ for relative in ("plugin.json", ".claude-plugin/plugin.json",
+ ".codex-plugin/plugin.json"):
+ manifest = json.loads((root / relative).read_text(encoding="utf-8"))
+ if manifest.get("version") != version:
+ raise ValueError(f"{relative}: version must match {tag}")
+ return version
+
+
+def prepare(root: Path, tag: str, output: Path, commit: str) -> None:
+ """Build into a new directory; never overwrite a previous candidate."""
+ version = version_for_tag(root, tag)
+ if not re.fullmatch(r"[0-9a-f]{40}", commit):
+ raise ValueError("Source commit must be a full Git SHA")
+ output.mkdir(parents=True, exist_ok=False)
+ checksums = []
+ for target in ("claude", "openai"):
+ _, archive = build(root, target, output / "build")
+ destination = output / f"egm-{target}-{version}.zip"
+ archive.rename(destination)
+ digest = hashlib.sha256(destination.read_bytes()).hexdigest()
+ checksums.append(f"{digest} {destination.name}\n")
+ (output / "SHA256SUMS").write_text("".join(checksums), encoding="utf-8")
+ (output / "RELEASE_NOTES.md").write_text(
+ f"# EGM {version}\n\nSource: `{commit}`\nTag: `{tag}`\n\n"
+ "Runtime archives: Claude and OpenAI. Verify downloads with "
+ "`sha256sum -c SHA256SUMS`.\n\n"
+ "## Changes\n\nMaintainer: summarize changes and migration steps before publishing.\n\n"
+ "## Verification\n\nOffline unit tests and runtime packaging are checked by CI. "
+ "Live installation, workflow execution, reviewer isolation, directory approval, "
+ "and cloud-host support are not established by this build. "
+ "Maintainer: attach exact-bundle host evidence and limitations before publishing.\n",
+ encoding="utf-8",
+ )
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--tag", required=True)
+ parser.add_argument("--commit", required=True)
+ parser.add_argument("--output", type=Path, required=True)
+ args = parser.parse_args()
+ prepare(Path(__file__).resolve().parents[1], args.tag, args.output, args.commit)
diff --git a/tests/unit/test_releases.py b/tests/unit/test_releases.py
new file mode 100644
index 0000000..a829cf1
--- /dev/null
+++ b/tests/unit/test_releases.py
@@ -0,0 +1,67 @@
+# Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0
+"""Version agreement, release identities, and archive checksum contracts."""
+
+import hashlib
+import json
+from pathlib import Path
+import runpy
+import zipfile
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[2]
+
+
+def release(monkeypatch: pytest.MonkeyPatch) -> dict:
+ monkeypatch.syspath_prepend(str(ROOT / "scripts"))
+ return runpy.run_path(str(ROOT / "scripts/prepare_release.py"))
+
+
[email protected]("tag", ["0.1.0", "v01.1.0", "v0.1.0-rc.1", "v0.1.0;echo bad"])
+def test_reject_invalid_tag(release: dict, tag: str) -> None:
+ with pytest.raises(ValueError, match="Tag must"):
+ release["version_for_tag"](ROOT, tag)
+
+
+def test_release_version_matches_source(release: dict) -> None:
+ version = json.loads((ROOT / "plugin.json").read_text())["version"]
+ assert release["version_for_tag"](ROOT, f"v{version}") == version
+
+
+def test_reject_host_version_drift(release: dict, tmp_path: Path) -> None:
+ for name in ("plugin.json", ".claude-plugin/plugin.json", ".codex-plugin/plugin.json"):
+ path = tmp_path / name
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(json.dumps({"version": "0.1.0"}))
+ (tmp_path / ".codex-plugin/plugin.json").write_text('{"version":"0.2.0"}')
+ with pytest.raises(ValueError, match="codex-plugin"):
+ release["version_for_tag"](tmp_path, "v0.1.0")
+
+
+def test_prepare_exact_archives(release: dict, tmp_path: Path) -> None:
+ version = json.loads((ROOT / "plugin.json").read_text())["version"]
+ destination = tmp_path / "release"
+ commit = "a" * 40
+ release["prepare"](ROOT, f"v{version}", destination, commit)
+ sums = (destination / "SHA256SUMS").read_text().splitlines()
+ assert len(sums) == 2
+ for line in sums:
+ digest, name = line.split(" ")
+ assert name in {f"egm-claude-{version}.zip", f"egm-openai-{version}.zip"}
+ archive = destination / name
+ assert hashlib.sha256(archive.read_bytes()).hexdigest() == digest
+ with zipfile.ZipFile(archive) as bundle:
+ assert bundle.testzip() is None
+ assert json.loads(bundle.read("plugin.json"))["version"] == version
+ assert commit in (destination / "RELEASE_NOTES.md").read_text()
+ with pytest.raises(FileExistsError):
+ release["prepare"](ROOT, f"v{version}", destination, commit)
+
+
+def test_reject_invalid_commit_without_writing(release: dict, tmp_path: Path) -> None:
+ version = json.loads((ROOT / "plugin.json").read_text())["version"]
+ destination = tmp_path / "release"
+ with pytest.raises(ValueError, match="Git SHA"):
+ release["prepare"](ROOT, f"v{version}", destination, "HEAD")
+ assert not destination.exists()