#!/usr/bin/env bash
# Tag-pipeline publish step.
#
# Inspected BlueGit master on 6 November 2026 (api_routes.go, ops_ci.go
# opPublishRelease, release_replace.go checkReplace, gitrepo.Tag):
# there is no route that attaches artifacts to an existing git tag or an
# existing release. POST /api/v1/repos/{owner}/{repo}/releases always creates
# the annotated tag. An existing tag returns HTTP 409 unless replace=true,
# and replace=true is HTTP 403 on a tag pipeline.
#
# This script therefore does not call that endpoint and does not send
# replace. It exits 3 until BlueGit grows an attach route. It does not
# invent a second tag and it does not switch the pipeline onto a branch
# release. The required server change is recorded in design.md section 15.
set -euo pipefail

: "${CI_API_URL:?}" "${CI_JOB_TOKEN:?}" "${CI_COMMIT_SHA:?}" "${CI_PROJECT_PATH:?}" "${CI_COMMIT_TAG:?}"

root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$root"
version="$(bash scripts/ci/package-version.sh)"

echo "release-blocked: no-attach-endpoint" >&2
echo "tag ${CI_COMMIT_TAG} version ${version} commit ${CI_COMMIT_SHA} project ${CI_PROJECT_PATH}" >&2
echo "BlueGit has no request that publishes these package artifacts onto the tag that already started this pipeline." >&2
echo "The create-release route would make a new annotated tag. This script does not call it." >&2
echo "The overwrite flag is not sent. No second tag is created." >&2
exit 3
