Files
mcpctl/scripts/release.sh
Michal Rydlikowski 8ad7fe2748
Some checks failed
CI/CD / lint (push) Successful in 46s
CI/CD / test (push) Successful in 1m3s
CI/CD / typecheck (push) Has started running
CI/CD / smoke (push) Has been cancelled
CI/CD / build (amd64) (push) Has been cancelled
CI/CD / build (arm64) (push) Has been cancelled
CI/CD / publish-rpm (amd64) (push) Has been cancelled
CI/CD / publish-rpm (arm64) (push) Has been cancelled
CI/CD / publish-deb (amd64) (push) Has been cancelled
CI/CD / publish-deb (arm64) (push) Has been cancelled
feat: add ARM64 (aarch64) architecture support for builds and packages
Add cross-architecture build support so the project can be developed on
ARM64 (Fedora aarch64 laptop) while still producing amd64 packages for
production. All build, package, publish, and install scripts are now
architecture-aware via shared arch-helper.sh detection.

- Add scripts/arch-helper.sh for shared architecture detection
- CI builds both amd64 and arm64 in matrix strategy
- nfpm.yaml uses NFPM_ARCH env var instead of hardcoded amd64
- Build scripts support MCPCTL_TARGET_ARCH for cross-compilation
- installlocal.sh auto-detects RPM/DEB and filters by architecture
- release.sh gains --both-arches flag for dual-arch releases
- Package cleanup is arch-scoped (won't clobber other arch's packages)
- build-mcpd.sh supports --platform and --multi-arch flags
- Add pnpm scripts: rpm:build:amd64, deb:build:arm64, release:both
- Conditional rpm/dpkg-deb checks for cross-distro compatibility

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-13 23:01:51 +00:00

92 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Build, publish, and install mcpctl packages.
#
# Usage:
# ./release.sh # Build + publish for native arch only
# ./release.sh --both-arches # Build + publish for both amd64 and arm64
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT"
# Load .env if present
if [ -f .env ]; then
set -a; source .env; set +a
fi
source "$SCRIPT_DIR/arch-helper.sh"
resolve_arch "${MCPCTL_TARGET_ARCH:-}"
NATIVE_ARCH="$NFPM_ARCH"
BOTH_ARCHES=false
if [[ "${1:-}" == "--both-arches" ]]; then
BOTH_ARCHES=true
fi
echo "=== mcpctl release ==="
echo " Native arch: $NATIVE_ARCH"
echo ""
build_and_publish() {
local arch="$1"
echo ""
echo "=== Building for $arch ==="
MCPCTL_TARGET_ARCH="$arch" bash scripts/build-rpm.sh
echo ""
MCPCTL_TARGET_ARCH="$arch" bash scripts/publish-rpm.sh
MCPCTL_TARGET_ARCH="$arch" bash scripts/publish-deb.sh
}
if [ "$BOTH_ARCHES" = true ]; then
build_and_publish "amd64"
build_and_publish "arm64"
else
build_and_publish "$NATIVE_ARCH"
fi
echo ""
# Install locally for native arch (auto-detect RPM or DEB)
echo "==> Installing locally (${NATIVE_ARCH})..."
if command -v dpkg &>/dev/null && ! command -v dnf &>/dev/null; then
DEB_FILE=$(ls dist/mcpctl*.deb 2>/dev/null | grep -E "[._]${NATIVE_ARCH}[._]" | head -1)
sudo dpkg -i "$DEB_FILE" || sudo apt-get install -f -y
else
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | grep -E "[._]${NATIVE_ARCH}[._]" | head -1)
sudo rpm -U --force "$RPM_FILE"
fi
echo ""
echo "==> Installed:"
mcpctl --version
echo ""
# Restart mcplocal so smoke tests run against the new binary
echo "==> Restarting mcplocal..."
systemctl --user restart mcplocal
sleep 2
# Run smoke tests (requires live mcplocal + mcpd)
echo "==> Running smoke tests..."
export PATH="$HOME/.npm-global/bin:$PATH"
if pnpm test:smoke; then
echo "==> Smoke tests passed!"
else
echo "==> WARNING: Smoke tests failed! Check mcplocal/mcpd are running."
echo " Continuing anyway — deployment is complete, but verify manually."
fi
echo ""
GITEA_PUBLIC_URL="${GITEA_PUBLIC_URL:-https://mysources.co.uk}"
GITEA_OWNER="${GITEA_OWNER:-michal}"
echo "=== Done! ==="
echo "RPM install:"
echo " sudo dnf config-manager --add-repo ${GITEA_PUBLIC_URL}/api/packages/${GITEA_OWNER}/rpm.repo"
echo " sudo dnf install mcpctl"
echo ""
echo "DEB install (Debian/Ubuntu):"
echo " echo \"deb ${GITEA_PUBLIC_URL}/api/packages/${GITEA_OWNER}/debian trixie main\" | sudo tee /etc/apt/sources.list.d/mcpctl.list"
echo " curl -fsSL ${GITEA_PUBLIC_URL}/api/packages/${GITEA_OWNER}/debian/repository.key | sudo gpg --dearmor -o /etc/apt/keyrings/mcpctl.gpg"
echo " sudo apt update && sudo apt install mcpctl"