-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·73 lines (63 loc) · 2.36 KB
/
release.sh
File metadata and controls
executable file
·73 lines (63 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env sh
#
# Prepare a release.
#
# Usage
#
# ./scripts/release.sh [rooster-args ...]
#
set -eu
echo "Checking Ruff submodule status..."
if git -C ruff diff --quiet; then
echo "Ruff submodule is clean; continuing..."
else
echo "Ruff submodule has uncommitted changes; aborting!"
exit 1
fi
ruff_head=$(git -C ruff rev-parse --abbrev-ref HEAD)
case "${ruff_head}" in
"HEAD")
echo "Ruff submodule has detached HEAD; switching to main..."
git -C ruff checkout main > /dev/null 2>&1
;;
"main")
echo "Ruff submodule is on main branch; continuing..."
;;
*)
echo "Ruff submodule is on branch ${ruff_head} but must be on main; aborting!"
exit 1
;;
esac
# Save the current typeshed source commit before updating ruff,
# so we can generate a typeshed diff link for the changelog later.
typeshed_commit_file="ruff/crates/ty_vendored/vendor/typeshed/source_commit.txt"
old_typeshed_commit=""
if [ -f "$typeshed_commit_file" ]; then
old_typeshed_commit=$(cat "$typeshed_commit_file")
fi
echo "Updating Ruff to the latest commit..."
git -C ruff pull origin main
git add ruff
script_root="$(realpath "$(dirname "$0")")"
project_root="$(dirname "$script_root")"
echo "Running rooster..."
cd "$project_root"
# Generate the changelog and bump versions
uv run --isolated --only-group release \
rooster release "$@"
# If the typeshed source commit changed and the changelog mentions a typeshed
# sync, append a link to the typeshed diff so reviewers can see what changed.
if [ -n "$old_typeshed_commit" ] && [ -f "$typeshed_commit_file" ]; then
new_typeshed_commit=$(cat "$typeshed_commit_file")
if [ "$old_typeshed_commit" != "$new_typeshed_commit" ]; then
typeshed_diff_link="[Typeshed diff](https://github.com/python/typeshed/compare/${old_typeshed_commit}...${new_typeshed_commit})"
# Match lines like "- Sync vendored typeshed stubs ([#NNNN](...))".
# The pattern anchors on the trailing "))$" so it won't match lines
# that already have a typeshed diff link appended.
# Use a temp file instead of `sed -i` for macOS/Linux portability.
sed "s|\(- Sync vendored typeshed stubs (.*)\))$|\1). ${typeshed_diff_link}|" CHANGELOG.md > CHANGELOG.md.tmp
mv CHANGELOG.md.tmp CHANGELOG.md
fi
fi
"${script_root}/autogenerate_files.sh"
git add ./docs/reference