From 95e062f5727818834d8ded80a5a85d1f3807e684 Mon Sep 17 00:00:00 2001 From: ben kelly Date: Fri, 28 Aug 2026 09:37:10 +0100 Subject: [PATCH] Add CI that tests every change and publishes from main Test job runs the self-check on pull requests and on main. It needs no dependencies and no lockfile, and it passes with no device and no socket attached, reporting both as absent. Publish job uses npm trusted publishing over OIDC, so there is no token to store or rotate, and a YubiKey cannot be tapped from CI anyway. npm adds provenance automatically for a public repo published this way. Publishing an existing version fails with 409, so the job only publishes when the version in package.json differs from the registry. Bump the version in the pull request and merging it releases. That suits the branch ruleset, which requires a pull request and blocks direct pushes to main. Drop npm ci from the published example, since this package has no dependencies and no lockfile. Point the test script at node rather than bun, because the plugin now uses only Node standard library modules and node is always present on the runner. --- .github/workflows/ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4e609ab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: "24" + # The package has no dependencies and no lockfile, so there is nothing to install. + # The self-check needs no device and no socket: it reports both as absent and exits 0. + - run: npm test + + publish: + needs: test + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + id-token: write # required for npm trusted publishing over OIDC + contents: read + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: "24" + registry-url: "https://registry.npmjs.org" + package-manager-cache: false # never cache in a release build + + # Publishing a version that already exists fails with 409, so only publish when the + # version in package.json differs from the registry. Bump the version in the pull + # request, and the merge releases it. + - id: version + run: | + local_version=$(node -p "require('./package.json').version") + remote_version=$(npm view opencode-sidepulse version 2>/dev/null || echo none) + echo "local=$local_version remote=$remote_version" + if [ "$local_version" = "$remote_version" ]; then + echo "changed=false" >> "$GITHUB_OUTPUT" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + # No NODE_AUTH_TOKEN. OIDC authenticates this workflow, and npm adds provenance. + - if: steps.version.outputs.changed == 'true' + run: npm publish diff --git a/package.json b/package.json index 543e87d..f013f19 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,6 @@ "LICENSE" ], "scripts": { - "test": "bun plugin.mjs" + "test": "node plugin.mjs" } }