-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·139 lines (115 loc) · 3.66 KB
/
release.sh
File metadata and controls
executable file
·139 lines (115 loc) · 3.66 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -e
# Colors and formatting
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
BOLD='\033[1m'
print_step() {
echo -e "\n${BOLD}${GREEN}=== $1 ===${NC}\n"
}
print_warning() {
echo -e "${YELLOW}WARNING: $1${NC}"
}
print_error() {
echo -e "${RED}ERROR: $1${NC}"
}
confirm() {
echo -e -n "${BOLD}$1 (y/N) ${NC}"
read -r response
[[ "$response" == "y" ]]
}
# Header
echo -e "${BOLD}${GREEN}"
echo "╔════════════════════════════════════╗"
echo "║ marimo release script ║"
echo "╚════════════════════════════════════╝"
echo -e "${NC}"
# Check if version type is provided
if [ -z "$1" ]; then
echo -e "\nAvailable version types:"
# echo " - major (x.0.0)"
echo " - minor (0.x.0)"
echo " - patch (0.0.x)"
print_error "Please specify version type: ./release.sh <minor|patch>"
exit 1
fi
VERSION_TYPE=$1
# Validate version type
if [[ ! "$VERSION_TYPE" =~ ^(minor|patch)$ ]]; then
print_error "Invalid version type. Use: minor or patch"
exit 1
fi
# Check gh CLI is available
if ! command -v gh &> /dev/null; then
print_error "gh CLI is required but not installed. See https://cli.github.com/"
exit 1
fi
# Check if on main branch
print_step "Checking git branch"
BRANCH=$(git branch --show-current)
if [ "$BRANCH" != "main" ]; then
print_error "Not on main branch. Current branch: $BRANCH"
echo "Please run: git checkout main"
exit 1
fi
# Check git state
print_step "Checking git status"
if [ -n "$(git status --porcelain)" ]; then
print_error "Git working directory is not clean"
echo "Please commit or stash your changes first:"
git status
exit 1
fi
# Pull latest changes
print_step "Pulling latest changes"
git pull origin main
# Run uv version
print_step "Updating version"
echo -e "Running: uv version --bump $VERSION_TYPE\n"
uv version --bump $VERSION_TYPE
NEW_VERSION=$(NO_COLOR=1 uv version --short) # re-run to get the version
# Summary and confirmation
echo -e "\n${BOLD}Release Summary:${NC}"
echo " • New Version: $NEW_VERSION"
echo " • A PR will be created: release/$NEW_VERSION -> main"
echo " • After merge, a tag will be created automatically"
if ! confirm "Proceed with release?"; then
print_warning "Release cancelled"
git checkout pyproject.toml
exit 1
fi
# Create release branch and commit
RELEASE_BRANCH="release/$NEW_VERSION"
print_step "Creating release branch: $RELEASE_BRANCH"
git checkout -b "$RELEASE_BRANCH"
git add pyproject.toml
git commit -m "release: $NEW_VERSION"
# Push branch and create PR
print_step "Pushing branch and creating PR"
git push origin "$RELEASE_BRANCH"
PR_URL=$(gh pr create \
--title "release: $NEW_VERSION" \
--label "internal" \
--body "$(cat <<EOF
## Release $NEW_VERSION
Bumps version to \`$NEW_VERSION\` ($VERSION_TYPE release).
### After merge
1. Push to \`main\` triggers a **dev release** (pre-release to PyPI)
2. The \`release-tag\` workflow detects this merged release PR and creates tag \`$NEW_VERSION\`
3. Tag push triggers the **production release** (publish to PyPI, Docker, etc.)
### Checklist
- [ ] CI passes
- [ ] Version in \`pyproject.toml\` is correct (\`$NEW_VERSION\`)
EOF
)")
# Switch back to main
git checkout main
# Final success message
echo -e "\n${BOLD}${GREEN}Release PR created successfully!${NC}\n"
echo -e " PR: $PR_URL"
echo -e "\n${YELLOW}Next steps:${NC}"
echo " 1. Get the PR reviewed and merged"
echo " 2. After merge, the tag will be created automatically"
echo " 3. Monitor the release: https://github.com/marimo-team/marimo/actions/workflows/release.yml"