All checks were successful
CI/CD / lint (push) Successful in 46s
CI/CD / test (push) Successful in 1m1s
CI/CD / typecheck (push) Successful in 2m49s
CI/CD / smoke (push) Successful in 7m4s
CI/CD / build (amd64) (push) Successful in 5m32s
CI/CD / publish-rpm (arm64) (push) Has been skipped
CI/CD / publish-deb (arm64) (push) Has been skipped
CI/CD / build (arm64) (push) Successful in 5m23s
CI/CD / publish-deb (amd64) (push) Successful in 43s
CI/CD / publish-rpm (amd64) (push) Successful in 45s
The publish-rpm step was deleting the existing package by version before uploading, but Gitea RPM registry keys by version (not version+arch). When building both amd64 and arm64 in a matrix, the second job would delete the first job's upload. Remove the delete-before-upload pattern. Gitea supports multiple architectures under the same version. Handle 409 (already exists) gracefully instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
1.9 KiB
Bash
Executable File
67 lines
1.9 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 RPM matching target architecture (RPM uses x86_64/aarch64)
|
|
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | grep -E "[._]${RPM_ARCH}[._]" | head -1)
|
|
if [ -z "$RPM_FILE" ]; then
|
|
# Fallback: try any rpm file
|
|
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | head -1)
|
|
fi
|
|
if [ -z "$RPM_FILE" ]; then
|
|
echo "Error: No RPM found in dist/. Run scripts/build-rpm.sh first."
|
|
exit 1
|
|
fi
|
|
|
|
echo "==> Publishing $RPM_FILE to ${GITEA_URL}..."
|
|
|
|
# Upload — don't delete existing packages, Gitea supports
|
|
# multiple architectures under the same version.
|
|
HTTP_CODE=$(curl -s -o /tmp/rpm-upload.out -w "%{http_code}" \
|
|
-X PUT \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
--upload-file "$RPM_FILE" \
|
|
"${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm/upload")
|
|
|
|
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "200" ]; then
|
|
echo "==> Published successfully!"
|
|
elif [ "$HTTP_CODE" = "409" ]; then
|
|
echo "==> Already exists (same arch+version), skipping"
|
|
else
|
|
echo "==> Upload returned HTTP $HTTP_CODE"
|
|
cat /tmp/rpm-upload.out 2>/dev/null || true
|
|
rm -f /tmp/rpm-upload.out
|
|
exit 1
|
|
fi
|
|
rm -f /tmp/rpm-upload.out
|
|
|
|
# Ensure package is linked to the repository
|
|
source "$SCRIPT_DIR/link-package.sh"
|
|
link_package "rpm" "mcpctl"
|
|
|
|
echo ""
|
|
echo "Install with:"
|
|
echo " sudo dnf install mcpctl # if repo already configured"
|