Skip to content

Commit 2e313f5

Browse files
committed
refactor: simplify build scripts and fix quality issues
1 parent 70f4f9f commit 2e313f5

5 files changed

Lines changed: 26 additions & 38 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ jobs:
6262
# Link packages with --force and --overwrite (needed for keg-only formulas)
6363
brew link --force --overwrite mariadb-connector-c 2>/dev/null || true
6464
65-
# Verify installations
66-
if ! brew list mariadb-connector-c >/dev/null 2>&1; then
67-
echo "❌ ERROR: mariadb-connector-c installation failed"
68-
exit 1
69-
fi
70-
7165
echo "✅ ARM64 dependencies installed"
7266
7367
- name: Prepare libraries
@@ -183,12 +177,6 @@ jobs:
183177
# Link packages with --force (needed for keg-only formulas)
184178
arch -x86_64 /usr/local/bin/brew link --force --overwrite mariadb-connector-c 2>/dev/null || true
185179
186-
# Verify installations
187-
if ! arch -x86_64 /usr/local/bin/brew list mariadb-connector-c >/dev/null 2>&1; then
188-
echo "❌ ERROR: mariadb-connector-c installation failed"
189-
exit 1
190-
fi
191-
192180
echo "✅ x86_64 dependencies installed"
193181
194182
- name: Prepare libraries

scripts/build-release.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
set -eo pipefail
2+
set -euo pipefail
33

