mirror of
https://github.com/Sea-Haven-Industries/.github.git
synced 2026-10-05 07:12:03 +00:00
fix(ci): pick the ancestor release in the Lambda ship-gate (PLAT-79)
This commit is contained in:
parent
1528c01e94
commit
99a1786221
1 changed files with 22 additions and 9 deletions
31
.github/workflows/cd-hcp-lambda.yaml
vendored
31
.github/workflows/cd-hcp-lambda.yaml
vendored
|
|
@ -123,7 +123,10 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATTERN TAG
|
export PATTERN TAG
|
||||||
PREV="$(
|
# Newest matching release that is an ancestor of TAG. The highest
|
||||||
|
# release overall is not that ancestor when a hotfix is cut from an
|
||||||
|
# older line (v2.0.0 exists, v1.2.1 is cut from v1.2.0).
|
||||||
|
CANDIDATES="$(
|
||||||
gh api "repos/${REPO}/releases" --paginate --jq '.[].tag_name' | python3 -c '
|
gh api "repos/${REPO}/releases" --paginate --jq '.[].tag_name' | python3 -c '
|
||||||
import os, re, sys
|
import os, re, sys
|
||||||
pattern = re.compile(os.environ["PATTERN"])
|
pattern = re.compile(os.environ["PATTERN"])
|
||||||
|
|
@ -137,21 +140,31 @@ jobs:
|
||||||
body = tag[1:]
|
body = tag[1:]
|
||||||
core = body.split("-", 1)[0]
|
core = body.split("-", 1)[0]
|
||||||
return tuple(int(part) for part in core.split("."))
|
return tuple(int(part) for part in core.split("."))
|
||||||
tags.sort(key=key)
|
tags.sort(key=key, reverse=True)
|
||||||
print(tags[-1] if tags else "")
|
print("\n".join(tags))
|
||||||
'
|
'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
PREV=""
|
||||||
|
if [ -n "${CANDIDATES}" ]; then
|
||||||
|
while IFS= read -r candidate; do
|
||||||
|
if [ -z "${candidate}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
candidate_status="$(gh api "repos/${REPO}/compare/${candidate}...${TAG}" --jq .status)"
|
||||||
|
if [ "${candidate_status}" = "ahead" ]; then
|
||||||
|
PREV="${candidate}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done <<< "${CANDIDATES}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${PREV}" ]; then
|
if [ -z "${PREV}" ]; then
|
||||||
echo "ship-gate: no previous matching release tag; hotfix path requires a prior ${PATTERN} release" >&2
|
echo "ship-gate: no prior ${PATTERN} release is an ancestor of ${TAG}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ff_status="$(gh api "repos/${REPO}/compare/${PREV}...${TAG}" --jq .status)"
|
echo "ship-gate: ${TAG} is ahead of ${PREV}"
|
||||||
if [ "${ff_status}" != "ahead" ]; then
|
|
||||||
echo "ship-gate: ${TAG} is not a fast-forward of ${PREV} (status: ${ff_status})" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
from_train=false
|
from_train=false
|
||||||
TARGET_COMMITISH="$(gh api "repos/${REPO}/releases/tags/${TAG}" --jq .target_commitish 2>/dev/null || true)"
|
TARGET_COMMITISH="$(gh api "repos/${REPO}/releases/tags/${TAG}" --jq .target_commitish 2>/dev/null || true)"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue