Skip to content

Commit d1f9368

Browse files
Automate CA template date sync and guard enforcement
1 parent 402fc96 commit d1f9368

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

pkg_build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version_override="${FVPLUS_VERSION_OVERRIDE:-}"
77
today_version="$(date +"%Y.%m.%d")"
88
version="${today_version}.01"
99
plgfile="$CWD/folderview.plus.plg"
10+
xmlfile="$CWD/folderview.plus.xml"
1011
archive_prefix="folderview.plus"
1112
icon_ext_regex='^(png|jpg|jpeg|gif|webp|svg|bmp|ico|avif)$'
1213

@@ -211,6 +212,17 @@ md5=$(md5sum "$filename" | awk '{print $1}')
211212
sed -i "s/<!ENTITY version.*>/<!ENTITY version \"$version\">/" "$plgfile"
212213
sed -i "s/<!ENTITY md5.*>/<!ENTITY md5 \"$md5\">/" "$plgfile"
213214

215+
# Keep CA template date aligned with the release version date.
216+
if [[ "$version" =~ ^([0-9]{4})\.([0-9]{2})\.([0-9]{2})(\.[0-9]+|-beta[0-9]*)?$ ]]; then
217+
xml_date="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}-${BASH_REMATCH[3]}"
218+
if [ -f "$xmlfile" ]; then
219+
sed -i "s|<Date>.*</Date>|<Date>${xml_date}</Date>|" "$xmlfile"
220+
else
221+
echo "ERROR: Missing CA template file: $xmlfile" >&2
222+
exit 1
223+
fi
224+
fi
225+
214226
# Update branch references in plg file (URLs use XML entities like &github;)
215227
sed -i 's|/main/folderview.plus.plg|/'"$branch"'/folderview.plus.plg|' "$plgfile"
216228
sed -i 's|/main/archive/|/'"$branch"'/archive/|' "$plgfile"

scripts/release_guard.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -euo pipefail
33

44
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
PLG_FILE="${ROOT_DIR}/folderview.plus.plg"
6+
CA_TEMPLATE_FILE="${ROOT_DIR}/folderview.plus.xml"
67
PLUGIN_SRC_DIR="${ROOT_DIR}/src/folderview.plus/usr/local/emhttp/plugins/folderview.plus"
78
SERVER_DIR="${PLUGIN_SRC_DIR}/server"
89
MAX_ARCHIVE_BYTES="${FVPLUS_MAX_ARCHIVE_BYTES:-52428800}" # 50 MiB default ceiling
@@ -40,6 +41,23 @@ if [[ "${VERSION}" =~ ^([0-9]{4}\.[0-9]{2}\.[0-9]{2})(\.[0-9]{2,}|-beta[0-9]*)$
4041
fi
4142
fi
4243

44+
if [[ ! -f "${CA_TEMPLATE_FILE}" ]]; then
45+
echo "ERROR: Missing CA template file: ${CA_TEMPLATE_FILE}" >&2
46+
exit 1
47+
fi
48+
49+
CA_TEMPLATE_DATE="$(sed -n 's|.*<Date>\([^<]*\)</Date>.*|\1|p' "${CA_TEMPLATE_FILE}" | head -n 1 || true)"
50+
if [[ -z "${CA_TEMPLATE_DATE}" ]]; then
51+
echo "ERROR: Could not parse <Date> from ${CA_TEMPLATE_FILE}" >&2
52+
exit 1
53+
fi
54+
55+
EXPECTED_CA_TEMPLATE_DATE="${VERSION_DATE//./-}"
56+
if [[ "${CA_TEMPLATE_DATE}" != "${EXPECTED_CA_TEMPLATE_DATE}" ]]; then
57+
echo "ERROR: CA template <Date> mismatch. expected=${EXPECTED_CA_TEMPLATE_DATE}, found=${CA_TEMPLATE_DATE}" >&2
58+
exit 1
59+
fi
60+
4361
if command -v xmllint >/dev/null 2>&1; then
4462
xmllint --noout "${PLG_FILE}"
4563
else

0 commit comments

Comments
 (0)