Skip to content

Commit a0b4020

Browse files
Merge pull request #15 from dell/fix/release-script
fix bad gitignore rule blocking necessary release script
2 parents 9a0529b + 0c5384d commit a0b4020

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ cli/entry-metrics.json
133133

134134
<<<<<<< Updated upstream
135135
# Release test dir
136-
release/
136+
/release/
137137
=======
138138
# CLI codehealth artifacts
139139
cli/tools/codehealth/deadfinder/deadfinder
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Validate that version metadata is synchronized across the repository.
5+
6+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
7+
VERSION_FILE="${ROOT_DIR}/VERSION"
8+
9+
usage() {
10+
cat <<'EOF'
11+
Usage: check_version_sync.sh [--expected VERSION] [--allow-snapshot]
12+
13+
Ensures VERSION is set and referenced consistently across build tooling.
14+
Fails fast if mismatches are detected.
15+
EOF
16+
}
17+
18+
EXPECTED_VERSION=""
19+
ALLOW_SNAPSHOT="false"
20+
21+
while [[ $# -gt 0 ]]; do
22+
case "$1" in
23+
--expected)
24+
shift
25+
[[ $# -gt 0 ]] || { echo "error: --expected requires a value" >&2; exit 2; }
26+
EXPECTED_VERSION="$1"
27+
;;
28+
--allow-snapshot)
29+
ALLOW_SNAPSHOT="true"
30+
;;
31+
-h|--help)
32+
usage
33+
exit 0
34+
;;
35+
*)
36+
echo "error: unknown argument: $1" >&2
37+
usage >&2
38+
exit 2
39+
;;
40+
esac
41+
shift
42+
done
43+
44+
errors=()
45+
46+
if [[ ! -f "${VERSION_FILE}" ]]; then
47+
errors+=("VERSION file missing at ${VERSION_FILE}")
48+
else
49+
REPO_VERSION="$(<"${VERSION_FILE}")"
50+
REPO_VERSION="${REPO_VERSION//$'\n'/}"
51+
if [[ -z "${REPO_VERSION}" ]]; then
52+
errors+=("VERSION file is empty")
53+
fi
54+
if [[ "${ALLOW_SNAPSHOT}" != "true" && "${REPO_VERSION}" == *"-SNAPSHOT" ]]; then
55+
errors+=("VERSION ${REPO_VERSION} still marked as SNAPSHOT; releases must use final SemVer")
56+
fi
57+
if [[ -n "${EXPECTED_VERSION}" && "${EXPECTED_VERSION}" != "${REPO_VERSION}" ]]; then
58+
errors+=("VERSION mismatch: expected '${EXPECTED_VERSION}', found '${REPO_VERSION}'")
59+
fi
60+
fi
61+
62+
check_contains() {
63+
local file="$1"
64+
local pattern="$2"
65+
if [[ ! -f "${ROOT_DIR}/${file}" ]]; then
66+
errors+=("Expected file ${file} not found")
67+
return
68+
fi
69+
if ! grep -qF "${pattern}" "${ROOT_DIR}/${file}"; then
70+
errors+=("Expected to find '${pattern}' in ${file}")
71+
fi
72+
}
73+
74+
check_contains "cli/Makefile" "VERSION_FILE ?= ../VERSION"
75+
check_contains "engine/Makefile" "VERSION_FILE := ../VERSION"
76+
check_contains "engine/build.gradle" "file('../VERSION').text.trim()"
77+
check_contains "engine/bundle/build.gradle" "rootProject.ext.SPT_VERSION"
78+
check_contains "engine/bundle/Dockerfile" "ARG SPT_VERSION="
79+
check_contains "engine/bundle/Dockerfile" "LABEL version=\"\${SPT_VERSION}\""
80+
81+
if [[ "${#errors[@]}" -gt 0 ]]; then
82+
printf 'Version sync check failed:\n' >&2
83+
for err in "${errors[@]}"; do
84+
printf ' - %s\n' "${err}" >&2
85+
done
86+
exit 1
87+
fi
88+
89+
printf 'Version sync check passed. VERSION=%s\n' "${REPO_VERSION:-unknown}"

0 commit comments

Comments
 (0)