nerd-fonts/bin/scripts/version-bump.sh
Fini Jastrow 7b81d7c84a CI: Fix version bump
[why]
This can not work.

Issue 1:
It is unspecified in which order the font matrix jobs run, so the
version number changes somewhen.

The changed (version-bumped) files are never committed and written back,
so this would have to be done manually anyhow.

The version-bump script itself has issues because the regexes for the
change are a bit too loose and other version like strings are changes
also (like the Script Version).

Issue 2:
The script changed versions that should not be changed like the script version
in the scripts (rather than the NF release version).

In bin/scripts/generate-glyph-info-from-set.py pumping has been
forgotten/omitted completely.

[how]
In the version-bump script:
* Use more modern regex
* Instead of copying the code use a loop

Create a commit with the bumped version information in all scripts.
This can only be done with the final job, because we have a problem to
checkout the modified version with actions/checkout.

We need to bump the version on every patch job, because we need the correct
information already in the script when we patch.

[note]
This does not prevent to have multiple commits attempts that change to the same
version. But if the change is empty, no commit will be added and the
step is silently ignored.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2022-08-24 10:50:06 +02:00

29 lines
905 B
Bash
Executable file

#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# Script Version: 1.0.2
# bump version number for release in scripts (bash and python)
# does not do semver format checking
# this obviously is not perfect but works good enough for now (YAGNI)
# todo take some ideas from: https://github.com/fsaintjacques/semver-tool
#set -x
LINE_PREFIX="# [Nerd Fonts] "
if [ ! $# -eq 1 ]
then
echo "$LINE_PREFIX No release version given, must give semver release version in format: #.#.#, e.g. 1.1.0"
fi
release=$1
echo "$LINE_PREFIX Bump version to $release"
function patch_file {
echo patching $1
sed -i -E "s/^(# Nerd Fonts Version: )[0-9]+\.[0-9]+\.[0-9]+.*/\1$release/" "$1"
sed -i -E "s/^(version *= *\")[0-9]+\.[0-9]+\.[0-9]+.*(\") *$/\1$release\2/" "$1"
}
while IFS= read -r file; do
patch_file "$file"
done < <(find ../.. -name "*.sh" -o -name "*.py" -o -name "font-patcher" -type f)