Files
Echoion/scripts/restore-gitea-release-tag.sh
faumaray 4b2008bc2b
Modular container CI / release-build (push) Has been cancelled
Release: restore annotated component tags
2026-07-30 03:25:55 +03:00

50 lines
951 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
usage() {
printf '%s\n' \
'Usage: restore-gitea-release-tag.sh --repository URL --tag TAG'
}
repository=
tag=
while (($# > 0)); do
case "$1" in
--repository)
repository=${2-}
shift 2
;;
--tag)
tag=${2-}
shift 2
;;
--help|-h)
usage
exit 0
;;
*)
printf 'restore-gitea-release-tag: unknown argument: %s\n' "$1" >&2
usage >&2
exit 2
;;
esac
done
if [[ -z $repository || $repository == -* || -z $tag ]]; then
usage >&2
exit 2
fi
tag_ref="refs/tags/$tag"
if ! git check-ref-format "$tag_ref"; then
printf '%s\n' 'restore-gitea-release-tag: invalid tag name' >&2
exit 1
fi
# actions/checkout can replace an annotated tag with a lightweight local ref
# when Gitea reports the target commit as the workflow event SHA. Fetch the
# exact remote tag object before performing signature verification.
git fetch --force --no-tags "$repository" "+$tag_ref:$tag_ref"