-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanual_release.sh
More file actions
264 lines (221 loc) · 9.24 KB
/
manual_release.sh
File metadata and controls
264 lines (221 loc) · 9.24 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
#!/bin/bash
# =============================================================================
# CampusVault Manual Release & GitHub Upload Script
#
# Usage: ./manual_release.sh
# This script builds the Android APK and uploads to GitHub using the GitHub CLI (gh).
# =============================================================================
set -e
# -----------------------------------------------------------------------------
# EDIT THESE VARIABLES FOR EACH RELEASE
# -----------------------------------------------------------------------------
VERSION="1.6.0" # Version string
VERSION_CODE=18 # Android version code
RELEASE_NOTES=$(cat <<'EOF'
## 🚀 What's New in v1.6.0
### ✨ Enhanced Document Management
- **🔄 Upgraded Document Picker**: Migrated to the latest @react-native-documents/picker for better compatibility and performance
- **👁️ Document Preview**: Added native document preview functionality - users can now preview files before uploading to verify content quality
- **🤖 Smart File Handling**: Improved support for virtual files (Google Docs, Sheets) with automatic conversion
- **⚡ Better Error Handling**: Enhanced error messages with proper error codes for clearer user feedback
### 🛠️ Technical Improvements
- **📱 Native Integration**: Better integration with device's native document viewers
- **🔍 File Type Validation**: Improved file type detection and validation
- **💾 Memory Optimization**: More efficient file handling and memory usage
- **🛡️ Enhanced Permissions**: Better Android 13+ permission handling
### 🎨 User Experience
- **👀 Preview Button**: Added eye icon button in file selection for quick document preview
- **📋 Quality Control**: Users can verify document readability before upload (especially useful for scanned PDFs)
- **💡 Smart Hints**: Added helpful hints about preview capabilities
- **🔄 Streamlined Flow**: Cleaner upload process with better visual feedback
### 🐛 Bug Fixes
- Fixed document picker cancellation handling
- Improved error messages for unsupported file types
- Better handling of permission-related errors
- Enhanced stability for large file uploads
### 📱 Compatibility
- Full Android 13+ support with improved file access permissions
- Enhanced iOS document viewing experience
- Better support for various file formats and virtual files
---
*Preview your documents, upload with confidence! 📄✨*
EOF
)
# Release notes for GitHub
# -----------------------------------------------------------------------------
# CONFIG
# -----------------------------------------------------------------------------
REPO="AstronDaniel/CampusVault"
APK_DIR="android/app/build/outputs/apk/release"
# -----------------------------------------------------------------------------
# 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"
}
# -----------------------------------------------------------------------------
# Pre-flight checks
# -----------------------------------------------------------------------------
echo ""
echo "=============================================="
echo " CampusVault Manual Release Script v2.0"
echo "=============================================="
echo ""
log_info "Starting release process for version v${VERSION} (code: ${VERSION_CODE})"
echo ""
# Check if we're in a git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
log_error "Not inside a git repository!"
exit 1
fi
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
log_error "GitHub CLI (gh) is not installed!"
log_info "Install it from: https://cli.github.com/"
exit 1
fi
# Check if gh is authenticated
if ! gh auth status &> /dev/null; then
log_error "GitHub CLI is not authenticated!"
log_info "Run: gh auth login"
exit 1
fi
# Check for uncommitted changes (excluding the files we're about to modify)
if ! git diff --quiet HEAD -- ':!package.json' ':!android/app/build.gradle'; then
log_warning "You have uncommitted changes. Please commit or stash them first."
git status --short
read -p "Do you want to continue anyway? (y/N): " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
log_info "Release cancelled."
exit 1
fi
fi
# Check if tag already exists
if git rev-parse "v${VERSION}" > /dev/null 2>&1; then
log_error "Tag v${VERSION} already exists! Please use a different version."
exit 1
fi
# -----------------------------------------------------------------------------
# Update package.json
# -----------------------------------------------------------------------------
log_info "Updating package.json version to ${VERSION}..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" package.json
else
# Linux/Git Bash on Windows
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" package.json
fi
if grep -q "\"version\": \"${VERSION}\"" package.json; then
log_success "package.json updated successfully"
else
log_error "Failed to update package.json"
exit 1
fi
# -----------------------------------------------------------------------------
# Update android/app/build.gradle
# -----------------------------------------------------------------------------
log_info "Updating android/app/build.gradle..."
GRADLE_FILE="android/app/build.gradle"
# Update versionCode and versionName
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/versionCode [0-9]*/versionCode ${VERSION_CODE}/" "$GRADLE_FILE"
sed -i '' "s/versionName \"[^\"]*\"/versionName \"${VERSION}\"/" "$GRADLE_FILE"
else
sed -i "s/versionCode [0-9]*/versionCode ${VERSION_CODE}/" "$GRADLE_FILE"
sed -i "s/versionName \"[^\"]*\"/versionName \"${VERSION}\"/" "$GRADLE_FILE"
fi
if grep -q "versionCode ${VERSION_CODE}" "$GRADLE_FILE" && grep -q "versionName \"${VERSION}\"" "$GRADLE_FILE"; then
log_success "build.gradle updated successfully"
else
log_error "Failed to update build.gradle"
exit 1
fi
# -----------------------------------------------------------------------------
# Show changes for confirmation
# -----------------------------------------------------------------------------
echo ""
log_info "Changes made:"
echo "----------------------------------------"
git --no-pager diff --color package.json android/app/build.gradle
echo "----------------------------------------"
echo ""
read -p "Do you want to proceed with building and releasing? (y/N): " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
log_warning "Rolling back changes..."
git checkout -- package.json android/app/build.gradle
log_info "Release cancelled."
exit 1
fi
# -----------------------------------------------------------------------------
# Commit version changes
# -----------------------------------------------------------------------------
log_info "Staging version changes..."
git add package.json android/app/build.gradle
log_info "Committing version changes..."
git commit -m "chore: bump version to v${VERSION}"
log_info "Pushing version commit..."
git push
# -----------------------------------------------------------------------------
# Build APKs
# -----------------------------------------------------------------------------
log_info "Building release APKs..."
cd android
./gradlew assembleRelease
cd ..
if [ ! -d "$APK_DIR" ]; then
log_error "APK directory not found: $APK_DIR"
exit 1
fi
APK_FILES=("$APK_DIR"/*.apk)
if [ ${#APK_FILES[@]} -eq 0 ]; then
log_error "No APKs found in $APK_DIR"
exit 1
fi
log_success "APKs built successfully:"
for apk in "${APK_FILES[@]}"; do
echo " - $(basename "$apk")"
done
echo ""
# -----------------------------------------------------------------------------
# Create Git tag
# -----------------------------------------------------------------------------
log_info "Creating tag v${VERSION}..."
git tag -a "v${VERSION}" -m "${RELEASE_NOTES}"
log_info "Pushing tag to remote..."
git push origin "v${VERSION}"
# -----------------------------------------------------------------------------
# Create GitHub release and upload APKs
# -----------------------------------------------------------------------------
log_info "Creating GitHub release and uploading APKs..."
gh release create "v${VERSION}" "${APK_FILES[@]}" \
--title "CampusVault v${VERSION}" \
--notes "${RELEASE_NOTES}" \
--repo "$REPO"
# -----------------------------------------------------------------------------
# Done!
# -----------------------------------------------------------------------------
echo ""
echo "=============================================="
log_success "Release v${VERSION} completed successfully!"
echo "=============================================="
echo ""
log_info "Release URL: https://github.com/${REPO}/releases/tag/v${VERSION}"
echo ""