diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b11903fa5..e53c361de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,12 +7,13 @@ on: # Manual backfill: republish an already-cut release to a channel that # missed it. Fill in only the channel(s) you want — an empty input leaves # that channel's jobs skipped. npm reuses the existing release's binary - # assets, so it only works for releases cut after the Twigpine rename (their - # archives are named twigpine-node-*); docker rebuilds the image from the tag and re-tags the manifest. + # assets, so it only works for releases cut after the Twigpine rename (v0.8.0 + # or later, whose archives are named twigpine-node-*); docker rebuilds the + # image from the tag and re-tags the manifest. workflow_dispatch: inputs: npm_backfill_tag: - description: "Existing release tag to publish to npm (e.g. v0.6.0)" + description: "Existing release tag to publish to npm (v0.8.0 or later, e.g. v0.9.0)" required: false type: string docker_backfill_tag: @@ -38,8 +39,9 @@ permissions: {} jobs: release-please: # Skipped on manual dispatch: a backfill must never create or advance a - # release PR as a side effect (npm-publish tolerates the skipped need via - # !cancelled(), and every other job gates on release_created == 'true'). + # release PR as a side effect (docker, docker-manifest and npm-publish-cli + # tolerate the skipped need via !cancelled(); the other jobs gate on + # release_created == 'true'). if: ${{ github.repository == 'Twigpine/node' && github.event_name != 'workflow_dispatch' }} name: Release Please runs-on: ubuntu-latest @@ -627,186 +629,11 @@ jobs: dist/*.zip dist/*.sha256 - npm-publish: - name: Publish to npm - needs: [release-please, release-binaries] - # Runs on a fresh release, or on manual dispatch for an existing tag - # (release-binaries is skipped on dispatch, hence !cancelled()). Publishing - # auth is npm Trusted Publishing (GitHub OIDC) — no NPM_TOKEN. Each - # @gitlawb package must have this repo + workflow (release.yml) configured - # as its trusted publisher on npmjs.com, scoped to the release environment - # so a dispatched copy of this file on another ref cannot mint a token, or - # publish fails loudly here — - # deliberately loud: the silent secret-guard skip is how 0.4.x–0.6.0 - # never reached npm. - if: >- - ${{ !cancelled() && ( - (needs.release-please.outputs.release_created == 'true' && needs.release-binaries.result == 'success') || - (github.event_name == 'workflow_dispatch' && inputs.npm_backfill_tag != '') - ) }} - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write # npm trusted publishing (OIDC) + provenance - environment: release - steps: - - name: Check out workflow scripts - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - with: - persist-credentials: false - - - name: Resolve release tag - id: rel - env: - DISPATCH_TAG: ${{ inputs.npm_backfill_tag }} - RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -euo pipefail - scripts/resolve-release-tag.sh "${DISPATCH_TAG:-$RELEASE_TAG}" - - - name: Checkout release tag - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - with: - # Pin the commit the resolver verified; a tag ref re-resolved here - # could have been moved between resolve and checkout. - ref: ${{ steps.rel.outputs.tag_commit || format('refs/tags/{0}', steps.rel.outputs.tag) }} - persist-credentials: false - - # npm >= 11.5.1 performs the OIDC token exchange automatically when the - # package has a trusted publisher configured; older npm silently falls - # back to (absent) token auth and fails confusingly. - - name: Set up Node 24 + OIDC-capable npm - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 - with: - node-version: "24" - - name: Ensure npm supports trusted publishing - run: | - set -euo pipefail - npm install -g npm@11.19.1 - # Assert the pin took, so an accidental unpin or a drift off 11.19.1 - # fails loudly here instead of silently running a different npm on - # the OIDC path. - installed="$(npm --version)" - echo "npm installed: $installed" - if [ "$installed" != "11.19.1" ]; then - echo "::error::npm is not the pinned 11.19.1 (got: $installed)" - exit 1 - fi - - - name: Lay in release binaries - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ steps.rel.outputs.version }} - TAG: ${{ steps.rel.outputs.tag }} - ASSETS: ${{ steps.rel.outputs.assets }} - run: | - set -euo pipefail - # npm platform package -> Rust target triple (unix only; Windows is not - # published to npm). - MAP=" - gl-darwin-arm64:aarch64-apple-darwin - gl-darwin-x64:x86_64-apple-darwin - gl-linux-arm64:aarch64-unknown-linux-musl - gl-linux-x64:x86_64-unknown-linux-musl - " - mkdir -p _dl - for entry in $MAP; do - pkg="${entry%%:*}" - target="${entry#*:}" - archive="twigpine-node-${VERSION}-${target}.tar.gz" - echo "==> $pkg <- $archive" - # Download by the asset id the resolver captured and uploader- - # checked, not by name: release assets are mutable, and an id can - # only ever point at the exact blob captured at resolve time. - # The map keys are base64-encoded asset names. - want="$(printf '%s' "$archive" | base64 -w0)" - asset_id="$(printf '%s\n' "$ASSETS" | awk -v n="$want" '$1 == n {print $2; exit}')" - if [ -z "$asset_id" ]; then - echo "::error::release $TAG has no asset $archive captured at resolve time" - exit 1 - fi - gh api "repos/$GITHUB_REPOSITORY/releases/assets/$asset_id" \ - -H 'Accept: application/octet-stream' > "_dl/$archive" - tar -xzf "_dl/$archive" -C _dl - src="_dl/twigpine-node-${VERSION}-${target}" - cp "$src/twigpine" "npm/packages/$pkg/gl" - cp "$src/git-remote-twigpine" "npm/packages/$pkg/git-remote-gitlawb" - chmod +x "npm/packages/$pkg/gl" "npm/packages/$pkg/git-remote-gitlawb" - done - - - name: Set versions - env: - VERSION: ${{ steps.rel.outputs.version }} - run: | - set -euo pipefail - node -e ' - const fs = require("fs"); - const v = process.env.VERSION; - for (const p of fs.readdirSync("npm/packages")) { - const f = `npm/packages/${p}/package.json`; - const pkg = JSON.parse(fs.readFileSync(f, "utf8")); - pkg.version = v; - if (pkg.optionalDependencies) { - for (const k of Object.keys(pkg.optionalDependencies)) { - pkg.optionalDependencies[k] = v; - } - } - fs.writeFileSync(f, JSON.stringify(pkg, null, 2) + "\n"); - } - ' - - - name: Publish - env: - VERSION: ${{ steps.rel.outputs.version }} - run: | - set -euo pipefail - # No token: npm exchanges this job's GitHub OIDC identity with the - # registry (trusted publishing); provenance is attested automatically. - # Platform packages first, then the wrapper (so its optionalDependencies resolve). - # Skip versions already on the registry so a rerun after a partial publish - # is idempotent instead of erroring on the first existing package. - # npm publish moves the latest dist-tag to whatever it publishes, so a - # backfilled older version would hand :latest to stale code. Decide - # the dist-tag per package from that package's own registry latest: - # a partial publish can leave the platform packages ahead of the - # wrapper. E404 means the package has never been published, so this - # release gets latest; any other lookup failure must fail closed - # rather than guess at the dist-tag and risk moving latest backward. - # stderr goes to a file so a warning on a successful lookup cannot - # leak into registry_latest; it is read only when the lookup fails. - npm_err="$(mktemp)" - trap 'rm -f -- "$npm_err"' EXIT - for pkg in gl-darwin-arm64 gl-darwin-x64 gl-linux-arm64 gl-linux-x64 gl; do - name="@gitlawb/$pkg" - if npm view "$name@$VERSION" version >/dev/null 2>&1; then - echo "==> $name@$VERSION already published, skipping" - continue - fi - registry_latest="$(npm view "$name" dist-tags.latest 2>"$npm_err")" || { - if ! grep -q E404 "$npm_err"; then - cat "$npm_err" >&2 - echo "::error::npm dist-tags lookup failed for $name; not guessing the dist-tag" - exit 1 - fi - registry_latest="" - } - dist_tag="latest" - if [ -n "$registry_latest" ] && \ - [ "$VERSION" != "$(printf '%s\n%s\n' "$registry_latest" "$VERSION" | sort -V | tail -1)" ]; then - dist_tag="backfill" - echo "::notice::$VERSION is older than $name@$registry_latest; publishing under dist-tag backfill" - fi - echo "==> npm publish $name@$VERSION (dist-tag $dist_tag)" - npm publish "npm/packages/$pkg" --provenance --access public --tag "$dist_tag" - done - npm-publish-cli: # @twigpine/cli: one package, a wrapper plus a platform version per target, # no install script (docs/NPM_PACKAGING.md). Its own environment so its # trusted publisher and approval are separate from the rest of the release. - # The @gitlawb/gl job above stays for one more release, as the bridge that - # points existing installs at this package, and is then removed. + # (It replaced the @gitlawb/gl job, removed after the 0.9.0 bridge release.) name: Publish @twigpine/cli to npm needs: [release-please, release-binaries] if: >- diff --git a/README.md b/README.md index 3b71f5df4..225f16c0c 100644 --- a/README.md +++ b/README.md @@ -128,8 +128,8 @@ docker compose down The command is `twigpine`. Every install method also provides `twig` as a short form and `gl`, the name used before the rename. ```bash -# npm (macOS / Linux) -npm install -g @gitlawb/gl +# npm (macOS / Linux / Windows) +npm install -g @twigpine/cli # Homebrew (macOS / Linux) brew install twigpine/tap/gl diff --git a/docs/LEGACY-NAMES.md b/docs/LEGACY-NAMES.md index c43d35f47..605e6ebf5 100644 --- a/docs/LEGACY-NAMES.md +++ b/docs/LEGACY-NAMES.md @@ -52,9 +52,9 @@ Readers accept both spellings today, through `twigpine_core::url_scheme`. | `X-Gitlawb-*` headers | `twigpine-core/src/legacy_headers.rs` | | `gl`, `git-remote-gitlawb`, `gitlawb-node` command names | Installers, Homebrew formula, Docker image, npm package. `git-remote-gitlawb` stays as long as `gitlawb://` remotes exist. | -## Being retired +## Retired -- The npm package `@gitlawb/gl`, replaced by `@twigpine/cli`: published once more as a bridge, then deprecated (`docs/NPM_PACKAGING.md`). The CLI points users of the old package at the new one. +- The npm package `@gitlawb/gl`, replaced by `@twigpine/cli`: last published as the 0.9.0 bridge, every version deprecated, sources and release job removed (`docs/NPM_PACKAGING.md`). Until 1.0 the CLI still points users of an old npm install at the new package (`twigpine-cli/src/main.rs`). ## Not decided yet diff --git a/docs/NPM_PACKAGING.md b/docs/NPM_PACKAGING.md index da380c33b..da2fbccb1 100644 --- a/docs/NPM_PACKAGING.md +++ b/docs/NPM_PACKAGING.md @@ -1,7 +1,7 @@ # npm packaging How `@twigpine/cli` is put together on npm and the rules the release pipeline -follows. Read this before touching `npm/cli/`, `scripts/npm/`, or the npm jobs +follows. Read this before touching `npm/cli/`, `scripts/npm/`, or the npm job in `.github/workflows/release.yml`. The design is the one Zero uses (`Twigpine/zero`, `docs/NPM_PACKAGING.md`), without Zero's vendored helpers and without a fallback downloader. @@ -130,8 +130,7 @@ Done once, by a maintainer, in this order: deleted and created again (which starts a new two days). Until then the `npm-publish-cli` job fails on its own; the rest of the release -is unaffected. The `npm-publish` job publishing `@gitlawb/gl` needs that -package's trusted publishers to name `Twigpine/node` the same way. +is unaffected. ## The move from `@gitlawb/gl` @@ -144,19 +143,18 @@ npm uninstall -g @gitlawb/gl npm install -g @twigpine/cli ``` -To reach existing users: +How existing users were reached (done): -- The first release that publishes `@twigpine/cli` also publishes - `@gitlawb/gl` once more (the `npm-publish` job), so `npm update -g +- 0.9.0, the first release that published `@twigpine/cli`, also published + `@gitlawb/gl` once more (the old `npm-publish` job), so `npm update -g @gitlawb/gl` installs something and shows its deprecation message. - A CLI installed from `@gitlawb/gl` prints the two commands above on a terminal. -- After that release, in one change: the `npm-publish` job and - `npm/packages/` are removed, a maintainer deprecates every `@gitlawb/gl*` - version with a pointer to `@twigpine/cli`, and the install line in the - README and the website moves to `@twigpine/cli`. Keep removing the job and - deprecating together: `npm deprecate` marks only versions that exist, and - while the job is in `release.yml`, every release and every - `npm_backfill_tag` dispatch (which both jobs read) would publish a new - `@gitlawb/gl` version without the deprecation. The old versions stay on the - registry: existing installs resolve their platform packages through them. +- After that release, together: every `@gitlawb/gl*` version was deprecated + with a pointer to `@twigpine/cli` (2026-12-04), the old `npm-publish` job and + `npm/packages/` were removed, and the install line in the README and the + website moved to `@twigpine/cli`. They belong together: `npm deprecate` + marks only versions that exist, and while that job was in `release.yml`, + every release and every `npm_backfill_tag` dispatch would have published a + new `@gitlawb/gl` version without the deprecation. The old versions stay on + the registry: existing installs resolve their platform packages through them. diff --git a/npm/.gitignore b/npm/.gitignore index c113adb7a..c2658d7d1 100644 --- a/npm/.gitignore +++ b/npm/.gitignore @@ -1,15 +1 @@ node_modules/ - -# Platform binaries — laid in by the release workflow at publish time, not committed. -packages/gl-darwin-arm64/gl -packages/gl-darwin-arm64/git-remote-gitlawb -packages/gl-darwin-x64/gl -packages/gl-darwin-x64/git-remote-gitlawb -packages/gl-linux-arm64/gl -packages/gl-linux-arm64/git-remote-gitlawb -packages/gl-linux-x64/gl -packages/gl-linux-x64/git-remote-gitlawb - -# The wrapper's bin/ placeholders are committed: npm links commands before the -# install step runs and skips any whose file is missing. install.js overwrites -# them with the real programs. diff --git a/npm/README.md b/npm/README.md index 4ac5150ba..5bcabf8dc 100644 --- a/npm/README.md +++ b/npm/README.md @@ -1,13 +1,11 @@ # npm distribution for the Twigpine CLI -Two packages are built from this directory. The full description, publishing +The package is built from this directory. The full description, publishing rules and one-time setup are in [`docs/NPM_PACKAGING.md`](../docs/NPM_PACKAGING.md). ```text cli/ @twigpine/cli the package: launchers + manifest; the release job adds one payload per platform -packages/ @gitlawb/gl the old package, published once more as a - bridge to @twigpine/cli, then removed ``` ## `@twigpine/cli` @@ -25,10 +23,9 @@ the release archives, `scripts/npm/publish-packages.sh` publishes them, and release. The `version` in `cli/package.json` is a placeholder; the release version comes from the tag. -## `@gitlawb/gl` (being retired) +## `@gitlawb/gl` (retired) -A wrapper whose `postinstall` (`packages/gl/install.js`) copied the programs -out of four `@gitlawb/gl-` packages. npm links commands before -`postinstall` runs, so `packages/gl/bin/` holds placeholders for npm to link, -which `install.js` overwrites. The `npm-publish` job publishes it for one more -release, after which it is deprecated and this directory and that job go. +The package before the rename. Its last version is 0.9.0, published as a +bridge alongside the first `@twigpine/cli`; every version is deprecated with a +pointer to `@twigpine/cli`, and its sources and release job are gone. The old +versions stay on the registry so existing installs keep working. diff --git a/npm/packages/gl-darwin-arm64/package.json b/npm/packages/gl-darwin-arm64/package.json deleted file mode 100644 index 92ee55167..000000000 --- a/npm/packages/gl-darwin-arm64/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@gitlawb/gl-darwin-arm64", - "version": "0.3.9", - "description": "Twigpine CLI binary for macOS Apple Silicon (arm64)", - "license": "MIT", - "os": ["darwin"], - "cpu": ["arm64"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "https://github.com/Twigpine/node", - "directory": "npm/packages/gl-darwin-arm64" - }, - "files": [ - "gl", - "git-remote-gitlawb" - ] -} diff --git a/npm/packages/gl-darwin-x64/package.json b/npm/packages/gl-darwin-x64/package.json deleted file mode 100644 index 339b27866..000000000 --- a/npm/packages/gl-darwin-x64/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@gitlawb/gl-darwin-x64", - "version": "0.3.9", - "description": "Twigpine CLI binary for macOS Intel (x64)", - "license": "MIT", - "os": ["darwin"], - "cpu": ["x64"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "https://github.com/Twigpine/node", - "directory": "npm/packages/gl-darwin-x64" - }, - "files": [ - "gl", - "git-remote-gitlawb" - ] -} diff --git a/npm/packages/gl-linux-arm64/package.json b/npm/packages/gl-linux-arm64/package.json deleted file mode 100644 index 9a90568fd..000000000 --- a/npm/packages/gl-linux-arm64/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@gitlawb/gl-linux-arm64", - "version": "0.3.9", - "description": "Twigpine CLI binary for Linux arm64", - "license": "MIT", - "os": ["linux"], - "cpu": ["arm64"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "https://github.com/Twigpine/node", - "directory": "npm/packages/gl-linux-arm64" - }, - "files": [ - "gl", - "git-remote-gitlawb" - ] -} diff --git a/npm/packages/gl-linux-x64/package.json b/npm/packages/gl-linux-x64/package.json deleted file mode 100644 index 70ab82dee..000000000 --- a/npm/packages/gl-linux-x64/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@gitlawb/gl-linux-x64", - "version": "0.3.9", - "description": "Twigpine CLI binary for Linux x64", - "license": "MIT", - "os": ["linux"], - "cpu": ["x64"], - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "https://github.com/Twigpine/node", - "directory": "npm/packages/gl-linux-x64" - }, - "files": [ - "gl", - "git-remote-gitlawb" - ] -} diff --git a/npm/packages/gl/README.md b/npm/packages/gl/README.md deleted file mode 100644 index 89bf2f3d5..000000000 --- a/npm/packages/gl/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# @gitlawb/gl - -> **This package is replaced by [`@twigpine/cli`](https://www.npmjs.com/package/@twigpine/cli).** Both provide the same commands, so uninstall this one first: -> `npm uninstall -g @gitlawb/gl && npm install -g @twigpine/cli` - -The [Twigpine](https://twigpine.com) CLI — decentralized git for AI agents and developers. - -## Install - -```bash -# macOS / Linux / WSL -npm install -g @gitlawb/gl -``` - -Also works with yarn, pnpm, and bun: - -```bash -# macOS / Linux / WSL -yarn global add @gitlawb/gl -pnpm add -g @gitlawb/gl -bun add -g @gitlawb/gl -``` - -Native Windows is not supported via npm — use the PowerShell installer below. - -### Other install methods - -```bash -# Homebrew -brew install twigpine/tap/gl - -# curl (macOS / Linux) -curl -fsSL https://twigpine.com/install.sh | sh - -# PowerShell (Windows) -irm https://twigpine.com/install.ps1 | iex -``` - -## Quick start - -```bash -gl identity new -gl register -gl doctor -gl repo create my-project --description "My first Twigpine repo" -git remote add gitlawb gitlawb://my-project -git push gitlawb main -``` - -## What's included - -- **`gl`** — the main CLI for identity, repos, PRs, bounties, and agents -- **`git-remote-gitlawb`** — git remote helper for `gitlawb://` URLs - -## Supported platforms - -| Platform | Architecture | Package | -|----------|-------------|---------| -| macOS | Apple Silicon (arm64) | `@gitlawb/gl-darwin-arm64` | -| macOS | Intel (x64) | `@gitlawb/gl-darwin-x64` | -| Linux | arm64 | `@gitlawb/gl-linux-arm64` | -| Linux | x64 | `@gitlawb/gl-linux-x64` | - -Windows is supported via the PowerShell installer or WSL. - -## Links - -- Docs: https://docs.gitlawb.com -- Site: https://twigpine.com -- Source: https://github.com/Twigpine/node diff --git a/npm/packages/gl/bin/.gitkeep b/npm/packages/gl/bin/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/npm/packages/gl/bin/git-remote-gitlawb b/npm/packages/gl/bin/git-remote-gitlawb deleted file mode 100755 index d0c13fe27..000000000 --- a/npm/packages/gl/bin/git-remote-gitlawb +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Placeholder. npm links each command before the install step runs, and skips -# a command whose file is missing, so this file has to exist in the package. -# The install step (install.js) replaces it with the real program. -echo "@gitlawb/gl: the install step did not run, so this command is not set up." >&2 -echo "Reinstall with scripts allowed: npm install -g @gitlawb/gl --no-ignore-scripts --allow-scripts=@gitlawb/gl" >&2 -echo "or install without npm: curl -fsSL https://twigpine.com/install.sh | sh" >&2 -exit 1 diff --git a/npm/packages/gl/bin/git-remote-twigpine b/npm/packages/gl/bin/git-remote-twigpine deleted file mode 100755 index d0c13fe27..000000000 --- a/npm/packages/gl/bin/git-remote-twigpine +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Placeholder. npm links each command before the install step runs, and skips -# a command whose file is missing, so this file has to exist in the package. -# The install step (install.js) replaces it with the real program. -echo "@gitlawb/gl: the install step did not run, so this command is not set up." >&2 -echo "Reinstall with scripts allowed: npm install -g @gitlawb/gl --no-ignore-scripts --allow-scripts=@gitlawb/gl" >&2 -echo "or install without npm: curl -fsSL https://twigpine.com/install.sh | sh" >&2 -exit 1 diff --git a/npm/packages/gl/bin/gl b/npm/packages/gl/bin/gl deleted file mode 100755 index d0c13fe27..000000000 --- a/npm/packages/gl/bin/gl +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Placeholder. npm links each command before the install step runs, and skips -# a command whose file is missing, so this file has to exist in the package. -# The install step (install.js) replaces it with the real program. -echo "@gitlawb/gl: the install step did not run, so this command is not set up." >&2 -echo "Reinstall with scripts allowed: npm install -g @gitlawb/gl --no-ignore-scripts --allow-scripts=@gitlawb/gl" >&2 -echo "or install without npm: curl -fsSL https://twigpine.com/install.sh | sh" >&2 -exit 1 diff --git a/npm/packages/gl/bin/twigpine b/npm/packages/gl/bin/twigpine deleted file mode 100755 index d0c13fe27..000000000 --- a/npm/packages/gl/bin/twigpine +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Placeholder. npm links each command before the install step runs, and skips -# a command whose file is missing, so this file has to exist in the package. -# The install step (install.js) replaces it with the real program. -echo "@gitlawb/gl: the install step did not run, so this command is not set up." >&2 -echo "Reinstall with scripts allowed: npm install -g @gitlawb/gl --no-ignore-scripts --allow-scripts=@gitlawb/gl" >&2 -echo "or install without npm: curl -fsSL https://twigpine.com/install.sh | sh" >&2 -exit 1 diff --git a/npm/packages/gl/install.js b/npm/packages/gl/install.js deleted file mode 100644 index 7e5b98239..000000000 --- a/npm/packages/gl/install.js +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env node - -const { existsSync, copyFileSync, chmodSync, mkdirSync } = require("fs"); -const { join, dirname } = require("path"); - -const PLATFORM_PACKAGES = { - "darwin-arm64": "@gitlawb/gl-darwin-arm64", - "darwin-x64": "@gitlawb/gl-darwin-x64", - "linux-arm64": "@gitlawb/gl-linux-arm64", - "linux-x64": "@gitlawb/gl-linux-x64", -}; - -const BINARIES = ["gl", "git-remote-gitlawb"]; - -function getPlatformKey() { - const platform = process.platform; - const arch = process.arch; - - if (arch !== "arm64" && arch !== "x64") { - throw new Error( - `Unsupported architecture: ${arch}. Twigpine CLI supports x64 and arm64.` - ); - } - - if (platform !== "darwin" && platform !== "linux") { - throw new Error( - `Unsupported platform: ${platform}. Twigpine CLI supports macOS and Linux.\n` + - `For Windows, use WSL or the installer: https://twigpine.com/install.ps1` - ); - } - - return `${platform}-${arch}`; -} - -function findPlatformPackage(packageName) { - try { - const pkgJson = require.resolve(`${packageName}/package.json`); - return dirname(pkgJson); - } catch { - return null; - } -} - -function install() { - const platformKey = getPlatformKey(); - const packageName = PLATFORM_PACKAGES[platformKey]; - - if (!packageName) { - console.error(`No binary package available for ${platformKey}`); - process.exit(1); - } - - const packageDir = findPlatformPackage(packageName); - - if (!packageDir) { - // On a supported platform the matching optional dependency must be present; - // fail loudly rather than leave @gitlawb/gl installed without its binaries. - console.error( - `@gitlawb/gl: Platform package ${packageName} not found.\n` + - `This can happen if optional dependencies were skipped.\n` + - `Install manually: curl -fsSL https://twigpine.com/install.sh | sh` - ); - process.exit(1); - } - - const binDir = join(__dirname, "bin"); - mkdirSync(binDir, { recursive: true }); - - for (const binary of BINARIES) { - const src = join(packageDir, binary); - const dest = join(binDir, binary); - - if (!existsSync(src)) { - throw new Error(`Binary ${binary} not found in ${packageName}`); - } - - copyFileSync(src, dest); - chmodSync(dest, 0o755); - } - - // `twigpine` and `twig` run their own copy, so the CLI can tell it was not - // started as `gl` (it prints a note about the new name when it was). - const renamed = join(binDir, "twigpine"); - copyFileSync(join(binDir, "gl"), renamed); - chmodSync(renamed, 0o755); - - // Git picks its remote helper by URL scheme: `git-remote-twigpine` runs - // twigpine:// remotes, `git-remote-gitlawb` runs gitlawb:// ones. - const helper = join(binDir, "git-remote-twigpine"); - copyFileSync(join(binDir, "git-remote-gitlawb"), helper); - chmodSync(helper, 0o755); - - console.log(`@gitlawb/gl: Installed Twigpine CLI for ${platformKey}`); -} - -try { - install(); -} catch (err) { - console.error(`@gitlawb/gl: ${err.message}`); - process.exit(1); -} diff --git a/npm/packages/gl/package.json b/npm/packages/gl/package.json deleted file mode 100644 index 96d720d11..000000000 --- a/npm/packages/gl/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@gitlawb/gl", - "version": "0.3.9", - "description": "Twigpine CLI — decentralized git for AI agents and developers", - "license": "MIT", - "bin": { - "twigpine": "bin/twigpine", - "twig": "bin/twigpine", - "gl": "bin/gl", - "git-remote-gitlawb": "bin/git-remote-gitlawb", - "git-remote-twigpine": "bin/git-remote-twigpine" - }, - "scripts": { - "postinstall": "node install.js" - }, - "publishConfig": { - "access": "public", - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "https://github.com/Twigpine/node", - "directory": "npm/packages/gl" - }, - "keywords": [ - "gitlawb", - "git", - "decentralized", - "cli", - "ai-agents", - "did", - "ucan" - ], - "files": [ - "bin", - "install.js", - "README.md" - ], - "optionalDependencies": { - "@gitlawb/gl-darwin-arm64": "0.3.9", - "@gitlawb/gl-darwin-x64": "0.3.9", - "@gitlawb/gl-linux-arm64": "0.3.9", - "@gitlawb/gl-linux-x64": "0.3.9" - } -} diff --git a/scripts/npm/test-npm-packages.sh b/scripts/npm/test-npm-packages.sh index a3810f6f0..279fc807b 100755 --- a/scripts/npm/test-npm-packages.sh +++ b/scripts/npm/test-npm-packages.sh @@ -261,13 +261,15 @@ FAKEBIN="$W/fakebin" mkdir -p "$FAKEBIN" # A registry in $REG: versions/ per published version, tags/. # `npm view` of anything unknown answers E404; FAKE_VIEW_BROKEN makes every -# lookup fail some other way. Every call is logged. +# lookup fail some other way; FAKE_VIEW_WARN adds an npm warning on stderr to +# every lookup, as real npm does for config warnings. Every call is logged. cat > "$FAKEBIN/npm" <<'EOF' #!/usr/bin/env bash echo "npm $*" >> "$REG/log" case "$1" in view) [ -z "${FAKE_VIEW_BROKEN:-}" ] || { echo "npm error code ECONNRESET" >&2; exit 1; } + [ -z "${FAKE_VIEW_WARN:-}" ] || echo "npm warn config production Use \`--omit=dev\` instead." >&2 spec="$2"; what="$3" if [ "$what" = version ]; then v="${spec##*@}" @@ -335,6 +337,18 @@ if run_publish "$OUT" && [ -z "$(published_order)" ] && [ $((SECONDS - start)) - ok "re-running a backfill that already went out finishes at once" else bad "re-running a backfill that already went out finishes at once"; fi +# A warning on stderr during a successful lookup must not be read as the +# registry's latest: it once made a new release look older than latest, so it +# went out under backfill. +REG="$W/reg3c"; mkdir -p "$REG/versions" "$REG/tags" +echo "9.8.0" > "$REG/tags/latest"; touch "$REG/versions/9.8.0" +rm -f "$REG/log" +if PATH="$FAKEBIN:$PATH" REG="$REG" FAKE_VIEW_WARN=1 TWIGPINE_NPM_PUBLISH_RETRY_DELAY=0 TWIGPINE_NPM_PUBLISH_WAIT_TIMEOUT=5 \ + bash "$PUBLISH" "$OUT" > "$W/out" 2>&1 \ + && grep -q '^published 9.9.0 latest$' "$REG/log" && [ "$(cat "$REG/tags/latest")" = 9.9.0 ]; then + ok "an npm warning during a lookup does not turn a new release into a backfill" +else bad "an npm warning during a lookup does not turn a new release into a backfill"; fi + REG="$W/reg4"; mkdir -p "$REG" cp -R "$OUT" "$W/npm-short"; rm -rf "$W/npm-short/platforms/cli-win32-x64" if run_publish "$W/npm-short"; then bad "refuses payloads that do not match the wrapper" diff --git a/scripts/test-resolve-release-tag.sh b/scripts/test-resolve-release-tag.sh index 0673d0355..60bbb57b6 100755 --- a/scripts/test-resolve-release-tag.sh +++ b/scripts/test-resolve-release-tag.sh @@ -309,8 +309,8 @@ awk ' is_workflow_scripts_checkout = ($0 ~ /^ - name:[[:space:]]*Check out workflow scripts[[:space:]]*$/) is_manifest = ($0 ~ /^ - name:[[:space:]]*Create and push multi-arch manifest[[:space:]]*$/) is_moving = ($0 ~ /^ - name:[[:space:]]*Move floating tags[[:space:]]*$/) - is_npm_publish = ($0 ~ /^ - name:[[:space:]]*Publish[[:space:]]*$/) - is_layin = ($0 ~ /^ - name:[[:space:]]*Lay in release binaries[[:space:]]*$/) + is_npm_publish = ($0 ~ /^ - name:[[:space:]]*Publish @twigpine\/cli[[:space:]]*$/) + is_layin = ($0 ~ /^ - name:[[:space:]]*Fetch release archives[[:space:]]*$/) is_tag_checkout = ($0 ~ /^ - name:[[:space:]]*Checkout release tag[[:space:]]*$/ || $0 ~ /^ - name:[[:space:]]*Checkout node \(release tag\)[[:space:]]*$/) is_regen = ($0 ~ /^ - name:[[:space:]]*Regenerate formula[[:space:]]*$/) step = $0 ORS @@ -488,13 +488,13 @@ job=release-binaries ref: ${{ steps.rel.outputs.tag_commit || format('refs/tags/{0}', steps.rel.outputs.tag) }} persist-credentials: false -job=npm-publish +job=npm-publish-cli - name: Check out workflow scripts uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 with: persist-credentials: false -job=npm-publish +job=npm-publish-cli - name: Resolve release tag id: rel env: @@ -505,20 +505,8 @@ job=npm-publish set -euo pipefail scripts/resolve-release-tag.sh "${DISPATCH_TAG:-$RELEASE_TAG}" -job=npm-publish - - name: Checkout release tag - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - with: - # Pin the commit the resolver verified; a tag ref re-resolved here - # could have been moved between resolve and checkout. - ref: ${{ steps.rel.outputs.tag_commit || format('refs/tags/{0}', steps.rel.outputs.tag) }} - persist-credentials: false - - # npm >= 11.5.1 performs the OIDC token exchange automatically when the - # package has a trusted publisher configured; older npm silently falls - # back to (absent) token auth and fails confusingly. -job=npm-publish - - name: Lay in release binaries +job=npm-publish-cli + - name: Fetch release archives env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ steps.rel.outputs.version }} @@ -526,101 +514,44 @@ job=npm-publish ASSETS: ${{ steps.rel.outputs.assets }} run: | set -euo pipefail - # npm platform package -> Rust target triple (unix only; Windows is not - # published to npm). - MAP=" - gl-darwin-arm64:aarch64-apple-darwin - gl-darwin-x64:x86_64-apple-darwin - gl-linux-arm64:aarch64-unknown-linux-musl - gl-linux-x64:x86_64-unknown-linux-musl - " - mkdir -p _dl - for entry in $MAP; do - pkg="${entry%%:*}" - target="${entry#*:}" - archive="twigpine-node-${VERSION}-${target}.tar.gz" - echo "==> $pkg <- $archive" - # Download by the asset id the resolver captured and uploader- - # checked, not by name: release assets are mutable, and an id can - # only ever point at the exact blob captured at resolve time. - # The map keys are base64-encoded asset names. - want="$(printf '%s' "$archive" | base64 -w0)" - asset_id="$(printf '%s\n' "$ASSETS" | awk -v n="$want" '$1 == n {print $2; exit}')" - if [ -z "$asset_id" ]; then - echo "::error::release $TAG has no asset $archive captured at resolve time" - exit 1 - fi - gh api "repos/$GITHUB_REPOSITORY/releases/assets/$asset_id" \ - -H 'Accept: application/octet-stream' > "_dl/$archive" - tar -xzf "_dl/$archive" -C _dl - src="_dl/twigpine-node-${VERSION}-${target}" - cp "$src/twigpine" "npm/packages/$pkg/gl" - cp "$src/git-remote-twigpine" "npm/packages/$pkg/git-remote-gitlawb" - chmod +x "npm/packages/$pkg/gl" "npm/packages/$pkg/git-remote-gitlawb" - done - -job=npm-publish - - name: Publish - env: - VERSION: ${{ steps.rel.outputs.version }} - run: | - set -euo pipefail - # No token: npm exchanges this job's GitHub OIDC identity with the - # registry (trusted publishing); provenance is attested automatically. - # Platform packages first, then the wrapper (so its optionalDependencies resolve). - # Skip versions already on the registry so a rerun after a partial publish - # is idempotent instead of erroring on the first existing package. - # npm publish moves the latest dist-tag to whatever it publishes, so a - # backfilled older version would hand :latest to stale code. Decide - # the dist-tag per package from that package's own registry latest: - # a partial publish can leave the platform packages ahead of the - # wrapper. E404 means the package has never been published, so this - # release gets latest; any other lookup failure must fail closed - # rather than guess at the dist-tag and risk moving latest backward. - # stderr goes to a file so a warning on a successful lookup cannot - # leak into registry_latest; it is read only when the lookup fails. - npm_err="$(mktemp)" - trap 'rm -f -- "$npm_err"' EXIT - for pkg in gl-darwin-arm64 gl-darwin-x64 gl-linux-arm64 gl-linux-x64 gl; do - name="@gitlawb/$pkg" - if npm view "$name@$VERSION" version >/dev/null 2>&1; then - echo "==> $name@$VERSION already published, skipping" - continue - fi - registry_latest="$(npm view "$name" dist-tags.latest 2>"$npm_err")" || { - if ! grep -q E404 "$npm_err"; then - cat "$npm_err" >&2 - echo "::error::npm dist-tags lookup failed for $name; not guessing the dist-tag" + mkdir -p _art + windows="twigpine-node-${VERSION}-x86_64-pc-windows-msvc.zip" + for archive in \ + "twigpine-node-${VERSION}-aarch64-apple-darwin.tar.gz" \ + "twigpine-node-${VERSION}-x86_64-apple-darwin.tar.gz" \ + "twigpine-node-${VERSION}-aarch64-unknown-linux-musl.tar.gz" \ + "twigpine-node-${VERSION}-x86_64-unknown-linux-musl.tar.gz" \ + "$windows"; do + for file in "$archive" "$archive.sha256"; do + # By the asset id the resolver captured and uploader-checked, not + # by name: release assets are mutable, an id is not. + want="$(printf '%s' "$file" | base64 -w0)" + asset_id="$(printf '%s\n' "$ASSETS" | awk -v n="$want" '$1 == n {print $2; exit}')" + if [ -z "$asset_id" ]; then + # Windows is built best-effort (release-binaries); without it + # the package is published for the other platforms. + if [ "$archive" = "$windows" ]; then + echo "::warning::release $TAG has no $file; publishing without Windows" + rm -f "_art/$windows" "_art/$windows.sha256" + continue 2 + fi + echo "::error::release $TAG has no asset $file captured at resolve time" exit 1 fi - registry_latest="" - } - dist_tag="latest" - if [ -n "$registry_latest" ] && \ - [ "$VERSION" != "$(printf '%s\n%s\n' "$registry_latest" "$VERSION" | sort -V | tail -1)" ]; then - dist_tag="backfill" - echo "::notice::$VERSION is older than $name@$registry_latest; publishing under dist-tag backfill" - fi - echo "==> npm publish $name@$VERSION (dist-tag $dist_tag)" - npm publish "npm/packages/$pkg" --provenance --access public --tag "$dist_tag" + gh api "repos/$GITHUB_REPOSITORY/releases/assets/$asset_id" \ + -H 'Accept: application/octet-stream' > "_art/$file" + done done job=npm-publish-cli - - name: Check out workflow scripts - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - with: - persist-credentials: false - -job=npm-publish-cli - - name: Resolve release tag - id: rel + - name: Publish @twigpine/cli env: - DISPATCH_TAG: ${{ inputs.npm_backfill_tag }} - RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # No token: npm exchanges this job's GitHub OIDC identity with the + # registry (trusted publishing). + TWIGPINE_NPM_PUBLISH_FLAGS: --provenance run: | set -euo pipefail - scripts/resolve-release-tag.sh "${DISPATCH_TAG:-$RELEASE_TAG}" + scripts/npm/publish-packages.sh _npm job=homebrew-bump - name: Check out workflow scripts @@ -755,7 +686,7 @@ EOF if ! cmp "$expected_resolver_steps" "$actual_resolver_steps"; then printf '%s\n' \ - "release workflow resolver steps differ from the three reviewed blocks" >&2 + "release workflow resolver steps differ from the reviewed blocks" >&2 diff -u "$expected_resolver_steps" "$actual_resolver_steps" >&2 || true exit 1 fi @@ -908,7 +839,6 @@ sync-release-lock=release docker=release docker-manifest=release release-binaries=release -npm-publish=release npm-publish-cli=npm-publish homebrew-bump=release web-sync=release @@ -1061,88 +991,6 @@ if [ -s "$stale_reads" ]; then exit 1 fi -# Behavioral check of the Publish step's dist-tag decision. The run block is -# extracted from the workflow and run against a stub npm, so nothing is -# published. The lookup's stderr must not leak into the registry latest on a -# successful call (a warning there once made a new release look older and -# published it under backfill). -publish_script="$test_tmp/publish-step.sh" -awk ' - /^job=npm-publish$/ { want = 1; next } - /^job=/ { want = 0 } - /^ - name:/ { in_publish = ($0 ~ /^ - name:[[:space:]]*Publish[[:space:]]*$/) } - want && in_publish && /^ run: \|$/ { in_run = 1; next } - want && in_run && /^$/ { exit } - want && in_run { sub(/^ /, ""); print } -' "$actual_resolver_steps" > "$publish_script" -if ! grep -q 'npm publish' "$publish_script"; then - printf '%s\n' "could not extract the npm-publish run block" >&2 - exit 1 -fi - -publish_bin="$test_tmp/publish-bin" -mkdir -p "$publish_bin" -cat > "$publish_bin/npm" <<'STUB' -#!/usr/bin/env bash -case "$1" in - view) - case "$2" in - *@*/*@*) exit 1 ;; # "@": not yet published - esac - case "${NPM_MODE:?NPM_MODE unset}" in - warn_ok) - echo "npm warn config something is deprecated" >&2 - echo "${NPM_LATEST:?}" - ;; - clean_ok) echo "${NPM_LATEST:?}" ;; - e404) - echo "npm error code E404" >&2 - exit 1 - ;; - other) - echo "npm error code ECONNRESET" >&2 - exit 1 - ;; - esac - ;; - publish) echo "PUBLISH $*" ;; -esac -STUB -chmod +x "$publish_bin/npm" - -run_publish() { # mode version latest - PATH="$publish_bin:$PATH" NPM_MODE="$1" VERSION="$2" NPM_LATEST="${3:-}" \ - bash "$publish_script" > "$test_tmp/publish-out" 2> "$test_tmp/publish-err" -} -expect_tag() { # label mode version latest tag - if ! run_publish "$2" "$3" "$4"; then - printf '%s\n' "publish dist-tag ($1): step failed" >&2 - cat "$test_tmp/publish-err" >&2 - exit 1 - fi - if [ "$(grep -c -- "--tag $5\$" "$test_tmp/publish-out")" != 5 ] \ - || [ "$(grep -c -- '--tag ' "$test_tmp/publish-out")" != 5 ]; then - printf '%s\n' "publish dist-tag ($1): expected five publishes under $5" >&2 - cat "$test_tmp/publish-out" >&2 - exit 1 - fi -} -expect_tag "new release, stderr warning on a successful lookup" warn_ok 0.10.0 0.9.0 latest -expect_tag "new release, clean lookup" clean_ok 0.10.0 0.9.0 latest -expect_tag "genuine backfill" warn_ok 0.8.0 0.9.0 backfill -expect_tag "E404 means never published" e404 0.10.0 "" latest -if run_publish other 0.10.0 ""; then - printf '%s\n' "publish dist-tag (non-E404 failure): step unexpectedly passed" >&2 - exit 1 -fi -if ! grep -q '^::error::npm dist-tags lookup failed for @gitlawb/gl-darwin-arm64; not guessing the dist-tag$' "$test_tmp/publish-out" \ - || grep -q PUBLISH "$test_tmp/publish-out" \ - || ! grep -q ECONNRESET "$test_tmp/publish-err"; then - printf '%s\n' "publish dist-tag (non-E404 failure): wrong error output or a publish ran" >&2 - cat "$test_tmp/publish-out" "$test_tmp/publish-err" >&2 - exit 1 -fi - # Behavioral check of the Move floating tags floor. The run block is extracted # from the workflow and run against a stub gh and a stub docker. The stub gh # serves two pages of releases ordered by creation, with the newest semver on