Fixes to the set-version.sh script.

This commit is contained in:
Storm Dragon
2025-12-27 19:20:43 -05:00
parent 88a88574ac
commit af2b76e971
3 changed files with 64 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
# Maintainer: Storm Dragon <storm_dragon@stormux.org>
pkgname=cthulhu
pkgver=2025.12.27
pkgver=2025.12.27-testing
pkgrel=1
pkgdesc="Desktop-agnostic screen reader with plugin system, forked from Orca"
url="https://git.stormux.org/storm/cthulhu"

View File

@@ -1,5 +1,5 @@
project('cthulhu',
version: '2025.12.27',
version: '2025.12.27-testing',
meson_version: '>= 1.0.0',
)

View File

@@ -2,18 +2,60 @@
set -euo pipefail
scriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
newVersion="${1:-}"
dateInput="${1:-}"
branchInput="${2:-}"
if [[ -z "$newVersion" ]]; then
newVersion="$(date +%Y.%m.%d)"
if [[ -z "$dateInput" ]]; then
dateInput="$(date +%Y.%m.%d)"
fi
if [[ ! "$newVersion" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then
echo "Usage: $(basename "$0") [YYYY.MM.DD]" >&2
echo "Error: version must match YYYY.MM.DD" >&2
if [[ ! "$dateInput" =~ ^([0-9]{4}\.[0-9]{2}\.[0-9]{2})(-([A-Za-z0-9._-]+))?$ ]]; then
echo "Usage: $(basename "$0") [YYYY.MM.DD[-branch]] [branch]" >&2
echo "Error: version must match YYYY.MM.DD or YYYY.MM.DD-branch" >&2
exit 1
fi
datePart="${BASH_REMATCH[1]}"
suffixPart="${BASH_REMATCH[3]}"
if [[ -n "$suffixPart" && -n "$branchInput" ]]; then
echo "Warning: branch argument ignored because suffix was provided in version." >&2
branchInput=""
fi
if [[ -z "$suffixPart" ]]; then
if [[ -z "$branchInput" ]]; then
branchInput="$(git -C "$scriptDir" branch --show-current 2>/dev/null || true)"
fi
if [[ "$branchInput" == "HEAD" ]]; then
branchInput=""
fi
if [[ -n "$branchInput" ]]; then
branchName="$(printf '%s' "$branchInput" | sed 's/[^A-Za-z0-9._-]/-/g')"
branchName="${branchName#-}"
branchName="${branchName%-}"
suffixPart="$branchName"
fi
fi
pythonVersion="$datePart"
fullVersion="$datePart"
if [[ -n "$suffixPart" ]]; then
fullVersion="${fullVersion}-${suffixPart}"
fi
if [[ ! "$fullVersion" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}(-[A-Za-z0-9._-]+)?$ ]]; then
echo "Error: generated version '${fullVersion}' is invalid" >&2
exit 1
fi
codeNameValue=""
if [[ -n "$suffixPart" ]]; then
codeNameValue="$suffixPart"
fi
cthulhuVersionFile="${scriptDir}/src/cthulhu/cthulhuVersion.py"
mesonFile="${scriptDir}/meson.build"
pkgbuildFile="${scriptDir}/distro-packages/Arch-Linux/PKGBUILD"
@@ -25,20 +67,27 @@ for path in "$cthulhuVersionFile" "$mesonFile" "$pkgbuildFile"; do
fi
done
sed -i "s/^version = \".*\"/version = \"${newVersion}\"/" "$cthulhuVersionFile"
sed -i "s/^ version: '.*',/ version: '${newVersion}',/" "$mesonFile"
sed -i "s/^pkgver=.*/pkgver=${newVersion}/" "$pkgbuildFile"
sed -i "s/^version = \".*\"/version = \"${pythonVersion}\"/" "$cthulhuVersionFile"
if [[ -n "$codeNameValue" ]]; then
sed -i "s/^codeName = \".*\"/codeName = \"${codeNameValue}\"/" "$cthulhuVersionFile"
fi
sed -i "s/^ version: '.*',/ version: '${fullVersion}',/" "$mesonFile"
sed -i "s/^pkgver=.*/pkgver=${fullVersion}/" "$pkgbuildFile"
sed -i "s/^pkgrel=.*/pkgrel=1/" "$pkgbuildFile"
if ! rg -q "^version = \"${newVersion}\"" "$cthulhuVersionFile"; then
if ! rg -q "^version = \"${pythonVersion}\"" "$cthulhuVersionFile"; then
echo "Error: Failed to update ${cthulhuVersionFile}" >&2
exit 1
fi
if ! rg -q "^ version: '${newVersion}'," "$mesonFile"; then
if [[ -n "$codeNameValue" ]] && ! rg -q "^codeName = \"${codeNameValue}\"" "$cthulhuVersionFile"; then
echo "Error: Failed to update codeName in ${cthulhuVersionFile}" >&2
exit 1
fi
if ! rg -q "^ version: '${fullVersion}'," "$mesonFile"; then
echo "Error: Failed to update ${mesonFile}" >&2
exit 1
fi
if ! rg -q "^pkgver=${newVersion}$" "$pkgbuildFile"; then
if ! rg -q "^pkgver=${fullVersion}$" "$pkgbuildFile"; then
echo "Error: Failed to update ${pkgbuildFile}" >&2
exit 1
fi
@@ -47,7 +96,7 @@ if ! rg -q "^pkgrel=1$" "$pkgbuildFile"; then
exit 1
fi
echo "Updated version to ${newVersion} in:" \
echo "Updated version to ${fullVersion} in:" \
"${cthulhuVersionFile}" \
"${mesonFile}" \
"${pkgbuildFile}"