diff --git a/.github/scripts/published.mjs b/.github/scripts/published.mjs new file mode 100644 index 0000000..7478dbb --- /dev/null +++ b/.github/scripts/published.mjs @@ -0,0 +1,13 @@ +import { readFile, appendFile } from 'node:fs/promises'; +const manifest = JSON.parse(await readFile('package.json', 'utf8')); +const url = `https://registry.npmjs.org/${manifest.name.replace('/', '%2F')}/${manifest.version}`; +const response = await fetch(url, { headers: { 'Cache-Control': 'no-cache' } }); +if (response.status === 404) { + await appendFile(process.env.GITHUB_OUTPUT, 'published=false\n'); +} else { + if (!response.ok) throw new Error(`Registry check failed: ${response.status}`); + const published = await response.json(); + if (published.pi?.image !== manifest.pi?.image) throw new Error('The existing npm version has different preview metadata; bump the package version.'); + await appendFile(process.env.GITHUB_OUTPUT, 'published=true\n'); + console.log(`${manifest.name}@${manifest.version} is already published with the expected cover metadata.`); +} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..f8773bc --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,20 @@ +name: Checks +on: [push, pull_request] +permissions: + contents: read +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + - uses: actions/setup-node@v5 + with: + node-version: 24 + cache: npm + - run: npm ci --ignore-scripts + - run: npm run check + - run: npm test --if-present + - run: npm run check:package diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8e377e2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: Publish package +on: + push: + tags: ['v*'] + workflow_dispatch: +permissions: + contents: read +concurrency: + group: publish-${{ github.repository }}-${{ github.ref }} + cancel-in-progress: false +jobs: + publish: + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + - uses: actions/setup-node@v5 + with: + 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: Check an existing release + id: registry + run: node .github/scripts/published.mjs + - if: steps.registry.outputs.published != 'true' + run: npm ci --ignore-scripts + - if: steps.registry.outputs.published != 'true' + run: npm run check + - if: steps.registry.outputs.published != 'true' + run: npm test --if-present + - if: steps.registry.outputs.published != 'true' + run: npm run check:package + - if: steps.registry.outputs.published != 'true' + run: npm publish --provenance --access public diff --git a/CHANGELOG.md b/CHANGELOG.md index 7981ce5..a867fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.2.1 + +- Add the English package cover to the README, npm archive, and Pi gallery metadata. +- Publish matching version tags through the package GitHub Actions workflow. + + ## 0.2.0 - `/sync` opens the shared docked panel: connection status, the last sync's file changes, pending and failed packages, and the one action to take. Press `l` to login, `s` to sync (preview only), `y` to sync and install new packages, `x` to logout. Login still uses the link+code flow, surfaced through a notice. Replaces the old `/pi-sync` text-only command. diff --git a/README.md b/README.md index 9804c5b..d80a68e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # pi-sync +[![pi-sync — for PI Agent](https://raw.githubusercontent.com/prjct-app/pi-sync/main/docs/cover.png)](https://pi.dev) + Keeps Pi's portable configuration the same on every machine you use: settings, `AGENTS.md`, MCP and model config, and the extensions that are on. It also installs the packages listed in `settings.json`. ## Commands diff --git a/docs/cover.png b/docs/cover.png new file mode 100644 index 0000000..9ced8ec Binary files /dev/null and b/docs/cover.png differ diff --git a/package-lock.json b/package-lock.json index c0eda71..72e98cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@prjct.app/pi-sync", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@prjct.app/pi-sync", - "version": "0.2.0", + "version": "0.2.1", "license": "MIT", "dependencies": { "@prjct.app/pi-tui-kit": "^0.3.5" diff --git a/package.json b/package.json index be2c2da..9e7ce44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prjct.app/pi-sync", - "version": "0.2.0", + "version": "0.2.1", "description": "Export and import the portable Pi configuration (settings, AGENTS.md, extensions, MCP and model config) between machines. Never exports auth or sessions.", "type": "module", "keywords": [ @@ -13,12 +13,14 @@ "pi": { "extensions": [ "./index.ts" - ] + ], + "image": "https://raw.githubusercontent.com/prjct-app/pi-sync/main/docs/cover.png" }, "scripts": { "test": "export PI_CODING_AGENT_DIR=\"$(mktemp -d)\" PRJCT_HOME=\"$(mktemp -d)\" && node --import tsx --test tests/*.test.ts", "check": "tsc --noEmit && npm run check:immutable", - "check:immutable": "! grep -rn '\\blet\\b' src/ index.ts || (echo 'Use const and immutable values: no let bindings in src/ or index.ts' && exit 1)" + "check:immutable": "! grep -rn '\\blet\\b' src/ index.ts || (echo 'Use const and immutable values: no let bindings in src/ or index.ts' && exit 1)", + "check:package": "npm pack --dry-run --ignore-scripts" }, "engines": { "node": ">=22.19.0" @@ -38,7 +40,8 @@ "LICENSE", "README.md", "index.ts", - "src" + "src", + "docs/cover.png" ], "exports": { ".": "./index.ts"