-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake_release.sh
More file actions
executable file
·262 lines (224 loc) · 9.53 KB
/
make_release.sh
File metadata and controls
executable file
·262 lines (224 loc) · 9.53 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
#!/bin/bash
set -e
# Configuration
NEW_VERSION="${1:-0.0.4}"
CODE_SIGN_IDENTITY="${2}"
GITHUB_TOKEN="${3}"
if [[ -z "$CODE_SIGN_IDENTITY" ]]; then
echo "❌ Error: Code signing identity is required"
echo "Usage: $0 <version> <code_sign_identity> [github_token]"
echo "Example: $0 0.0.4 \"Developer ID Application: Your Name (TEAM_ID)\" ghp_xxxxx"
exit 1
fi
if [[ -z "$GITHUB_TOKEN" ]]; then
echo ""
echo "⚠️ GitHub token not found in environment or arguments"
echo ""
read -p "Enter GitHub token (or press Enter to skip GitHub release): " INPUT_TOKEN
if [[ -n "$INPUT_TOKEN" ]]; then
GITHUB_TOKEN="$INPUT_TOKEN"
echo "✅ GitHub token provided"
else
echo ""
echo "⚠️ WARNING: Proceeding without GitHub token"
echo " - Git tag will be created and pushed"
echo " - GitHub release will NOT be created automatically"
echo " - DMG will NOT be uploaded to GitHub"
echo ""
read -p "Continue without GitHub release? (y/N): " CONTINUE
if [[ "$CONTINUE" != "y" && "$CONTINUE" != "Y" ]]; then
echo "❌ Aborted by user"
exit 1
fi
fi
else
echo "✅ Using GitHub token from environment variable"
fi
echo ""
echo "🚀 Making release for OpenSuperMLX v${NEW_VERSION}"
echo " Code signing identity: ${CODE_SIGN_IDENTITY}"
if [[ -n "$GITHUB_TOKEN" ]]; then
echo " GitHub release: ✅ Enabled"
else
echo " GitHub release: ❌ Disabled (no token)"
fi
echo ""
# # Update version in Xcode project
echo "📝 Updating version to ${NEW_VERSION} in Xcode project..."
# Update MARKETING_VERSION in project.pbxproj
sed -i '' "s/MARKETING_VERSION = [^;]*/MARKETING_VERSION = ${NEW_VERSION}/g" OpenSuperMLX.xcodeproj/project.pbxproj
# Get current PROJECT_VERSION and increment by 1
CURRENT_PROJECT_VERSION=$(grep -o 'CURRENT_PROJECT_VERSION = [0-9]*' OpenSuperMLX.xcodeproj/project.pbxproj | head -1 | grep -o '[0-9]*')
NEW_PROJECT_VERSION=$((CURRENT_PROJECT_VERSION + 1))
sed -i '' "s/CURRENT_PROJECT_VERSION = [^;]*/CURRENT_PROJECT_VERSION = ${NEW_PROJECT_VERSION}/g" OpenSuperMLX.xcodeproj/project.pbxproj
echo "✅ Updated MARKETING_VERSION to ${NEW_VERSION} and CURRENT_PROJECT_VERSION to ${NEW_PROJECT_VERSION} (was ${CURRENT_PROJECT_VERSION})"
# Clean previous builds
echo "🧹 Cleaning previous builds..."
rm -rf build
rm -f OpenSuperMLX.dmg
rm -f OpenSuperMLX.dmg.sha256
rm -f OpenSuperMLX.app.dSYM.zip
# Use the existing notarize_app.sh script to build, sign, and notarize
echo "🔨 Building, signing and notarizing with notarize_app.sh..."
if [[ ! -f "./notarize_app.sh" ]]; then
echo "❌ notarize_app.sh not found!"
exit 1
fi
chmod +x ./notarize_app.sh
./notarize_app.sh "${CODE_SIGN_IDENTITY}"
if [[ $? -ne 0 ]]; then
echo "❌ Build/notarization failed!"
exit 1
fi
echo "✅ Build and notarization successful!"
DMG_PATH="./OpenSuperMLX.dmg"
# Verify DMG exists
if [[ ! -f "$DMG_PATH" ]]; then
echo "❌ DMG not found at $DMG_PATH"
exit 1
fi
# Find and prepare dSYM
DSYM_PATH="./build/Build/Products/Release/OpenSuperMLX.app.dSYM"
DSYM_ZIP_PATH="./OpenSuperMLX.app.dSYM.zip"
if [[ -d "$DSYM_PATH" ]]; then
echo "📦 Creating dSYM zip..."
cd $(dirname "$DSYM_PATH")
zip -r "$(basename "$DSYM_ZIP_PATH")" "$(basename "$DSYM_PATH")" > /dev/null
mv "$(basename "$DSYM_ZIP_PATH")" "$DSYM_ZIP_PATH"
cd - > /dev/null
echo "✅ dSYM zip created: $DSYM_ZIP_PATH"
else
echo "⚠️ dSYM not found at $DSYM_PATH - skipping dSYM upload"
DSYM_ZIP_PATH=""
fi
# # Generate SHA256
echo "🔍 Generating SHA256..."
shasum -a 256 "$DMG_PATH" > "${DMG_PATH}.sha256"
SHA256=$(cat "${DMG_PATH}.sha256" | cut -d' ' -f1)
echo "SHA256: $SHA256"
# # Commit version changes
echo "📝 Committing version changes..."
git add OpenSuperMLX.xcodeproj/project.pbxproj
git commit -m "Bump version to ${NEW_VERSION}" || echo "No changes to commit"
# Create git tag
echo "🏷️ Creating git tag..."
git tag -a "${NEW_VERSION}" -m "Release ${NEW_VERSION}"
# Push tag to origin
echo "📤 Pushing tag to origin..."
git push origin "${NEW_VERSION}"
if [[ $? -ne 0 ]]; then
echo "❌ Failed to push tag!"
exit 1
fi
# Create GitHub release and upload DMG if token is provided
if [[ -n "$GITHUB_TOKEN" ]]; then
echo "🚀 Creating GitHub release..."
# Create release
RELEASE_RESPONSE=$(curl -s -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/axot/OpenSuperMLX/releases \
-d '{
"tag_name": "'${NEW_VERSION}'",
"target_commitish": "master",
"name": "Release '${NEW_VERSION}'",
"body": "## OpenSuperMLX '${NEW_VERSION}'\n\nReal-time audio transcription for macOS using MLX.\n\n## Installation\n\n### Homebrew (Recommended)\n```bash\nbrew update\nbrew install opensupermlx\n```\n\n### Manual Installation\n1. Download the `OpenSuperMLX.dmg` file below\n2. Open the DMG and drag OpenSuperMLX to Applications\n3. Launch the app and grant necessary permissions\n\n## Requirements\n- macOS 14.0 (Sonoma) or later\n- Apple Silicon (ARM64) Mac",
"draft": false,
"prerelease": false,
"generate_release_notes": false
}')
# Extract release ID from response
RELEASE_ID=$(echo "$RELEASE_RESPONSE" | grep -o '"id": [0-9]*' | head -1 | grep -o '[0-9]*')
if [[ -z "$RELEASE_ID" ]]; then
echo "❌ Failed to create GitHub release or extract release ID"
echo "Response: $RELEASE_RESPONSE"
exit 1
fi
echo "✅ GitHub release created (ID: $RELEASE_ID)!"
echo "📤 Uploading DMG..."
# Upload DMG using the correct API format
UPLOAD_RESPONSE=$(curl -s -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/axot/OpenSuperMLX/releases/${RELEASE_ID}/assets?name=OpenSuperMLX.dmg" \
--data-binary @"${DMG_PATH}")
# Check if upload was successful
if [[ $(echo "$UPLOAD_RESPONSE" | grep -c '"state":"uploaded"') -gt 0 ]] || [[ $(echo "$UPLOAD_RESPONSE" | grep -c '"state": "uploaded"') -gt 0 ]]; then
echo "✅ DMG uploaded successfully!"
# Extract download URL
DOWNLOAD_URL=$(echo "$UPLOAD_RESPONSE" | grep -o '"browser_download_url":"[^"]*' | cut -d'"' -f4)
echo "📥 Download URL: $DOWNLOAD_URL"
elif [[ $(echo "$UPLOAD_RESPONSE" | grep -c '"message"') -gt 0 ]]; then
echo "❌ Failed to upload DMG"
echo "Error: $(echo "$UPLOAD_RESPONSE" | grep -o '"message":"[^"]*' | cut -d'"' -f4)"
exit 1
else
echo "⚠️ Upload response unclear, but no error detected"
echo "Response: $UPLOAD_RESPONSE"
fi
# Upload dSYM if available
if [[ -n "$DSYM_ZIP_PATH" && -f "$DSYM_ZIP_PATH" ]]; then
echo "📤 Uploading dSYM..."
DSYM_UPLOAD_RESPONSE=$(curl -s -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/zip" \
"https://uploads.github.com/repos/axot/OpenSuperMLX/releases/${RELEASE_ID}/assets?name=OpenSuperMLX.app.dSYM.zip" \
--data-binary @"${DSYM_ZIP_PATH}")
# Check dSYM upload
if [[ $(echo "$DSYM_UPLOAD_RESPONSE" | grep -c '"state":"uploaded"') -gt 0 ]] || [[ $(echo "$DSYM_UPLOAD_RESPONSE" | grep -c '"state": "uploaded"') -gt 0 ]]; then
echo "✅ dSYM uploaded successfully!"
# Extract download URL
DSYM_DOWNLOAD_URL=$(echo "$DSYM_UPLOAD_RESPONSE" | grep -o '"browser_download_url":"[^"]*' | cut -d'"' -f4)
echo "📥 dSYM Download URL: $DSYM_DOWNLOAD_URL"
elif [[ $(echo "$DSYM_UPLOAD_RESPONSE" | grep -c '"message"') -gt 0 ]]; then
echo "⚠️ Failed to upload dSYM (non-critical)"
echo "Error: $(echo "$DSYM_UPLOAD_RESPONSE" | grep -o '"message":"[^"]*' | cut -d'"' -f4)"
else
echo "⚠️ dSYM upload response unclear"
fi
fi
echo "✅ DMG uploaded successfully!"
echo "🎉 GitHub release is complete!"
echo "🔗 Release URL: https://github.com/axot/OpenSuperMLX/releases/tag/${NEW_VERSION}"
else
echo "⚠️ Skipping GitHub release creation (no token provided)"
echo "📋 Manual steps needed:"
echo "1. Create GitHub release at:"
echo " https://github.com/axot/OpenSuperMLX/releases/new?tag=${NEW_VERSION}"
echo "2. Upload the DMG file: OpenSuperMLX.dmg"
fi
echo ""
echo "🎉 Release ${NEW_VERSION} is ready!"
echo ""
echo "📁 Files created:"
echo " - OpenSuperMLX.dmg"
echo " - OpenSuperMLX.dmg.sha256"
if [[ -f "$DSYM_ZIP_PATH" ]]; then
echo " - OpenSuperMLX.app.dSYM.zip"
fi
echo ""
echo "🍺 Homebrew cask update:"
echo "-----"
cat << EOF
cask "opensupermlx" do
version "${NEW_VERSION}"
sha256 "${SHA256}"
url "https://github.com/axot/OpenSuperMLX/releases/download/#{version}/OpenSuperMLX.dmg"
name "OpenSuperMLX"
desc "MLX-based dictation/transcription app"
homepage "https://github.com/axot/OpenSuperMLX"
depends_on macos: ">= :sonoma"
depends_on arch: :arm64
app "OpenSuperMLX.app"
zap trash: [
"~/Library/Application Scripts/org.axot.OpenSuperMLX",
"~/Library/Application Support/org.axot.OpenSuperMLX",
]
end
EOF
echo "-----"