Releases were built and uploaded by hand, so the published package could lag behind main and nothing checked the tree before it shipped. The new version file drives a pipeline that lints, builds and tests the exact commit, then creates the Gitea release and pushes the package to the pacman repository.
43 lines
1.6 KiB
Bash
Executable File
43 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# The version file is the single source of truth for a release: it triggers the
|
|
# packaging workflow and names the tag and the Gitea release. The version is
|
|
# also duplicated where kitty and makepkg expect it, so this script checks they
|
|
# still agree and prints the version for the workflows to reuse:
|
|
#
|
|
# version="$(packaging/check-version.sh)"
|
|
#
|
|
# It runs on the CI runner and locally, before any build.
|
|
set -eu
|
|
|
|
root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
|
|
version=$(tr -d '[:space:]' < "$root/version")
|
|
|
|
case "$version" in
|
|
''|*[!0-9.]*|.*|*..*|*.)
|
|
echo "::error file=version::expected MAJOR.MINOR.PATCH, got '$version'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
if [ "$(printf '%s' "$version" | awk -F. '{print NF}')" -ne 3 ]; then
|
|
echo "::error file=version::expected MAJOR.MINOR.PATCH, got '$version'"
|
|
exit 1
|
|
fi
|
|
|
|
# kitty reads its own version from this constant, and it ends up in the
|
|
# binaries and the man pages, so the release version must not drift from it.
|
|
constants=$(sed -n 's/^version: Version = Version(\([0-9]*\), \([0-9]*\), \([0-9]*\)).*/\1.\2.\3/p' "$root/kitty/constants.py" | head -n 1)
|
|
if [ "$constants" != "$version" ]; then
|
|
echo "::error file=kitty/constants.py::kitty reports '$constants' but the version file says '$version'"
|
|
exit 1
|
|
fi
|
|
|
|
# makepkg names the package from pkgver, so an out-of-date PKGBUILD would
|
|
# publish a package whose name does not match its release.
|
|
pkgver=$(sed -n 's/^pkgver=//p' "$root/packaging/PKGBUILD" | head -n 1)
|
|
if [ "$pkgver" != "$version" ]; then
|
|
echo "::error file=packaging/PKGBUILD::pkgver is '$pkgver' but the version file says '$version'"
|
|
exit 1
|
|
fi
|
|
|
|
printf '%s\n' "$version"
|