44
# Build script for creating architecture-specific releases
55
# Usage: ./build-release.sh [arm64|x86_64|both]
@@ -264,8 +264,7 @@ bundle_dylibs() {
264264
# (e.g. strchrnul) that don't exist on earlier OS versions → launch crash.
265265
echo " Verifying deployment target compatibility..."
266266
local deploy_target
267-
deploy_target=$(xcodebuild -project "$PROJECT" -scheme "$SCHEME" -showBuildSettings 2>/dev/null \
268-
| grep -m 1 'MACOSX_DEPLOYMENT_TARGET' | awk '{print $3}')
267+
deploy_target=$(echo "$build_settings" | grep -m 1 'MACOSX_DEPLOYMENT_TARGET' | awk '{print $3}')
269268
if [ -n "$deploy_target" ]; then
270269
local deploy_major
271270
deploy_major=$(echo "$deploy_target" | cut -d. -f1)
@@ -301,13 +300,6 @@ bundle_dylibs() {
301300
echo " ⚠️ WARNING: Could not determine deployment target, skipping dylib version check"
302301
fi
303302

304-
# Sign bundled dylibs (will be re-signed with proper identity later)
305-
echo " Signing bundled libraries (preliminary)..."
306-
for fw in "$frameworks_dir"/*.dylib; do
307-
[ -f "$fw" ] || continue
308-
codesign -fs - --force "$fw" 2>/dev/null || true
309-
done
310-
311303
echo "✅ Bundled $count dynamic libraries into Frameworks/"
312304
ls -lh "$frameworks_dir"/*.dylib 2>/dev/null
313305
}
@@ -317,6 +309,9 @@ build_for_arch() {
317309
echo ""
318310
echo "🔨 Building for $arch..."
319311

312+
# Fetch build settings once for this arch (used by build_for_arch and bundle_dylibs)
313+
build_settings=$(xcodebuild -project "$PROJECT" -scheme "$SCHEME" -configuration "$CONFIG" -arch "$arch" -showBuildSettings 2>&1)
314+
320315
# Prepare architecture-specific libraries
321316
prepare_mariadb "$arch"
322317
prepare_libpq "$arch"
@@ -358,7 +353,7 @@ build_for_arch() {
358353
echo "✅ Build succeeded for $arch"
359354

360355
# Get binary path with validation
361-
DERIVED_DATA=$(xcodebuild -project "$PROJECT" -scheme "$SCHEME" -showBuildSettings 2>&1 | grep -m 1 "BUILD_DIR" | awk '{print $3}')
356+
DERIVED_DATA=$(echo "$build_settings" | grep -m 1 "BUILD_DIR" | awk '{print $3}')
362357

363358
if [ -z "$DERIVED_DATA" ]; then
364359
echo "❌ FATAL: Failed to determine build directory from xcodebuild settings"
@@ -500,11 +495,18 @@ build_for_arch() {
500495
codesign -fs "$SIGN_IDENTITY" --force --options runtime --timestamp "$dylib"
501496
done
502497

503-
# Sign plugin bundles (stripped binaries need re-signing)
498+
# Sign plugin bundles (stripped binaries need re-signing, preserve entitlements)
504499
if [ -d "$PLUGINS_DIR" ]; then
505500
for plugin in "$PLUGINS_DIR"/*.tableplugin; do
506501
[ -d "$plugin" ] || continue
507-
codesign -fs "$SIGN_IDENTITY" --force --options runtime --timestamp "$plugin"
502+
local ent_file="/tmp/plugin_entitlements_$$.plist"
503+
codesign -d --entitlements - "$plugin" > "$ent_file" 2>/dev/null || true
504+
if [ -s "$ent_file" ]; then
505+
codesign -fs "$SIGN_IDENTITY" --force --options runtime --timestamp --entitlements "$ent_file" "$plugin"
506+
else
507+
codesign -fs "$SIGN_IDENTITY" --force --options runtime --timestamp "$plugin"
508+
fi
509+
rm -f "$ent_file"
508510
done
509511
fi
510512

scripts/ci/package-artifacts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if [[ "$ARCH" != "arm64" && "$ARCH" != "x86_64" ]]; then
99
exit 1
1010
fi
1111

12-
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.1.13")
12+
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//') || { echo "❌ ERROR: Cannot determine version from git tags"; exit 1; }
1313

1414
# --- Create DMG ---
1515
echo "Creating DMG installer..."

scripts/ci/prepare-libs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010

1111
# Prepare libmariadb
1212
echo "📦 Preparing libmariadb.a for $ARCH..."
13-
cp Libs/libmariadb_${ARCH}.a Libs/libmariadb.a
13+
cp "Libs/libmariadb_${ARCH}.a" "Libs/libmariadb.a"
1414
echo "✅ libmariadb.a ready"
1515
lipo -info Libs/libmariadb.a
1616
ls -lh Libs/libmariadb.a

scripts/ci/sign-and-appcast.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,21 @@ INFO_PLIST=$(find "$TEMP_DIR" -maxdepth 3 -path "*/Contents/Info.plist" | head -
3838
if [ -n "$INFO_PLIST" ] && [ -f "$INFO_PLIST" ]; then
3939
BUILD_NUMBER=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$INFO_PLIST" 2>/dev/null || echo "1")
4040
SHORT_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$INFO_PLIST" 2>/dev/null || echo "$VERSION")
41-
MIN_OS=$(/usr/libexec/PlistBuddy -c "Print :LSMinimumSystemVersion" "$INFO_PLIST" 2>/dev/null || echo "13.5")
41+
MIN_OS=$(/usr/libexec/PlistBuddy -c "Print :LSMinimumSystemVersion" "$INFO_PLIST" 2>/dev/null || echo "14.0")
4242
else
4343
echo "⚠️ Could not find app Info.plist in ZIP, using defaults from tag"
4444
BUILD_NUMBER="1"
4545
SHORT_VERSION="$VERSION"
46-
MIN_OS="13.5"
46+
MIN_OS="14.0"
4747
fi
4848
rm -rf "$TEMP_DIR"
4949

50-
# Extract release notes from CHANGELOG.md and convert to HTML for appcast
51-
NOTES=$(awk -v ver="$VERSION" '
52-
/^## \[/ {
53-
if (found) exit
54-
if ($0 ~ "\\[" ver "\\]") { found=1; next }
55-
}
56-
found { print }
57-
' CHANGELOG.md)
50+
# Extract release notes for appcast
51+
if [ -f release_notes.md ]; then
52+
NOTES=$(cat release_notes.md)
53+
else
54+
NOTES=$(awk "/^## \\[${VERSION}\\]/{flag=1; next} /^## \\[/{flag=0} flag" CHANGELOG.md)
55+
fi
5856

5957
if [ -z "$NOTES" ]; then
6058
RELEASE_HTML="<li>Bug fixes and improvements</li>"
@@ -84,7 +82,7 @@ fi
8482
DESCRIPTION_HTML="<body style=\"font-family: -apple-system, sans-serif; font-size: 13px; padding: 8px;\">${RELEASE_HTML}</body>"
8583

8684
# Build appcast.xml with architecture-specific items (Sparkle 2 convention)
87-
DOWNLOAD_PREFIX="https://github.com/datlechin/TablePro/releases/download/v${VERSION}"
85+
DOWNLOAD_PREFIX="${GITHUB_SERVER_URL:-https://github.com}/${GITHUB_REPOSITORY:-datlechin/TablePro}/releases/download/v${VERSION}"
8886
PUB_DATE=$(date -u '+%a, %d %b %Y %H:%M:%S +0000')
8987

9088
mkdir -p appcast

0 commit comments

Comments
 (0)