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
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>
81 lines
2.6 KiB
Bash
Executable File
81 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
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
|
|
|
|
GITEA_URL="${GITEA_URL:-http://10.0.0.194:3012}"
|
|
GITEA_PUBLIC_URL="${GITEA_PUBLIC_URL:-https://mysources.co.uk}"
|
|
GITEA_OWNER="${GITEA_OWNER:-michal}"
|
|
GITEA_REPO="${GITEA_REPO:-mcpctl}"
|
|
|
|
if [ -z "$GITEA_TOKEN" ]; then
|
|
echo "Error: GITEA_TOKEN not set. Add it to .env or export it."
|
|
exit 1
|
|
fi
|
|
|
|
# Architecture detection (respects MCPCTL_TARGET_ARCH)
|
|
source "$SCRIPT_DIR/arch-helper.sh"
|
|
resolve_arch "${MCPCTL_TARGET_ARCH:-}"
|
|
|
|
# Find DEB matching target architecture
|
|
DEB_FILE=$(ls dist/mcpctl*.deb 2>/dev/null | grep -E "[._]${NFPM_ARCH}[._]" | head -1)
|
|
if [ -z "$DEB_FILE" ]; then
|
|
# Fallback: try any deb file
|
|
DEB_FILE=$(ls dist/mcpctl*.deb 2>/dev/null | head -1)
|
|
fi
|
|
if [ -z "$DEB_FILE" ]; then
|
|
echo "Error: No DEB found in dist/. Run scripts/build-deb.sh first."
|
|
exit 1
|
|
fi
|
|
|
|
# Extract version from the deb filename (e.g. mcpctl_0.0.1_amd64.deb)
|
|
DEB_VERSION=$(dpkg-deb --field "$DEB_FILE" Version 2>/dev/null || echo "unknown")
|
|
|
|
echo "==> Publishing $DEB_FILE (version $DEB_VERSION) to ${GITEA_URL}..."
|
|
|
|
# Gitea Debian registry: PUT /api/packages/{owner}/debian/pool/{distribution}/{component}/upload
|
|
# We publish to each supported distribution.
|
|
# Debian: trixie (13/stable), forky (14/testing)
|
|
# Ubuntu: noble (24.04 LTS), plucky (25.04)
|
|
DISTRIBUTIONS="trixie forky noble plucky"
|
|
|
|
for DIST in $DISTRIBUTIONS; do
|
|
echo " -> $DIST..."
|
|
HTTP_CODE=$(curl -s -o /tmp/deb-upload-$DIST.out -w "%{http_code}" \
|
|
-X PUT \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
--upload-file "$DEB_FILE" \
|
|
"${GITEA_URL}/api/packages/${GITEA_OWNER}/debian/pool/${DIST}/main/upload")
|
|
|
|
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
|
|
echo " Published to $DIST"
|
|
elif [ "$HTTP_CODE" = "409" ]; then
|
|
echo " Already exists in $DIST (skipping)"
|
|
else
|
|
echo " WARNING: Upload to $DIST returned HTTP $HTTP_CODE"
|
|
cat /tmp/deb-upload-$DIST.out 2>/dev/null || true
|
|
echo ""
|
|
fi
|
|
rm -f /tmp/deb-upload-$DIST.out
|
|
done
|
|
|
|
echo ""
|
|
echo "==> Published successfully!"
|
|
|
|
# Ensure package is linked to the repository
|
|
source "$SCRIPT_DIR/link-package.sh"
|
|
link_package "debian" "mcpctl"
|
|
|
|
echo ""
|
|
echo "Install with:"
|
|
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"
|