Skip to content

Commit 8bef828

Browse files
committed
🔧 strip README dependency patches via hook
1 parent b70dd98 commit 8bef828

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

release.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
tag-name = "{{crate_name}}-{{version}}"
22
pre-release-commit-message = ":bookmark: Bump {{crate_name}} version to {{version}}"
3+
pre-release-hook = ["bash", "-lc", "cd $(git rev-parse --show-toplevel) && ./scripts/strip-readme-patch.sh {{version}}"]

scripts/strip-readme-patch.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -ne 1 ]]; then
5+
echo "Usage: $0 <version>" >&2
6+
exit 1
7+
fi
8+
9+
full_version="$1"
10+
minor_version="${full_version%.*}"
11+
if [[ "$minor_version" == "$full_version" ]]; then
12+
minor_version="$full_version"
13+
fi
14+
15+
export STRIP_README_FULL_VERSION="$full_version"
16+
export STRIP_README_MINOR_VERSION="$minor_version"
17+
18+
repo_root=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
19+
cd "$repo_root"
20+
21+
while IFS= read -r -d '' readme; do
22+
perl -0pi -e '
23+
my $from = $ENV{STRIP_README_FULL_VERSION};
24+
my $to = $ENV{STRIP_README_MINOR_VERSION};
25+
die "STRIP_README_FULL_VERSION not set" unless defined $from;
26+
die "STRIP_README_MINOR_VERSION not set" unless defined $to;
27+
s/(= ?")\Q$from\E(")/$1$to$2/g;
28+
s/(version ?= ?")\Q$from\E(")/$1$to$2/g;
29+
' "$readme"
30+
done < <(find . -name README.md -print0)

0 commit comments

Comments
 (0)