-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·97 lines (80 loc) · 2.16 KB
/
release.sh
File metadata and controls
executable file
·97 lines (80 loc) · 2.16 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -euo pipefail
VERSION="${1:-}"
RELEASE_NOTE_FILE="RELEASE_NOTE.md"
TAG="v$VERSION"
if [ -z "$VERSION" ]; then
echo "Usage: ./release.sh <version> (e.g., 1.0.0)"
exit 1
fi
ensure_release_note_file() {
if [ -f "$RELEASE_NOTE_FILE" ]; then
return
fi
cat >"$RELEASE_NOTE_FILE" <<'NOTE'
# Release Notes
NOTE
}
append_release_note_template() {
cat >>"$RELEASE_NOTE_FILE" <<NOTE
## v$VERSION
- TODO: summarize the changes in v$VERSION.
NOTE
}
extract_release_note_section() {
awk -v section="## v$VERSION" '
$0 == section { capture = 1; print; next }
capture && /^## / { exit }
capture { print }
' "$RELEASE_NOTE_FILE"
}
ensure_release_note_file
if ! grep -Fqx "## v$VERSION" "$RELEASE_NOTE_FILE"; then
append_release_note_template
echo "Added a release note template for v$VERSION in $RELEASE_NOTE_FILE."
echo "Please update it before running release.sh again."
exit 1
fi
if ! command -v cargo >/dev/null 2>&1; then
echo "cargo not found"
exit 1
fi
if ! cargo set-version --help >/dev/null 2>&1; then
echo "cargo set-version not found. Install with: cargo install cargo-edit"
exit 1
fi
cargo update
cargo fmt
cargo clippy --workspace --all-targets -- -D warnings -A clippy::too_many_arguments
cargo set-version "$VERSION"
cargo check -p gproxy
git add \
Cargo.toml \
Cargo.lock \
apps/*/Cargo.toml \
crates/*/Cargo.toml \
sdk/*/Cargo.toml \
"$RELEASE_NOTE_FILE"
git commit -m "Release v$VERSION"
git push
tag_note_file="$(mktemp)"
{
echo "v$VERSION"
echo
extract_release_note_section
} >"$tag_note_file"
git tag -a "$TAG" -F "$tag_note_file"
rm -f "$tag_note_file"
git push origin "$TAG"
if command -v gh >/dev/null 2>&1; then
release_note_tmp="$(mktemp)"
extract_release_note_section >"$release_note_tmp"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" --title "$TAG" --notes-file "$release_note_tmp"
else
gh release create "$TAG" --title "$TAG" --notes-file "$release_note_tmp"
fi
rm -f "$release_note_tmp"
else
echo "gh CLI not found, skipped GitHub Release body update."
fi