name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
packages: write
env:
BIN_NAME: nereid
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use_cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use_cross: true
- os: macos-15-intel
target: x86_64-apple-darwin
use_cross: false
- os: macos-15
target: aarch64-apple-darwin
use_cross: false
- os: windows-2022
target: x86_64-pc-windows-msvc
use_cross: false
steps:
- uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Restore Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ runner.os }}-${{ matrix.target }}
save-if: ${{ github.event_name != 'pull_request' }}
cache-on-failure: true
- name: Setup cross
if: matrix.use_cross
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- name: Resolve version
id: version
shell: bash
run: scripts/resolve-version.sh
- name: Build (unix)
if: runner.os != 'Windows'
run: TARGET=${{ matrix.target }} scripts/build-release.sh
- name: Build (windows)
if: runner.os == 'Windows'
shell: pwsh
run: scripts/build-release.ps1 -Target ${{ matrix.target }}
- name: Package (unix)
if: runner.os != 'Windows'
run: TARGET=${{ matrix.target }} VERSION=${{ steps.version.outputs.version }} BIN_NAME=${{ env.BIN_NAME }} scripts/package-release.sh
- name: Package (windows)
if: runner.os == 'Windows'
shell: pwsh
run: scripts/package-release.ps1 -Target ${{ matrix.target }} -Version ${{ steps.version.outputs.version }} -BinName ${{ env.BIN_NAME }}
- name: Upload workflow artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.target }}
path: dist/*
- name: Upload GitHub Release assets
uses: softprops/action-gh-release@v2
with:
files: dist/*
container:
name: Publish container image
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Resolve version
id: version
shell: bash
run: scripts/resolve-version.sh
- name: Resolve image name
id: image
shell: bash
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build smoke image (amd64)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/amd64
load: true
build-args: |
NEREID_VERSION=${{ steps.version.outputs.version }}
tags: nereid-smoke:amd64
- name: Smoke image (amd64)
run: |
docker run --rm --platform linux/amd64 nereid-smoke:amd64 --version
docker run --rm --platform linux/amd64 nereid-smoke:amd64 --help
docker run --rm --platform linux/amd64 nereid-smoke:amd64 --dump-mcp-tool-schema >/dev/null
- name: Build smoke image (arm64)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/arm64
load: true
build-args: |
NEREID_VERSION=${{ steps.version.outputs.version }}
tags: nereid-smoke:arm64
- name: Smoke image (arm64)
run: |
docker run --rm --platform linux/arm64 nereid-smoke:arm64 --version
docker run --rm --platform linux/arm64 nereid-smoke:arm64 --help
docker run --rm --platform linux/arm64 nereid-smoke:arm64 --dump-mcp-tool-schema >/dev/null
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
NEREID_VERSION=${{ steps.version.outputs.version }}
tags: |
${{ steps.image.outputs.name }}:${{ steps.version.outputs.version }}
${{ steps.image.outputs.name }}:latest
npm:
name: Publish npm wrapper
needs: build
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v5
- name: Resolve version
id: version
shell: bash
run: scripts/resolve-version.sh
- name: Set up Node
if: env.NODE_AUTH_TOKEN != ''
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Publish npm package
if: env.NODE_AUTH_TOKEN != ''
working-directory: npm/nereid
run: |
npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version
npm publish --access public
- name: Skip npm publish
if: env.NODE_AUTH_TOKEN == ''
run: echo "NPM_TOKEN is not set; skipping npm publish."