fix: don't delete RPM packages before uploading new arch
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>
This commit is contained in:
Michal Rydlikowski
2026-03-13 23:53:57 +00:00
parent 420f371897
commit dfc89058b4
2 changed files with 33 additions and 39 deletions

View File

@@ -35,31 +35,27 @@ if [ -z "$RPM_FILE" ]; then
exit 1
fi
# Get version string as it appears in Gitea (e.g. "0.1.0-1")
RPM_VERSION=$(rpm -qp --queryformat '%{VERSION}-%{RELEASE}' "$RPM_FILE")
echo "==> Publishing $RPM_FILE to ${GITEA_URL}..."
echo "==> Publishing $RPM_FILE (version $RPM_VERSION) to ${GITEA_URL}..."
# Check if version already exists and delete it first
EXISTING=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/packages/${GITEA_OWNER}/rpm/mcpctl/${RPM_VERSION}")
if [ "$EXISTING" = "200" ]; then
echo "==> Version $RPM_VERSION already exists, replacing..."
curl -s -o /dev/null -X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/packages/${GITEA_OWNER}/rpm/mcpctl/${RPM_VERSION}"
fi
# Upload
curl --fail -s -X PUT \
# 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"
"${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm/upload")
echo ""
echo "==> Published successfully!"
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"