Skip to content

Commit 73b87c9

Browse files
committed
chore(wasm): switch tlsn-wasm npm release from CI to manual script
The releng.yml workflow relied on an NPM_TOKEN secret that expires every 90 days, which made it almost always broken at release time. Replace it with crates/wasm/publish.sh, which downloads the CI-built artifact for a given tag and runs `npm publish` locally under a maintainer account.
1 parent d50db96 commit 73b87c9

3 files changed

Lines changed: 105 additions & 62 deletions

File tree

.github/workflows/releng.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

crates/wasm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ For browser usage, check the [`tlsn-extension`](https://github.com/tlsnotary/tls
1212
cargo install wasm-pack
1313
```
1414

15+
## Releasing to npm
16+
17+
Releases are published manually. CI builds and uploads a `tlsn-wasm` package
18+
artifact on every tagged build (see `ci.yml`); `publish.sh` downloads that
19+
artifact and pushes it to npm.
20+
21+
One-time setup:
22+
23+
1. Be a maintainer of [`tlsn-wasm`](https://www.npmjs.com/package/tlsn-wasm) on
24+
npm.
25+
2. Authenticate locally:
26+
- `gh auth login` (needs read access to `tlsnotary/tlsn` Actions artifacts)
27+
- `npm login` — verify with `npm whoami`. 2FA OTP is prompted at publish
28+
time.
29+
30+
To publish a tag (after the CI run for that tag has completed successfully):
31+
32+
```bash
33+
./publish.sh v0.1.0-alpha.16
34+
```
35+
36+
The script shows a `npm publish --dry-run` and asks for confirmation before
37+
actually publishing. Pass a second argument to use a non-`latest` dist-tag,
38+
e.g. `./publish.sh v0.1.0-alpha.16 alpha`.
39+
1540
## Links
1641

1742
- [Website](https://tlsnotary.org)

crates/wasm/publish.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/sh
2+
3+
# Publish a tagged tlsn-wasm build from GitHub Actions to npm.
4+
#
5+
# Usage:
6+
# ./publish.sh <tag> [npm-dist-tag]
7+
#
8+
# Example:
9+
# ./publish.sh v0.1.0-alpha.16
10+
# ./publish.sh v0.1.0-alpha.16 alpha
11+
#
12+
# Requires: gh (authenticated), npm (logged in as a maintainer of `tlsn-wasm`).
13+
14+
set -e
15+
16+
TAG="${1:-}"
17+
NPM_TAG="${2:-latest}"
18+
19+
if [ -z "$TAG" ]; then
20+
echo "Usage: $0 <tag> [npm-dist-tag]"
21+
echo "Example: $0 v0.1.0-alpha.16"
22+
exit 1
23+
fi
24+
25+
REPO="tlsnotary/tlsn"
26+
ARTIFACT_NAME="${TAG}-tlsn-wasm-pkg"
27+
28+
for cmd in gh npm; do
29+
if ! command -v "$cmd" >/dev/null 2>&1; then
30+
echo "Error: $cmd not found in PATH."
31+
exit 1
32+
fi
33+
done
34+
35+
if ! npm whoami >/dev/null 2>&1; then
36+
echo "Error: not logged in to npm. Run 'npm login' first."
37+
exit 1
38+
fi
39+
40+
WORK_DIR="$(mktemp -d -t tlsn-wasm-publish.XXXXXX)"
41+
trap 'rm -rf "$WORK_DIR"' EXIT
42+
echo "Working in $WORK_DIR"
43+
44+
echo "Looking for successful ci.yml run for $TAG..."
45+
RUN_ID=$(gh run list \
46+
--repo "$REPO" \
47+
--workflow ci.yml \
48+
--branch "$TAG" \
49+
--status success \
50+
--limit 1 \
51+
--json databaseId \
52+
--jq '.[0].databaseId')
53+
54+
if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then
55+
echo "Error: no successful ci.yml run found for tag $TAG."
56+
echo "Check: gh run list --repo $REPO --workflow ci.yml --branch $TAG"
57+
exit 1
58+
fi
59+
echo "Found CI run: $RUN_ID"
60+
61+
echo "Downloading artifact $ARTIFACT_NAME..."
62+
gh run download "$RUN_ID" \
63+
--repo "$REPO" \
64+
--name "$ARTIFACT_NAME" \
65+
--dir "$WORK_DIR/pkg"
66+
67+
echo "Tarball preview:"
68+
(cd "$WORK_DIR/pkg" && npm publish --dry-run --tag "$NPM_TAG")
69+
70+
printf "Publish %s to npm with dist-tag '%s'? [y/N] " "$ARTIFACT_NAME" "$NPM_TAG"
71+
read -r REPLY
72+
case "$REPLY" in
73+
y|Y|yes|YES) ;;
74+
*) echo "Aborted."; exit 1 ;;
75+
esac
76+
77+
cd "$WORK_DIR/pkg"
78+
npm publish --tag "$NPM_TAG"
79+
80+
echo "Published $ARTIFACT_NAME to npm under tag '$NPM_TAG'."

0 commit comments

Comments
 (0)