From 83b81d5ee5db52a2f39ab7c460d42fcd3ecf89ae Mon Sep 17 00:00:00 2001 From: rhysd Date: Thu, 22 Feb 2024 11:52:51 +0900 Subject: [PATCH] fix version bump script generates garbage files --- scripts/bump-version.bash | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/bump-version.bash b/scripts/bump-version.bash index 843a7262f..f3812bbf3 100755 --- a/scripts/bump-version.bash +++ b/scripts/bump-version.bash @@ -31,14 +31,16 @@ if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then exit 1 fi -case "$OSTYPE" in - darwin*) - sed="/usr/bin/sed -i '' -E" - ;; - *) - sed="sed -i -E" - ;; -esac +function sed_() { + case "$OSTYPE" in + darwin*) + /usr/bin/sed -i '' -E "$@" + ;; + *) + sed -i -E "$@" + ;; + esac +} pre_commit_hook='./.pre-commit-hooks.yaml' usage_doc='./docs/usage.md' @@ -49,12 +51,12 @@ echo "Bumping up version to ${version} (tag: ${tag})" # Update container image tag in pre-commit hook (See #116 for more details) echo "Updating $pre_commit_hook" -$sed "s/entry: docker.io\\/rhysd\\/actionlint:.*/entry: docker.io\\/rhysd\\/actionlint:${version}/" "$pre_commit_hook" +sed_ "s/entry: docker\\.io\\/rhysd\\/actionlint:.*/entry: docker.io\\/rhysd\\/actionlint:${version}/" "$pre_commit_hook" echo "Updating $usage_doc" -$sed "s/ rev: v[0-9]+\.[0-9]+\.[0-9]+/ rev: v${version}/" "$usage_doc" -$sed "s/actionlint@[0-9]+\.[0-9]+\.[0-9]+/actionlint@${version}/g" "$usage_doc" -$sed "s/\`actionlint:[0-9]+\.[0-9]+\.[0-9]+\`/\`actionlint:${version}\`/g" "$usage_doc" +sed_ "s/ rev: v[0-9]+\.[0-9]+\.[0-9]+/ rev: v${version}/" "$usage_doc" +sed_ "s/actionlint@[0-9]+\.[0-9]+\.[0-9]+/actionlint@${version}/g" "$usage_doc" +sed_ "s/\`actionlint:[0-9]+\.[0-9]+\.[0-9]+\`/\`actionlint:${version}\`/g" "$usage_doc" echo 'Creating a version bump commit and a version tag' git add "$pre_commit_hook" "$usage_doc"