From 3e83b947849336ab658e2ab3527bce4b47d268ac Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 30 Jan 2024 16:16:02 +0300 Subject: [PATCH] Update update-version.sh --- update-version.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/update-version.sh b/update-version.sh index 04f931b..d2e5019 100755 --- a/update-version.sh +++ b/update-version.sh @@ -1,16 +1,21 @@ #/usr/bin/env bash -set -euo pipefail + # This script updates the version number in the README.md files of all modules # to the latest tag in the repository. It is intended to be run from the root # of the repository or by using the `bun update-version` command. +set -euo pipefail + LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') || exit $? find . -name README.md | while read -r file; do + tmpfile=$(mktemp /tmp/tempfile.XXXXXX) awk -v tag="$LATEST_TAG" '{ if ($1 == "version" && $2 == "=") { sub(/"[^"]*"/, "\"" tag "\"") + print + } else { + print } - print - }' "$file" > tmpfile && mv tmpfile "$file" -done \ No newline at end of file + }' "$file" > "$tmpfile" && mv "$tmpfile" "$file" +done