Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cstack",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"description": "C-Stack Codex plugin",
"scripts": {
Expand Down
32 changes: 32 additions & 0 deletions tests/version.test.mjs
Original file line number Diff line number Diff line change
@@ -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}`);
});
Loading