Skip to content

Commit

Permalink
fix version bump script generates garbage files
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Feb 22, 2024
1 parent ec9009f commit 83b81d5
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions scripts/bump-version.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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"
Expand Down

0 comments on commit 83b81d5

Please sign in to comment.