Repository navigation
Expand file tree
/
Copy pathprepare-release.sh
More file actions
executable file
·184 lines (157 loc) · 5.38 KB
/
Copy pathprepare-release.sh
File metadata and controls
executable file
·184 lines (157 loc) · 5.38 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
#!/bin/bash
# Script to prepare release files for GitHub release
# This script verifies xcframework zip files and their checksums
set -e
RELEASE_DIR="./dist/release"
RELEASE_VERSION="${1:-0.40.0-av}"
echo "=========================================="
echo "Preparing Release: $RELEASE_VERSION"
echo "=========================================="
echo ""
# Check if release directory exists
if [ ! -d "$RELEASE_DIR" ]; then
echo "❌ Error: Release directory not found: $RELEASE_DIR"
echo " Run 'make build version=$RELEASE_VERSION' first"
exit 1
fi
cd "$RELEASE_DIR"
echo "📦 Checking xcframework zip files..."
echo ""
# Find all xcframework zip files
ZIP_FILES=($(find . -name "*.xcframework.zip" -type f | sort))
if [ ${#ZIP_FILES[@]} -eq 0 ]; then
echo "⚠️ Warning: No xcframework.zip files found in $RELEASE_DIR"
echo " The build may not have completed yet."
exit 1
fi
echo "Found ${#ZIP_FILES[@]} xcframework zip files:"
echo ""
# Arrays to track results
VALID_FILES=()
INVALID_FILES=()
MISSING_CHECKSUMS=()
# Process each zip file
for zip_file in "${ZIP_FILES[@]}"; do
zip_name=$(basename "$zip_file")
framework_name="${zip_name%.xcframework.zip}"
checksum_file="${framework_name}.xcframework.checksum.txt"
echo " 📄 $zip_name"
# Check if zip file is valid
if ! unzip -tq "$zip_file" > /dev/null 2>&1; then
echo " ❌ Invalid zip file!"
INVALID_FILES+=("$zip_file")
continue
fi
# Compute checksum
if command -v swift > /dev/null 2>&1; then
computed_checksum=$(swift package compute-checksum "$zip_file" 2>/dev/null | tr -d '[:space:]')
if [ -f "$checksum_file" ]; then
stored_checksum=$(cat "$checksum_file" | tr -d '[:space:]')
if [ "$computed_checksum" == "$stored_checksum" ]; then
echo " ✅ Checksum verified: $computed_checksum"
VALID_FILES+=("$zip_file")
else
echo " ⚠️ Checksum mismatch!"
echo " Stored: $stored_checksum"
echo " Computed: $computed_checksum"
echo " 🔄 Updating checksum file..."
echo "$computed_checksum" > "$checksum_file"
VALID_FILES+=("$zip_file")
fi
else
echo " ⚠️ Missing checksum file, creating..."
echo "$computed_checksum" > "$checksum_file"
echo " ✅ Checksum: $computed_checksum"
VALID_FILES+=("$zip_file")
fi
else
echo " ⚠️ Swift not found, skipping checksum verification"
if [ ! -f "$checksum_file" ]; then
MISSING_CHECKSUMS+=("$zip_file")
fi
VALID_FILES+=("$zip_file")
fi
# Show file size
file_size=$(du -h "$zip_file" | cut -f1)
echo " 📊 Size: $file_size"
echo ""
done
echo "=========================================="
echo "Summary"
echo "=========================================="
echo ""
echo "✅ Valid files: ${#VALID_FILES[@]}"
if [ ${#INVALID_FILES[@]} -gt 0 ]; then
echo "❌ Invalid files: ${#INVALID_FILES[@]}"
for file in "${INVALID_FILES[@]}"; do
echo " - $file"
done
fi
if [ ${#MISSING_CHECKSUMS[@]} -gt 0 ]; then
echo "⚠️ Missing checksums: ${#MISSING_CHECKSUMS[@]}"
for file in "${MISSING_CHECKSUMS[@]}"; do
echo " - $file"
done
fi
echo ""
# List all files that will be uploaded
echo "=========================================="
echo "Files ready for release upload:"
echo "=========================================="
echo ""
# List zip files
echo "📦 xcframework zip files:"
for zip_file in "${ZIP_FILES[@]}"; do
echo " - $(basename "$zip_file")"
done
echo ""
# List checksum files
CHECKSUM_FILES=($(find . -name "*.xcframework.checksum.txt" -type f | sort))
if [ ${#CHECKSUM_FILES[@]} -gt 0 ]; then
echo "🔐 Checksum files:"
for checksum_file in "${CHECKSUM_FILES[@]}"; do
echo " - $(basename "$checksum_file")"
done
echo ""
fi
# List other files (like Package.swift, -all.zip files, etc.)
OTHER_FILES=($(find . -type f \( -name "*.txt" -o -name "Package.swift" -o -name "*-all.zip" \) ! -name "*.checksum.txt" | sort))
if [ ${#OTHER_FILES[@]} -gt 0 ]; then
echo "📄 Other release files:"
for other_file in "${OTHER_FILES[@]}"; do
echo " - $(basename "$other_file")"
done
echo ""
fi
# Total size
TOTAL_SIZE=$(du -sh . | cut -f1)
echo "📊 Total release size: $TOTAL_SIZE"
echo ""
# Create a file list for GitHub release
FILE_LIST="release-files-${RELEASE_VERSION}.txt"
{
echo "Release files for $RELEASE_VERSION"
echo "Generated: $(date)"
echo ""
echo "=== xcframework zip files ==="
for zip_file in "${ZIP_FILES[@]}"; do
echo "$(basename "$zip_file")"
done
echo ""
echo "=== checksum files ==="
for checksum_file in "${CHECKSUM_FILES[@]}"; do
echo "$(basename "$checksum_file")"
done
} > "$FILE_LIST"
echo "✅ File list saved to: $FILE_LIST"
echo ""
echo "=========================================="
echo "Ready for GitHub release!"
echo "=========================================="
echo ""
echo "To create the release, run:"
echo " gh release create $RELEASE_VERSION \\"
echo " --title \"$RELEASE_VERSION\" \\"
echo " --notes \"Release $RELEASE_VERSION\" \\"
echo " ./dist/release/*.zip ./dist/release/*.txt"
echo ""