-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·310 lines (253 loc) · 9.77 KB
/
release.sh
File metadata and controls
executable file
·310 lines (253 loc) · 9.77 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#!/bin/bash
# Automated release script for Go-OPML
# This script handles the complete release process including building binaries for all platforms
set -e # Exit on any error
echo "🚀 Go-OPML Automated Release Script"
echo "===================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Helper functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "go.mod" ] || [ ! -d "cmd/go-opml" ]; then
log_error "This script must be run from the Go-OPML project root directory"
exit 1
fi
# Get current git status
CURRENT_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.2")
BRANCH=$(git branch --show-current)
log_info "Current branch: $BRANCH"
log_info "Latest tag: $LATEST_TAG"
# Determine next version
if [ "$LATEST_TAG" = "v1.0.2" ]; then
NEXT_VERSION="v1.0.3"
elif [ "$LATEST_TAG" = "v1.0.3" ]; then
NEXT_VERSION="v1.1.0" # Minor version bump for infrastructure improvements
else
# Extract version numbers and increment patch
VERSION_NUMBER=$(echo $LATEST_TAG | sed 's/v//')
IFS='.' read -r major minor patch <<< "$VERSION_NUMBER"
NEXT_VERSION="v$major.$minor.$((patch + 1))"
fi
echo ""
log_info "Next version will be: $NEXT_VERSION"
echo ""
# Ask for confirmation
read -p "Do you want to proceed with release $NEXT_VERSION? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
log_warning "Release cancelled by user"
exit 0
fi
echo ""
log_info "Starting release process for $NEXT_VERSION..."
echo ""
# Step 1: Clean workspace
log_info "1. Cleaning workspace..."
rm -rf build/
rm -f coverage.out coverage.html
mkdir -p build/
# Step 2: Check dependencies
log_info "2. Checking dependencies..."
go mod tidy
go mod verify
# Step 2.5: Run linting (optional but recommended)
log_info "2.5. Running code quality checks..."
# Check if golangci-lint is available, try multiple locations
GOLANGCI_LINT=""
if command -v golangci-lint &> /dev/null; then
GOLANGCI_LINT="golangci-lint"
elif [ -f "$(go env GOPATH)/bin/golangci-lint" ]; then
GOLANGCI_LINT="$(go env GOPATH)/bin/golangci-lint"
elif [ -f "$HOME/go/bin/golangci-lint" ]; then
GOLANGCI_LINT="$HOME/go/bin/golangci-lint"
fi
if [ -n "$GOLANGCI_LINT" ]; then
log_info " Running golangci-lint..."
$GOLANGCI_LINT run --timeout=5m || log_warning "Linting issues found - please review"
else
log_warning "golangci-lint not found - installing..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Try again after installation
if [ -f "$(go env GOPATH)/bin/golangci-lint" ]; then
log_info " Running golangci-lint..."
"$(go env GOPATH)/bin/golangci-lint" run --timeout=5m || log_warning "Linting issues found - please review"
elif [ -f "$HOME/go/bin/golangci-lint" ]; then
log_info " Running golangci-lint..."
"$HOME/go/bin/golangci-lint" run --timeout=5m || log_warning "Linting issues found - please review"
else
log_warning "Failed to install golangci-lint - skipping linting"
fi
fi
# Step 3: Check for dependency updates
log_info "3. Checking for dependency updates..."
UPDATES=$(go list -u -m all | grep '\[.*\]' | wc -l)
if [ $UPDATES -gt 0 ]; then
log_warning "$UPDATES dependency updates available (will be noted in changelog)"
go list -u -m all | grep '\[.*\]' | head -5
else
log_success "All dependencies are up to date"
fi
# Step 4: Build binaries for all platforms
log_info "4. Building binaries for all platforms..."
# Build flags for optimization (corrected syntax)
BUILD_FLAGS="-ldflags=-s -w"
# Linux 64-bit
log_info " Building for Linux 64-bit..."
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o build/Go-OPML-linux cmd/go-opml/main.go
# Windows 64-bit
log_info " Building for Windows 64-bit..."
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o build/Go-OPML.exe cmd/go-opml/main.go
# macOS Intel 64-bit
log_info " Building for macOS Intel..."
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o build/Go-OPML-mac-intel cmd/go-opml/main.go
# macOS Apple Silicon (ARM64)
log_info " Building for macOS Apple Silicon..."
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o build/Go-OPML-mac-arm64 cmd/go-opml/main.go
# Build for current platform (for testing)
log_info " Building for current platform..."
go build -ldflags="-s -w" -o build/Go-OPML cmd/go-opml/main.go
log_success "All binaries built successfully!"
echo ""
log_info "📦 Built binaries:"
ls -la build/
echo ""
# Step 5: Test the binary
log_info "5. Testing the built binary..."
if [ -f "examples/sample.opml" ]; then
if ./build/Go-OPML -input examples/sample.opml -output test-output.json 2>/dev/null; then
log_success "Binary test successful!"
rm -f test-output.json
else
log_error "Binary test failed!"
exit 1
fi
else
log_warning "No sample.opml found, skipping binary test"
fi
# Step 6: Calculate binary sizes and checksums
log_info "6. Generating checksums..."
cd build
sha256sum * > checksums.txt
cd ..
log_success "Checksums generated in build/checksums.txt"
# Step 7: Update README with new version (if needed)
log_info "7. Updating README version references..."
if grep -q "v1.0.3 (Ready)" README.md; then
sed -i "s/v1.0.3 (Ready)/$NEXT_VERSION (Released)/g" README.md
log_success "README updated with new version"
fi
# Step 8: Commit changes
log_info "8. Committing changes..."
git add .
git commit -m "Release $NEXT_VERSION: Infrastructure improvements and code quality enhancements
- Added comprehensive CI/CD pipeline with GitHub Actions
- Implemented automated testing across multiple Go versions
- Added golangci-lint configuration for code quality
- Created missing pkg/rss package with RSS fetching functionality
- Added GitHub issue templates and pull request template
- Implemented security policy and vulnerability reporting
- Fixed linting issues and improved code structure
- Enhanced project documentation and governance
Infrastructure:
- CI/CD: Automated testing, linting, and binary building
- Templates: Bug reports, feature requests, PR guidelines
- Security: Comprehensive security policy for v1.1.0
- Code Quality: Linting rules and automated checks"
# Step 9: Create and push tag
log_info "9. Creating and pushing tag $NEXT_VERSION..."
git tag $NEXT_VERSION
git push origin $BRANCH
git push origin $NEXT_VERSION
log_success "Tag $NEXT_VERSION created and pushed!"
# Step 10: Create release notes
log_info "10. Generating release notes..."
cat > release-notes.md << EOF
# Go-OPML $NEXT_VERSION
## 🚀 What's New
- **Enhanced Build Pipeline**: Automated release script with intelligent version detection
- **Dependency Updates**: Updated dependencies for better security and performance
- **Sample File Fix**: Removed broken RSS feed from sample.opml
- **Modernized Website**: Improved UX, modern design, and better documentation
- **Cross-Platform Binaries**: Native binaries for all major platforms
## 📦 Available Downloads
### Windows
- **Go-OPML.exe** - Windows 64-bit
### macOS
- **Go-OPML-mac-intel** - macOS Intel 64-bit
- **Go-OPML-mac-arm64** - macOS Apple Silicon (M1/M2)
### Linux
- **Go-OPML-linux** - Linux 64-bit
## 🔧 Quick Start
1. Download the appropriate binary for your platform
2. Make it executable: \`chmod +x Go-OPML-*\`
3. Run: \`./Go-OPML-* -input your_file.opml -output result.json\`
## 📋 Checksums
SHA256 checksums are provided in \`checksums.txt\` for verification.
## 🔗 Links
- **Documentation**: [go-opml.madi.se](https://go-opml.madi.se)
- **Go Package**: [pkg.go.dev/github.com/jadmadi/Go-OPML](https://pkg.go.dev/github.com/jadmadi/Go-OPML)
- **Source Code**: [github.com/jadmadi/Go-OPML](https://github.com/jadmadi/Go-OPML)
---
**Full Changelog**: https://github.com/jadmadi/Go-OPML/compare/$LATEST_TAG...$NEXT_VERSION
EOF
log_success "Release notes generated in release-notes.md"
# Step 11: Instructions for GitHub release
echo ""
log_success "🎉 Release $NEXT_VERSION is ready!"
echo ""
log_info "📋 Next steps to complete the GitHub release:"
echo ""
echo "1. Go to: https://github.com/jadmadi/Go-OPML/releases/new"
echo "2. Choose tag: $NEXT_VERSION"
echo "3. Release title: Go-OPML $NEXT_VERSION"
echo "4. Copy content from release-notes.md as description"
echo "5. Upload binaries by dragging files from build/ directory:"
echo " 📁 build/Go-OPML.exe (Windows 64-bit)"
echo " 📁 build/Go-OPML-mac-intel (macOS Intel)"
echo " 📁 build/Go-OPML-mac-arm64 (macOS Apple Silicon)"
echo " 📁 build/Go-OPML-linux (Linux 64-bit)"
echo " 📁 build/checksums.txt (SHA256 checksums)"
echo "6. Click 'Publish release'"
echo ""
echo "💡 Tip: You can drag and drop all files at once into the GitHub release page"
echo ""
# Show file sizes and checksums for reference
echo "📊 Files ready for upload:"
ls -lah build/
echo ""
echo "📋 SHA256 Checksums:"
cat build/checksums.txt
echo ""
log_success "Automated release process completed successfully! 🚀"
log_warning "📤 Don't forget to upload the binaries to complete the GitHub release."
# Optional: Open GitHub releases page
if command -v xdg-open &> /dev/null; then
read -p "Open GitHub releases page in browser? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
xdg-open "https://github.com/jadmadi/Go-OPML/releases/new?tag=$NEXT_VERSION"
fi
elif command -v open &> /dev/null; then
read -p "Open GitHub releases page in browser? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
open "https://github.com/jadmadi/Go-OPML/releases/new?tag=$NEXT_VERSION"
fi
fi