name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl, static: true }
- { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-musl, static: true }
- { os: macos-latest, target: aarch64-apple-darwin, static: false }
- { os: windows-latest, target: x86_64-pc-windows-msvc, static: false }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Build
shell: bash
run: |
# A self-contained Windows binary needs the CRT linked statically;
# musl is already fully static, macOS links only libSystem.
if [ "${{ matrix.target }}" = "x86_64-pc-windows-msvc" ]; then
export RUSTFLAGS="-C target-feature=+crt-static"
fi
cargo build --release --all-features --target ${{ matrix.target }}
- name: Assert static (Linux musl)
if: matrix.static
run: file target/${{ matrix.target }}/release/interlink-mcp | grep -qi static
- name: Stage assets
id: stage
shell: bash
run: |
target="${{ matrix.target }}"
bindir="target/$target/release"
ext=""
[ "${{ runner.os }}" = "Windows" ] && ext=".exe"
# (1) The raw interlink-mcp binary, per target — one file the npm
# wrapper downloads and runs directly.
cp "$bindir/interlink-mcp$ext" "interlink-mcp-$target$ext"
# (2) A full archive with all the binaries — for humans, and for a
# plugin that bundles them instead of using the npm wrapper.
stage="interlink-$target"
mkdir "$stage"
cp "$bindir/interlink-mcp$ext" "$bindir/interlink-bus$ext" \
"$bindir/interlink-keygen$ext" "$bindir/interlinked$ext" "$stage/"
if [ "${{ runner.os }}" = "Windows" ]; then
7z a "$stage.zip" "$stage" >/dev/null
echo "archive=$stage.zip" >> "$GITHUB_OUTPUT"
else
tar czf "$stage.tar.gz" "$stage"
echo "archive=$stage.tar.gz" >> "$GITHUB_OUTPUT"
fi
echo "binary=interlink-mcp-$target$ext" >> "$GITHUB_OUTPUT"
- name: Attach to release
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.stage.outputs.binary }}
${{ steps.stage.outputs.archive }}
crates-io:
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: cargo publish
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
npm:
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Upgrade npm (trusted publishing needs >= 11.5.1)
run: npm install -g npm@latest
- name: npm publish (OIDC)
working-directory: npm
run: npm publish