Skip to content

Commit f3e1b6e

Browse files
Release optimization (#21)
* Implement --clean option in build.sh Add clean build option to build script Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Update APP_PATH to use a specific build directory Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Fix missing xcodebuild parallelization flag Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Set architecture flags based on configuration Added architecture flags configuration for build process. Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Implement caching for Xcode DerivedData Add caching for Xcode DerivedData to improve build times. Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Add Sentry CLI caching in release workflow Add caching for Sentry CLI to optimize installation. Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Merge app zip creation with dSYM upload step Consolidate app zip creation and dSYM upload into a single step. Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Fix typos in release workflow script Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Optimize git clone for homebrew tap repository Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Add warning before amending last commit Added warning and confirmation prompt before amending the last commit. Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Fix typo in release workflow step name Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Fix condition check and update architecture flags Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Fix syntax for parallel command execution in release.yml Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Add confirmation before amending last commit Added confirmation prompt before amending last commit. Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Improve parallel execution handling in release workflow * Update .github/workflows/release.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Update .github/workflows/release.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Change ARCH_FLAGS to use array syntax Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> * Replace Sentry CLI caching with setup action Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> --------- Signed-off-by: Karan Mohindroo <96403086+NullPointerDepressiveDisorder@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 99719d8 commit f3e1b6e

4 files changed

Lines changed: 62 additions & 19 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ jobs:
110110
111111
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
112112
echo "Using version: ${VERSION}"
113+
114+
- name: Cache Swift Package Manager dependencies
115+
uses: actions/cache@v4
116+
with:
117+
path: |
118+
build/SourcePackages
119+
build/.build
120+
key: spm-${{ runner.os }}-${{ hashFiles('**/Package.resolved') }}
121+
restore-keys: |
122+
spm-${{ runner.os }}-
113123
114124
- name: Build Release
115125
run: |
@@ -123,26 +133,35 @@ jobs:
123133
OTHER_LDFLAGS="-F/System/Library/PrivateFrameworks -framework MultitouchSupport -framework CoreFoundation -framework CoreGraphics" \
124134
FRAMEWORK_SEARCH_PATHS="/System/Library/PrivateFrameworks" \
125135
build
126-
127-
- name: Create App Zip
128-
run: |
129-
cd build/Build/Products/Release
130-
zip -r MiddleDrag-${{ steps.version.outputs.VERSION }}.zip MiddleDrag.app
131-
mv MiddleDrag-${{ steps.version.outputs.VERSION }}.zip $GITHUB_WORKSPACE/
132136
133-
- name: Install Sentry CLI
134-
run: |
135-
curl -sL https://sentry.io/get-cli/ | bash
137+
- name: Setup Sentry CLI
138+
uses: mathieu-bour/setup-sentry-cli@v2
139+
with:
140+
version: latest
136141

137-
- name: Upload dSYM to Sentry
142+
- name: Create App Zip & Upload dSYM to Sentry
138143
env:
139144
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
140145
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
141146
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
142147
run: |
143-
sentry-cli debug-files upload \
144-
--include-sources \
145-
build/Build/Products/Release/
148+
# Run in parallel
149+
wait_all() {
150+
local failed=0
151+
for pid in "$@"; do
152+
wait "$pid" || failed=1
153+
done
154+
return $failed
155+
}
156+
157+
VERSION="${{ steps.version.outputs.VERSION }}"
158+
159+
(cd build/Build/Products/Release && zip -r "$GITHUB_WORKSPACE/MiddleDrag-${VERSION}.zip" MiddleDrag.app) &
160+
ZIP_PID=$!
161+
sentry-cli debug-files upload --include-sources build/Build/Products/Release/ &
162+
SENTRY_PID=$!
163+
164+
wait_all "$ZIP_PID" "$SENTRY_PID" || { echo "❌ A background job failed"; exit 1; }
146165
147166
- name: Create Sentry release
148167
env:

.github/workflows/update-homebrew.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ jobs:
5151
SHA=$(shasum -a 256 MiddleDrag.zip | awk '{print $1}')
5252
5353
# Clone tap repo and update
54-
git clone https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/nullpointerdepressivedisorder/homebrew-tap.git
54+
git clone --depth 1 --filter=blob:none --sparse \
55+
https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/nullpointerdepressivedisorder/homebrew-tap.git
5556
cd homebrew-tap
57+
git sparse-checkout set Casks
5658
5759
sed -i '' "s/version \".*\"/version \"${VERSION}\"/" Casks/middledrag.rb
5860
sed -i '' "s/sha256 \".*\"/sha256 \"${SHA}\"/" Casks/middledrag.rb

build.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ BUNDLE_ID="com.middledrag.MiddleDrag"
1313
# Parse arguments
1414
CONFIGURATION="Release"
1515
RUN_AFTER=false
16+
CLEAN_BUILD=false
1617

1718
while [[ $# -gt 0 ]]; do
1819
case $1 in
20+
--clean|-c)
21+
CLEAN_BUILD=true
22+
shift
23+
;;
1924
--debug|-d)
2025
CONFIGURATION="Debug"
2126
shift
@@ -28,6 +33,7 @@ while [[ $# -gt 0 ]]; do
2833
echo "Usage: ./build.sh [options]"
2934
echo ""
3035
echo "Options:"
36+
echo " --clean, -c Clean previous build"
3137
echo " --debug, -d Build debug configuration"
3238
echo " --run, -r Run after building"
3339
echo " --help, -h Show this help"
@@ -43,15 +49,25 @@ done
4349
echo "🔨 Building MiddleDrag ($CONFIGURATION)..."
4450

4551
# Clean previous build
46-
echo "Cleaning previous build..."
47-
rm -rf "$BUILD_DIR"
52+
if [ "$CLEAN_BUILD" = true ]; then
53+
echo "Cleaning previous build..."
54+
rm -rf "$BUILD_DIR"
55+
fi
56+
57+
# Set architecture flags based on configuration
58+
if [ "$CONFIGURATION" = "Release" ]; then
59+
ARCH_FLAGS=(ARCHS="arm64 x86_64" ONLY_ACTIVE_ARCH=NO)
60+
else
61+
ARCH_FLAGS=(ONLY_ACTIVE_ARCH=YES)
62+
fi
4863

4964
# Create build directory
5065
mkdir -p "$BUILD_DIR"
5166

5267
# Build with xcodebuild
5368
echo "Building with Xcode..."
5469
xcodebuild \
70+
-jobs $(sysctl -n hw.ncpu) \
5571
-project "$APP_NAME.xcodeproj" \
5672
-scheme "$APP_NAME" \
5773
-configuration "$CONFIGURATION" \
@@ -61,11 +77,10 @@ xcodebuild \
6177
FRAMEWORK_SEARCH_PATHS="/System/Library/PrivateFrameworks" \
6278
CODE_SIGN_IDENTITY="-" \
6379
CODE_SIGNING_REQUIRED=NO \
64-
ARCHS="$(uname -m)" \
65-
ONLY_ACTIVE_ARCH=NO
80+
"${ARCH_FLAGS[@]}"
6681

6782
# Find the built app
68-
APP_PATH=$(find "$BUILD_DIR" -name "$APP_NAME.app" -type d | head -n 1)
83+
APP_PATH="$BUILD_DIR/Build/Products/$CONFIGURATION/$APP_NAME.app"
6984

7085
if [ -z "$APP_PATH" ]; then
7186
echo "❌ Build failed: Could not find $APP_NAME.app"

bump-version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$"; then
5555
fi
5656

5757
# Stage and amend previous commit
58+
echo "⚠️ Warning: This will amend the last commit. Make sure it hasn't been pushed yet."
59+
read -p "Continue (y/n) " -n 1 -r
60+
echo
61+
if [[ ! "$REPLY" =~ ^[Yy]$ ]]; then
62+
echo "Aborted."
63+
exit 1
64+
fi
5865
git add MiddleDrag.xcodeproj/project.pbxproj
5966
git commit --amend --no-edit
6067
echo "✓ Amended previous commit with version change"

0 commit comments

Comments
 (0)