-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·91 lines (74 loc) · 2.43 KB
/
release.sh
File metadata and controls
executable file
·91 lines (74 loc) · 2.43 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
#!/usr/bin/env bash
# release.sh — two-phase release wrapper around cargo-release
#
# Usage:
# scripts/release.sh prepare <version> # steps 0-2: branch, bump, push PR
# scripts/release.sh finish # step 4: tag, publish, trigger dist
set -euo pipefail
COMMAND="${1:-}"
VERSION="${2:-}"
usage() {
echo "Usage:"
echo " scripts/release.sh prepare <version> # create release branch and open PR"
echo " scripts/release.sh finish # tag and publish from main"
exit 1
}
require_clean_tree() {
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "error: working tree is not clean. Commit or stash your changes first."
exit 1
fi
}
case "$COMMAND" in
prepare)
if [ -z "$VERSION" ]; then
echo "error: version required (e.g. scripts/release.sh prepare 0.2.0)"
usage
fi
BRANCH="release/$VERSION"
require_clean_tree
# step 0: create release branch
echo "→ Creating branch $BRANCH"
git checkout -b "$BRANCH"
# step 2: bump versions, commit, push branch
echo ""
echo "→ Running cargo release (no publish, no tag)..."
cargo release --no-publish --no-tag --allow-branch="$BRANCH" --execute "$VERSION"
echo ""
echo "→ Opening pull request..."
PR_URL=$(gh pr create \
--title "chore: Release hotdata-cli version $VERSION" \
--body "" \
--base main \
--head "$BRANCH")
echo ""
echo "✓ PR created: $PR_URL"
if command -v xdg-open &>/dev/null; then
xdg-open "$PR_URL" || true
elif command -v open &>/dev/null; then
open "$PR_URL" || true
fi
echo ""
echo "Next steps:"
echo " 1. Review and merge the PR (use 'Squash and merge')"
echo " 2. Run: scripts/release.sh finish"
;;
finish)
require_clean_tree
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ "$CURRENT_BRANCH" != "main" ]; then
echo "→ Switching to main..."
git checkout main
fi
echo "→ Pulling latest main..."
git pull
echo ""
echo "→ Running cargo release (tagging release)..."
cargo release
echo ""
echo "✓ Release complete. Tag pushed and dist workflow triggered."
;;
*)
usage
;;
esac