-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.sh
More file actions
201 lines (167 loc) · 5.49 KB
/
Copy pathrelease.sh
File metadata and controls
201 lines (167 loc) · 5.49 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# CFD Framework Release Management Script
# Usage: ./release.sh [version] [--check|--help]
set -e
VERSION_FILE="VERSION"
CURRENT_VERSION=$(cat "$VERSION_FILE" 2>/dev/null || echo "0.0.0")
show_help() {
cat << EOF
CFD Framework Release Management
USAGE:
./release.sh <version> Create a new release
./release.sh --check Check current version and status
./release.sh --help Show this help
EXAMPLES:
./release.sh 1.2.0 Create version 1.2.0
./release.sh 1.1.5 Create version 1.1.5
./release.sh --check Show current status
VERSION FORMAT:
Use semantic versioning: MAJOR.MINOR.PATCH
- MAJOR: Breaking changes
- MINOR: New features, backward compatible
- PATCH: Bug fixes, backward compatible
RELEASE PROCESS:
1. Update VERSION file with new version
2. Commit and push changes
3. GitHub Actions will automatically:
- Run tests on all platforms
- Create git tag
- Build release artifacts
- Create GitHub release
CURRENT VERSION: $CURRENT_VERSION
EOF
}
check_status() {
echo "=== CFD Framework Release Status ==="
echo "Current version: $CURRENT_VERSION"
echo "VERSION file: $VERSION_FILE"
echo ""
# Check if we're on a clean branch
if ! git diff --quiet; then
echo "❌ Working directory has uncommitted changes"
git status --short
echo ""
else
echo "✅ Working directory is clean"
fi
# Check current branch
current_branch=$(git branch --show-current)
echo "Current branch: $current_branch"
# Check if current version has a tag
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
echo "✅ Tag v$CURRENT_VERSION exists"
tag_commit=$(git rev-list -n 1 "v$CURRENT_VERSION")
head_commit=$(git rev-parse HEAD)
if [ "$tag_commit" = "$head_commit" ]; then
echo "✅ Current commit matches tag"
else
echo "⚠️ Current commit differs from tag"
fi
else
echo "❌ Tag v$CURRENT_VERSION does not exist"
fi
# Check recent tags
echo ""
echo "Recent tags:"
git tag --sort=-version:refname | head -5 || echo "No tags found"
}
validate_version() {
local version="$1"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Invalid version format: $version"
echo "Please use semantic versioning format: MAJOR.MINOR.PATCH (e.g., 1.2.3)"
exit 1
fi
}
compare_versions() {
local current="$1"
local new="$2"
# Split versions into components
IFS='.' read -ra CURR <<< "$current"
IFS='.' read -ra NEW <<< "$new"
# Compare major.minor.patch
for i in 0 1 2; do
curr_part=${CURR[$i]:-0}
new_part=${NEW[$i]:-0}
if (( new_part > curr_part )); then
return 0 # New version is greater
elif (( new_part < curr_part )); then
return 1 # New version is less
fi
done
return 1 # Versions are equal
}
create_release() {
local new_version="$1"
validate_version "$new_version"
# Check if new version is greater than current
if ! compare_versions "$CURRENT_VERSION" "$new_version"; then
echo "❌ New version $new_version must be greater than current version $CURRENT_VERSION"
exit 1
fi
# Check if tag already exists
if git rev-parse "v$new_version" >/dev/null 2>&1; then
echo "❌ Tag v$new_version already exists"
exit 1
fi
# Check if working directory is clean
if ! git diff --quiet; then
echo "❌ Working directory has uncommitted changes. Please commit or stash them first."
exit 1
fi
# Check if we're on main/master branch
current_branch=$(git branch --show-current)
if [[ "$current_branch" != "main" && "$current_branch" != "master" ]]; then
echo "⚠️ Warning: You're on branch '$current_branch', not main/master"
read -p "Continue anyway? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted"
exit 1
fi
fi
echo "=== Creating Release v$new_version ==="
echo "Current version: $CURRENT_VERSION"
echo "New version: $new_version"
echo ""
# Update VERSION file
echo "$new_version" > "$VERSION_FILE"
echo "✅ Updated $VERSION_FILE"
# Add and commit the version change
git add "$VERSION_FILE"
git commit -m "Release v$new_version
- Update VERSION file to $new_version
- This will trigger automatic tag creation and release build
🤖 Generated with [Claude Code](https://claude.ai/code)"
echo "✅ Committed version update"
# Push the change
echo "Pushing to origin..."
git push origin "$current_branch"
echo ""
echo "🚀 Release initiated!"
echo ""
echo "Next steps:"
echo "1. GitHub Actions will run tests on all platforms"
echo "2. If tests pass, tag v$new_version will be created automatically"
echo "3. Release artifacts will be built and published"
echo ""
echo "Monitor progress at:"
echo "https://github.com/$(git config --get remote.origin.url | sed 's/.*github.com[:/]\([^.]*\).*/\1/')/actions"
}
# Main script logic
case "${1:-}" in
--help|-h)
show_help
;;
--check|-c)
check_status
;;
"")
echo "❌ No version specified"
echo "Use --help for usage information"
exit 1
;;
*)
create_release "$1"
;;
esac