#!/bin/sh # The version file is the single source of truth for a release: it triggers the # packaging workflow and names the tag, the Gitea release and the Arch package. # It tracks the FWS fork version, which is independent from the upstream kitty # release shipped inside the package. Both numbers are duplicated where the # build reads them, so this script checks they still agree and prints the # release 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) fail() { echo "::error file=$1::$2" exit 1 } version=$(tr -d '[:space:]' < "$root/version") case "$version" in ''|*[!0-9.]*|.*|*..*|*.) fail version "expected MAJOR.MINOR.PATCH, got '$version'" ;; esac if [ "$(printf '%s' "$version" | awk -F. '{print NF}')" -ne 3 ]; then fail version "expected MAJOR.MINOR.PATCH, got '$version'" 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 fail packaging/PKGBUILD "pkgver is '$pkgver' but the version file says '$version'" fi # The upstream kitty release follows kitty, not the fork: it lives in its own # variable and must keep matching the constant kitty compiles into the binaries. kitty_version=$(sed -n 's/^_kittyver=//p' "$root/packaging/PKGBUILD" | head -n 1) 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" != "$kitty_version" ]; then fail kitty/constants.py "kitty reports '$constants' but _kittyver in the PKGBUILD says '$kitty_version'" fi # The fork version is hard-coded in both front-ends, so bumping only the version # file would ship binaries announcing the previous release. for f in tools/cli/help.go kitty/launcher/main.c; do if ! grep -qF "$version" "$root/$f"; then fail "$f" "the fork version '$version' is not set in this file" fi done printf '%s\n' "$version"