Update update-version.sh

pull/128/head
Muhammad Atif Ali 1 year ago committed by GitHub
parent f18ee394aa
commit 3e83b94784
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,16 +1,21 @@
#/usr/bin/env bash #/usr/bin/env bash
set -euo pipefail
# This script updates the version number in the README.md files of all modules # 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 # 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. # 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 $? LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') || exit $?
find . -name README.md | while read -r file; do find . -name README.md | while read -r file; do
tmpfile=$(mktemp /tmp/tempfile.XXXXXX)
awk -v tag="$LATEST_TAG" '{ awk -v tag="$LATEST_TAG" '{
if ($1 == "version" && $2 == "=") { if ($1 == "version" && $2 == "=") {
sub(/"[^"]*"/, "\"" tag "\"") sub(/"[^"]*"/, "\"" tag "\"")
print
} else {
print
} }
print }' "$file" > "$tmpfile" && mv "$tmpfile" "$file"
}' "$file" > tmpfile && mv tmpfile "$file"
done done
Loading…
Cancel
Save