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
189 changes: 8 additions & 181 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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: >-
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/LEGACY-NAMES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 13 additions & 15 deletions docs/NPM_PACKAGING.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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`

Expand All @@ -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.
14 changes: 0 additions & 14 deletions npm/.gitignore
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 6 additions & 9 deletions npm/README.md
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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-<platform>` 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.
21 changes: 0 additions & 21 deletions npm/packages/gl-darwin-arm64/package.json

This file was deleted.

21 changes: 0 additions & 21 deletions npm/packages/gl-darwin-x64/package.json

This file was deleted.

Loading
Loading