Multiplayer agent harness for work.
Publish the deployment CLI to npm with provenance (#10)
Joshua France57367e3370a9
diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.ymlnew file mode 100644index 000000000..495900ddd--- /dev/null+++ b/.github/workflows/publish-cli.yml@@ -0,0 +1,34 @@+name: Publish the QM CLI++on:+ workflow_dispatch:++permissions:+ contents: read+ id-token: write++jobs:+ package:+ if: github.ref == 'refs/heads/main'+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd+ with:+ persist-credentials: false+ - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444+ with:+ node-version-file: .node-version+ registry-url: https://registry.npmjs.org+ cache: npm+ cache-dependency-path: cli/package-lock.json+ - name: Install, typecheck, packed-artifact test+ working-directory: cli+ run: |+ npm ci+ npm run typecheck+ npm run test:pack+ - name: Publish+ working-directory: cli+ run: npm publish --provenance --access public+ env:+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}diff --git a/cli/README.md b/cli/README.mdindex 1d29fd2e0..6e87fbefa 100644--- a/cli/README.md+++ b/cli/README.md@@ -18,10 +18,11 @@ npm exec qm -- up --yesnpm exec qm -- check --live```-This package is private and is never published to a registry. First-party image-publication is a release operation outside this repository change. The checked-in-image manifest is a sentinel that a deployment overrides with real digests. The-packed-artifact test exercises the consumer path locally.+This package is published to npm as `@yc-software/qm`, with npm provenance attesting the+building workflow. First-party image publication is a separate release operation run by+`.github/workflows/release-package.yml`. The checked-in image manifest is a sentinel that+a deployment overrides with real digests. The packed-artifact test exercises the consumer+path locally.The CLI deploys long-running QM services; it is not the runtime. Docker runsthem locally, Fly runs them as Fly apps with Fly Machines for agent computers, and AWSdiff --git a/cli/package.json b/cli/package.jsonindex a14e2e85b..ac84bbca3 100644--- a/cli/package.json+++ b/cli/package.json@@ -1,10 +1,20 @@{"name": "@yc-software/qm","version": "0.1.0",- "private": true,"license": "MIT","description": "Control-plane CLI for portable QM deployments on Docker, Fly, and AWS.","type": "module",+ "repository": {+ "type": "git",+ "url": "git+https://github.com/yc-software/qm.git",+ "directory": "cli"+ },+ "homepage": "https://github.com/yc-software/qm/tree/main/cli#readme",+ "bugs": "https://github.com/yc-software/qm/issues",+ "publishConfig": {+ "access": "public",+ "provenance": true+ },"bin": {"qm": "dist/bin/qm.js"},diff --git a/test/release-workflows.test.ts b/test/release-workflows.test.tsindex b33dbfd22..31398fdae 100644--- a/test/release-workflows.test.ts+++ b/test/release-workflows.test.ts@@ -44,17 +44,32 @@ test("the release signs private images without requiring anonymous registry acceassert.ok(workflow.indexOf("docker/build-push-action") < workflow.indexOf("Sign exact image"));});-test("the CLI package cannot be published to a registry", () => {+test("the CLI package publishes publicly with provenance", () => {const manifest = JSON.parse(readFileSync("cli/package.json", "utf8")) as {private?: boolean;- publishConfig?: unknown;+ repository?: { url?: string; directory?: string };+ publishConfig?: { access?: string; provenance?: boolean };scripts?: Record<string, string>;};- assert.equal(manifest.private, true);- assert.equal(manifest.publishConfig, undefined);- assert.equal(manifest.scripts?.prepublishOnly, undefined);+ assert.equal(manifest.private, undefined);+ assert.equal(manifest.publishConfig?.access, "public");+ assert.equal(manifest.publishConfig?.provenance, true);+ assert.equal(manifest.repository?.url, "git+https://github.com/yc-software/qm.git");+ assert.equal(manifest.repository?.directory, "cli");assert.equal(manifest.scripts?.["verify:release"], undefined);assert.equal(existsSync("cli/scripts/verify-release-manifest.mjs"), false);assert.equal(existsSync("scripts/prepare-release-manifest.mjs"), false);});++test("publishing the CLI is a separate, attested, main-only operation", () => {+ const workflow = readFileSync(".github/workflows/publish-cli.yml", "utf8");++ assert.match(workflow, /^on:\n {2}workflow_dispatch:$/m);+ assert.match(workflow, /if: github\.ref == 'refs\/heads\/main'/);+ assert.match(workflow, /permissions:\s+contents: read\s+id-token: write/);+ assert.match(workflow, /registry-url: https:\/\/registry\.npmjs\.org/);+ assert.match(workflow, /npm publish --provenance --access public/);+ assert.match(workflow, /NODE_AUTH_TOKEN: \$\{\{ secrets\.NPM_TOKEN \}\}/);+ assert.doesNotMatch(workflow, /packages: write/);+});diff --git a/test/removed-features.test.ts b/test/removed-features.test.tsindex de110c4e4..cc229a382 100644--- a/test/removed-features.test.ts+++ b/test/removed-features.test.ts@@ -157,7 +157,6 @@ test("active source and public documentation do not expose retired credential fe["prepare", "-release-manifest"].join(""),["verify", "-release-manifest"].join(""),["prepublish", "Only"].join(""),- ["npm ", "publish"].join(""),].map((value) => value.toLowerCase());const matches = paths.flatMap((path) => {const source = readFileSync(path, "utf8").toLowerCase();