Publish tread to crates.io and npm - #17
Merged
Merged
Conversation
cargo package includes untracked files, so a private sample sitting in the working tree ships with a --allow-dirty publish and can never be deleted again. Name the exclusions instead of relying on the dirty check.
The package carries no binary. On first run it fetches the archive the releases page already publishes, checks it against SHA256SUMS, and only then reads the binary out of it — so npm costs the release nothing and delivers the same bytes install.sh does. TREAD_BINARY skips all of it.
Both registries authenticate by trusted publishing, so no long-lived secret lives in the workflow. The crate job refuses a tag that disagrees with Cargo.toml, because a crates.io version can never be republished, and skips a version the registry already has so a retag stays green. The npm job waits on the GitHub release, since the launcher it publishes reads its binary from there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ships
treadfrom two package managers, and wires the release to keep doing it.treadis now on crates.io, and@viict/treadon npm. This branch is what makesthe next tag publish to both without hands.
The npm package is a launcher, not a copy
It carries no binary. On first run it fetches the archive this release already
publishes — the same
.tar.gzor.zipa person downloads by hand and thatinstall.shverifies — checks it againstSHA256SUMS, and only then reads thebinary out of it. The release is not asked to carry a second, npm-shaped copy of
every build.
Reading the archives is the launcher's own work: node has
zlibbuilt in and noarchive reader, so
lib/unpack.jswalks a tar's 512-byte headers and a zip'scentral directory in ~130 lines. That keeps the package's dependency count where
the rest of the project keeps it — at zero.
Not a
postinstalldownload: that is dead weight undernpm ci --ignore-scriptsand pnpm's default script blocking, where the package installs and the binary
silently never arrives. Fetching at first run costs a moment once and works
everywhere.
The binary is state, not cache, so it lives under the platform's data
directory — a cache is something the OS may delete, and a
treadthatevaporates leaves an offline machine unable to read anything:
$XDG_DATA_HOME/tread/<version>/, else~/.local/share/tread/<version>/~/Library/Application Support/tread/<version>/%LOCALAPPDATA%\tread\<version>\A version is a directory, so upgrading needs no invalidation rule.
TREAD_BINARYpoints at a
treadyou already have and skips all of it — one global installshared by several accounts, or a runner with no route out.
Release
Two jobs, both authenticating by trusted publishing, so no long-lived secret
lives in the workflow. The crate job refuses a tag that disagrees with
Cargo.toml(a crates.io version can never be republished) and skips a versionthe registry already has, so re-tagging stays green — which the release job above
it already supported. The npm job waits on the GitHub release, because the
launcher it publishes reads its binary from there.
Cargo.tomlalso grows anexclude:cargo packageincludes untracked files,so anything sitting in a working tree ships with an
--allow-dirtypublish andcan never be deleted again.
Verified
cache: fetch, verify, extract, run. 0.43s cold, 0.06s warm.
npx @viict/treadfrom the public registry, unauthenticated, renders.runs and reports its version; the extracted
.exeis a valid PE32+.cargo test: 1587 passing, unchanged — nothing here touches Rust.npm pack: 4 files, 6.8 kB, no binary.Before the next tag
Cargo.tomlmust be bumped to the version being tagged, and npm trustedpublishing configured for
@viict/tread(repo, workflowrelease.yml,environment
Packaging).