Skip to content

πŸ”§ Enable npm Trusted Publishing with Node 22 and npm CLI upgrade. (#22) #21

πŸ”§ Enable npm Trusted Publishing with Node 22 and npm CLI upgrade. (#22)

πŸ”§ Enable npm Trusted Publishing with Node 22 and npm CLI upgrade. (#22) #21

Workflow file for this run

name: npm Release
# Publish the `malkuth` binary to npm as precompiled platform subpackages so
# users can run it via `npx @celestia-island/malkuth` with no Rust toolchain.
#
# This pipeline is the npm counterpart to publish.yml (crates.io). It runs in
# three phases:
#
# 1. `build-subpackage` (matrix, one job per platform) β€” cross-compile the
# binary with the `cli mcp` features (so both the watchdog CLI and
# `malkuth mcp` are available), stage it into a platform subpackage via
# celestia-devtools `npm-dist`, and publish that single subpackage to npm.
# 2. `publish-root` (single job, fan-in) β€” with no binary of its own, re-run
# `npm-dist` to (re)assemble the root package listing every subpackage
# already on npm, then publish the root launcher.
#
# The version is derived from the pushed tag (vX.Y.Z β†’ X.Y.Z) and is shared by
# the root package and every subpackage so they are released in lockstep.
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 0.1.0), without leading v"
required: true
permissions:
contents: read
id-token: write
jobs:
build-subpackage:
name: Build + publish @celestia-island/malkuth${{ matrix.suffix }} to npm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, suffix: -linux-x64 }
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, suffix: -linux-arm64 }
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl, suffix: -linux-x64-musl }
- { os: macos-latest, target: aarch64-apple-darwin, suffix: -darwin-arm64 }
- { os: macos-latest, target: x86_64-apple-darwin, suffix: -darwin-x64 }
- { os: windows-latest, target: x86_64-pc-windows-msvc, suffix: -win32-x64 }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install celestia-devtools
run: pip install git+https://github.com/celestia-island/celestia-devtools.git
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: https://registry.npmjs.org/
- name: Upgrade npm for Trusted Publishing
run: npm install -g npm@latest
- name: Resolve version
id: ver
shell: bash
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
v="${{ github.event.inputs.version }}"
else
v="${GITHUB_REF_NAME#v}"
fi
echo "version=$v" >> "$GITHUB_OUTPUT"
echo "publishing $v"
# Build with cli (the watchdog binary) + mcp so `malkuth mcp` ships too.
- name: Setup cross-compilation toolchains
if: runner.os == 'Linux'
shell: bash
run: |
case "${{ matrix.target }}" in
aarch64-unknown-linux-gnu)
sudo apt-get update -qq && sudo apt-get install -y -qq gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
;;
x86_64-unknown-linux-musl)
sudo apt-get update -qq && sudo apt-get install -y -qq musl-tools
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc" >> "$GITHUB_ENV"
;;
esac
- name: Build (release)
run: cargo build --release --features "cli mcp" --target ${{ matrix.target }}
- name: Stage subpackage
shell: bash
run: |
bin="target/${{ matrix.target }}/release/malkuth"
[ "${{ matrix.target }}" = "x86_64-pc-windows-msvc" ] && bin="${bin}.exe"
celestia-devtools npm-dist \
--name malkuth \
--version "${{ steps.ver.outputs.version }}" \
--binary "$bin" \
--rust-target "${{ matrix.target }}" \
--out-dir dist \
--description "Composable service-supervision toolkit β€” watchdog + MCP server (npx launcher)" \
--repository "https://github.com/celestia-island/malkuth" \
--homepage "https://github.com/celestia-island/malkuth"
- name: Upload staged subpackage
uses: actions/upload-artifact@v4
with:
name: subpackage-${{ matrix.suffix }}
path: dist/malkuth${{ matrix.suffix }}
retention-days: 7
- name: Publish subpackage
shell: bash
run: |
sub="dist/malkuth${{ matrix.suffix }}"
echo "::group::npm pack $sub"
(cd "$sub" && npm pack --dry-run)
echo "::endgroup::"
(cd "$sub" && npm publish --access public --provenance)
publish-root:
name: Publish root @celestia-island/malkuth to npm
needs: build-subpackage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install celestia-devtools
run: pip install git+https://github.com/celestia-island/celestia-devtools.git
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: https://registry.npmjs.org/
- name: Upgrade npm for Trusted Publishing
run: npm install -g npm@latest
- name: Resolve version
id: ver
shell: bash
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
v="${{ github.event.inputs.version }}"
else
v="${GITHUB_REF_NAME#v}"
fi
echo "version=$v" >> "$GITHUB_OUTPUT"
- name: Assemble root package
run: |
for sfx in -linux-x64 -linux-arm64 -linux-x64-musl -darwin-arm64 -darwin-x64 -win32-x64; do
mkdir -p "dist/malkuth${sfx}"
done
celestia-devtools npm-dist \
--name malkuth \
--version "${{ steps.ver.outputs.version }}" \
--out-dir dist \
--description "Composable service-supervision toolkit β€” watchdog + MCP server (npx launcher)" \
--repository "https://github.com/celestia-island/malkuth" \
--homepage "https://github.com/celestia-island/malkuth"
- name: Publish root package
run: |
echo "::group::npm pack (root)"
(cd dist && npm pack --dry-run)
echo "::endgroup::"
(cd dist && npm publish --access public --provenance)