023a6f03e2
Avoid a failed/confusing re-upload by checking whether the package is already published before PUTting it. artifactapi has no HEAD route (returns 405), so the guard uses a GET against the served path (RPMs are stored under Packages/): a 200 means it exists and the upload is skipped, anything else proceeds. Also point at the reachable artifactapi host (artifactapi.k8s.syd1.au.unkin.net, as used by rpmbuilder) instead of the unresolvable artifactapi3 name.
39 lines
1.3 KiB
YAML
39 lines
1.3 KiB
YAML
when:
|
|
- event: tag
|
|
|
|
steps:
|
|
- name: build
|
|
image: git.unkin.net/unkin/almalinux9-gobuilder:20260606
|
|
commands:
|
|
- make build VERSION=${CI_COMMIT_TAG}
|
|
|
|
- name: package
|
|
image: git.unkin.net/unkin/almalinux9-rpmbuilder:latest
|
|
commands:
|
|
- ./scripts/build-rpm.sh ${CI_COMMIT_TAG}
|
|
depends_on: [build]
|
|
|
|
- name: upload
|
|
image: git.unkin.net/unkin/almalinux9-base:20260606
|
|
commands:
|
|
- |
|
|
HOST="https://artifactapi.k8s.syd1.au.unkin.net"
|
|
REPO="rpm-internal"
|
|
for rpm in dist/*.rpm; do
|
|
FILE=$$(basename "$$rpm")
|
|
# Verify the package isn't already published before uploading.
|
|
# artifactapi has no HEAD route (returns 405), so probe with GET
|
|
# against the served path (RPMs are stored under Packages/).
|
|
code=$$(curl -s -o /dev/null -w '%{http_code}' "$$HOST/api/v2/remotes/$$REPO/files/Packages/$$FILE" || true)
|
|
if [ "$$code" = "200" ]; then
|
|
echo "$$FILE already exists in $$REPO (HTTP $$code); skipping upload"
|
|
continue
|
|
fi
|
|
echo "Uploading $$FILE to $$REPO (existence probe returned $$code)"
|
|
curl -f -X PUT \
|
|
"$$HOST/api/v2/remotes/$$REPO/files/$$FILE" \
|
|
-H "Content-Type: application/x-rpm" \
|
|
--data-binary @"$$rpm"
|
|
done
|
|
depends_on: [package]
|