From 92d9055c039c2961777e754bca8d3b7f1f789f33 Mon Sep 17 00:00:00 2001 From: Camgineer Date: Mon, 14 Sep 2026 14:17:09 -0400 Subject: [PATCH] chore(cstack): bump to 0.2.0 and require version changes on main Keep plugin.json and package.json on the same semver. Tag vX.Y.Z after each main merge. --- .codex-plugin/plugin.json | 2 +- .github/workflows/version.yml | 37 +++++++++++++++++++++++++++++++++++ package.json | 2 +- tests/version.test.mjs | 32 ++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/version.yml create mode 100644 tests/version.test.mjs diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 38f5167..6610fca 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "cstack", - "version": "0.1.0", + "version": "0.2.0", "description": "Codex plugin packaging PStack, Cursor Team Kit, and Matt Pocock skills.", "author": { "name": "Camgineer", diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..c37d1f8 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,37 @@ +name: Version +on: + pull_request: + branches: [main] + push: + branches: [main] +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: "20" + - run: node --test tests/version.test.mjs tests/inventory.test.mjs tests/cstack-default-mode.test.mjs + env: + CSTACK_VERSION_BASE: ${{ github.event.pull_request.base.sha }} + tag: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: check + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Tag the plugin version + run: | + version=$(node -p "require('./package.json').version") + git fetch --tags + if git rev-parse "v$version" >/dev/null 2>&1; then + echo "tag v$version already exists" + exit 0 + fi + git tag "v$version" + git push origin "v$version" diff --git a/package.json b/package.json index e164d4e..a869d45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cstack", - "version": "0.1.0", + "version": "0.2.0", "private": true, "description": "C-Stack Codex plugin", "scripts": { diff --git a/tests/version.test.mjs b/tests/version.test.mjs new file mode 100644 index 0000000..1c3feda --- /dev/null +++ b/tests/version.test.mjs @@ -0,0 +1,32 @@ +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; +import { promises as fs } from "node:fs"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const readJson = async (relative) => JSON.parse(await fs.readFile(path.join(root, relative), "utf8")); + +test("plugin and package versions match and use semver", async () => { + const [plugin, pkg] = await Promise.all([ + readJson(".codex-plugin/plugin.json"), + readJson("package.json"), + ]); + assert.match(plugin.version, /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/); + assert.equal(plugin.version, pkg.version); +}); + +test("a pull request against main bumps the plugin version", async () => { + const eventPath = process.env.GITHUB_EVENT_PATH; + const base = process.env.CSTACK_VERSION_BASE || (eventPath ? JSON.parse(await fs.readFile(eventPath, "utf8")).pull_request?.base?.sha : null); + if (!base) { + const plugin = await readJson(".codex-plugin/plugin.json"); + assert.match(plugin.version, /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/); + return; + } + const head = JSON.parse(await fs.readFile(path.join(root, ".codex-plugin/plugin.json"), "utf8")).version; + const old = execFileSync("git", ["show", `${base}:.codex-plugin/plugin.json`], { cwd: root, encoding: "utf8" }); + const previous = JSON.parse(old).version; + assert.notEqual(head, previous, `plugin version must change from ${previous}`); +});