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
3 changes: 3 additions & 0 deletions .github/scripts/release-source.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (process.env.GITHUB_REF !== 'refs/heads/main') {
throw new Error('Publish only from main after the reviewed changes have been merged.');
}
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish package
on:
push:
tags: ['v*']
branches: [main]
workflow_dispatch:
permissions:
contents: read
Expand All @@ -24,8 +24,8 @@ jobs:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Verify release tag
run: node --input-type=module -e 'import fs from "node:fs"; const p = JSON.parse(fs.readFileSync("package.json")); if (process.env.GITHUB_REF !== `refs/tags/v${p.version}`) throw new Error("Publish from the matching version tag");'
- name: Verify release source
run: node .github/scripts/release-source.mjs
- name: Check an existing release
id: registry
run: node .github/scripts/published.mjs
Expand Down
6 changes: 5 additions & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ Every list/read/delete includes an account filter. The previous link, token and

## 3. Publish or activate the extension

Deploying the backend does not replace an installed npm package. Publish an appropriately versioned package through the normal release process, or explicitly configure the reviewed local checkout for testing. Do not overwrite a user's package installation or change their settings implicitly.
Deploying the backend does not replace an installed npm package. Merge the reviewed version bump to `main`: the `Publish package` workflow checks and publishes that version automatically. Tags are not required. An already-published version is skipped; manual workflow retries must also target `main`.

The npm package must authorize GitHub trusted publishing for owner `prjct-app`, repository `pi-sync`, workflow `publish.yml`, without an environment name, and allow direct `npm publish`. The workflow uses OIDC and provenance, not a personal npm login or a stored npm token. GitHub repository access alone does not grant npm publishing permission.

For local testing, explicitly configure the reviewed checkout. Do not overwrite a user's package installation or change their settings implicitly.

The user experience is then only: `/sync` → Back up this machine; on another machine, `/sync` → select the dated backup → Restore → one confirmation. Packages install and Pi reloads automatically.

Expand Down
19 changes: 19 additions & 0 deletions tests/release.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { test } from 'node:test';

const verify = (ref: string) => spawnSync(process.execPath, ['.github/scripts/release-source.mjs'], {
env: { ...process.env, GITHUB_REF: ref }, encoding: 'utf8',
});

test('publication accepts the main branch used after a merge', () => {
assert.equal(verify('refs/heads/main').status, 0);
});

test('publication rejects tags, feature branches, pull requests, and missing refs', () => {
for (const ref of ['refs/tags/v0.3.0', 'refs/heads/feature', 'refs/pull/1/merge', '']) {
const result = verify(ref);
assert.notEqual(result.status, 0);
assert.match(result.stderr, /Publish only from main/);
}
});
Loading