Skip to content

Commit 488719e

Browse files
committed
fix installers #5
1 parent 2d32c3e commit 488719e

File tree

11 files changed

+198
-57
lines changed

11 files changed

+198
-57
lines changed

.github/workflows/build-macos-arm-installer.yml

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,44 @@ jobs:
9090
run: |
9191
# Clean any existing output directory
9292
rm -rf dist
93-
mkdir -p dist/Cleanuparr.app/Contents/MacOS
94-
95-
# Set environment variables to disable code signing
96-
export CODESIGN_ALLOCATE=/usr/bin/true
97-
export DOTNET_BUNDLE_EXTRACT_BASE_DIR=/tmp/dotnet_bundle_extract
93+
mkdir -p dist/temp
9894
99-
# Build without single file first, then we'll handle it manually if needed
95+
# First build to a temporary location to inspect the output
10096
dotnet publish code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj \
10197
-c Release \
10298
--runtime osx-arm64 \
103-
--self-contained \
104-
-o dist/Cleanuparr.app/Contents/MacOS \
105-
/p:PublishSingleFile=false \
99+
--self-contained true \
100+
-o dist/temp \
101+
/p:PublishSingleFile=true \
106102
/p:Version=${{ env.appVersion }} \
107103
/p:DebugType=None \
108104
/p:DebugSymbols=false \
109105
/p:UseAppHost=true \
110106
/p:EnableMacOSCodeSign=false \
111107
/p:CodeSignOnCopy=false \
112-
/p:_CodeSignDuringBuild=false
108+
/p:_CodeSignDuringBuild=false \
109+
/p:PublishTrimmed=false \
110+
/p:TrimMode=link
111+
112+
# Create proper app bundle structure
113+
mkdir -p dist/Cleanuparr.app/Contents/MacOS
114+
115+
# Copy the built executable (note: AssemblyName is "Cleanuparr" not "Cleanuparr.Api")
116+
cp dist/temp/Cleanuparr dist/Cleanuparr.app/Contents/MacOS/Cleanuparr
117+
118+
# Copy any additional runtime files if they exist
119+
if [ -d "dist/temp" ]; then
120+
find dist/temp -name "*.dylib" -exec cp {} dist/Cleanuparr.app/Contents/MacOS/ \; 2>/dev/null || true
121+
find dist/temp -name "createdump" -exec cp {} dist/Cleanuparr.app/Contents/MacOS/ \; 2>/dev/null || true
122+
fi
113123
114124
- name: Post-build setup
115125
run: |
116126
# Make sure the executable is actually executable
117127
chmod +x dist/Cleanuparr.app/Contents/MacOS/Cleanuparr
118128
119129
# Remove any .pdb files that might have been created
120-
find dist/Cleanuparr.app/Contents/MacOS -name "*.pdb" -delete
130+
find dist/Cleanuparr.app/Contents/MacOS -name "*.pdb" -delete 2>/dev/null || true
121131
122132
echo "Checking architecture of built binary:"
123133
file dist/Cleanuparr.app/Contents/MacOS/Cleanuparr
@@ -127,11 +137,14 @@ jobs:
127137
128138
echo "Files in MacOS directory:"
129139
ls -la dist/Cleanuparr.app/Contents/MacOS/
140+
141+
echo "Checking if executable can run basic help:"
142+
dist/Cleanuparr.app/Contents/MacOS/Cleanuparr --help || echo "Help command failed, but this might be expected"
130143
131144
- name: Create macOS app bundle structure
132145
run: |
133146
# Create proper app bundle structure
134-
mkdir -p dist/Cleanuparr.app/Contents/{MacOS,Resources}
147+
mkdir -p dist/Cleanuparr.app/Contents/{MacOS,Resources,Frameworks}
135148
136149
# Convert ICO to ICNS for macOS app bundle
137150
if command -v iconutil >/dev/null 2>&1; then
@@ -157,7 +170,7 @@ jobs:
157170
rm -rf Cleanuparr.iconset
158171
fi
159172
160-
# Create Info.plist with icon reference
173+
# Create Info.plist with proper configuration
161174
cat > dist/Cleanuparr.app/Contents/Info.plist << EOF
162175
<?xml version="1.0" encoding="UTF-8"?>
163176
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -166,9 +179,11 @@ jobs:
166179
<key>CFBundleExecutable</key>
167180
<string>Cleanuparr</string>
168181
<key>CFBundleIdentifier</key>
169-
<string>Cleanuparr</string>
182+
<string>com.Cleanuparr</string>
170183
<key>CFBundleName</key>
171184
<string>Cleanuparr</string>
185+
<key>CFBundleDisplayName</key>
186+
<string>Cleanuparr</string>
172187
<key>CFBundleVersion</key>
173188
<string>${{ env.appVersion }}</string>
174189
<key>CFBundleShortVersionString</key>
@@ -187,41 +202,89 @@ jobs:
187202
<false/>
188203
<key>LSMinimumSystemVersion</key>
189204
<string>11.0</string>
205+
<key>LSApplicationCategoryType</key>
206+
<string>public.app-category.productivity</string>
207+
<key>NSSupportsAutomaticTermination</key>
208+
<false/>
209+
<key>NSSupportsSuddenTermination</key>
210+
<false/>
211+
<key>LSBackgroundOnly</key>
212+
<false/>
213+
<key>NSAppTransportSecurity</key>
214+
<dict>
215+
<key>NSAllowsArbitraryLoads</key>
216+
<true/>
217+
</dict>
190218
</dict>
191219
</plist>
192220
EOF
193221
222+
# Clean up temp directory
223+
rm -rf dist/temp
224+
194225
- name: Create PKG installer
195226
run: |
196227
# Create postinstall script
197228
mkdir -p scripts
198229
cat > scripts/postinstall << 'EOF'
199230
#!/bin/bash
200231
232+
# Set proper permissions for the app bundle
233+
chmod -R 755 /Applications/Cleanuparr.app
234+
chmod +x /Applications/Cleanuparr.app/Contents/MacOS/Cleanuparr
235+
201236
# Create config directory in user's Application Support
202-
mkdir -p "$HOME/Library/Application Support/Cleanuparr"
237+
# Note: This runs as root during installation, so we need to handle user directories properly
238+
for user_home in /Users/*; do
239+
if [[ -d "$user_home" && ! "$user_home" =~ /(Shared|.localized)$ ]]; then
240+
user_name=$(basename "$user_home")
241+
if [[ "$user_name" != "root" ]]; then
242+
sudo -u "$user_name" mkdir -p "$user_home/Library/Application Support/Cleanuparr"
243+
sudo -u "$user_name" chmod 755 "$user_home/Library/Application Support/Cleanuparr"
244+
fi
245+
fi
246+
done
203247
204-
# Set permissions
205-
chmod -R 755 "$HOME/Library/Application Support/Cleanuparr"
248+
# Add to system PATH if not already there (optional)
249+
# ln -sf /Applications/Cleanuparr.app/Contents/MacOS/Cleanuparr /usr/local/bin/cleanuparr 2>/dev/null || true
206250
207251
exit 0
208252
EOF
209253
210254
chmod +x scripts/postinstall
211255
256+
# Create preinstall script to handle existing installations
257+
cat > scripts/preinstall << 'EOF'
258+
#!/bin/bash
259+
260+
# Stop any running instances of Cleanuparr
261+
pkill -f "Cleanuparr" || true
262+
sleep 2
263+
264+
# Remove old installation if it exists
265+
if [[ -d "/Applications/Cleanuparr.app" ]]; then
266+
rm -rf "/Applications/Cleanuparr.app"
267+
fi
268+
269+
exit 0
270+
EOF
271+
272+
chmod +x scripts/preinstall
273+
212274
# Determine package name
213275
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]]; then
214276
pkg_name="Cleanuparr-${{ env.appVersion }}-macos-arm64.pkg"
215277
else
216278
pkg_name="Cleanuparr-${{ env.appVersion }}-macos-arm64-dev.pkg"
217279
fi
218280
219-
# Create PKG installer
281+
# Create PKG installer with better metadata
220282
pkgbuild --root dist/ \
221283
--scripts scripts/ \
222-
--identifier Cleanuparr.app \
284+
--identifier com.Cleanuparr \
223285
--version ${{ env.appVersion }} \
224286
--install-location /Applications \
287+
--ownership preserve \
225288
${pkg_name}
226289
227290
echo "pkgName=${pkg_name}" >> $GITHUB_ENV

.github/workflows/build-macos-intel-installer.yml

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,44 @@ jobs:
9090
run: |
9191
# Clean any existing output directory
9292
rm -rf dist
93-
mkdir -p dist/Cleanuparr.app/Contents/MacOS
94-
95-
# Set environment variables to disable code signing
96-
export CODESIGN_ALLOCATE=/usr/bin/true
97-
export DOTNET_BUNDLE_EXTRACT_BASE_DIR=/tmp/dotnet_bundle_extract
93+
mkdir -p dist/temp
9894
99-
# Build without single file first, then we'll handle it manually if needed
95+
# First build to a temporary location to inspect the output
10096
dotnet publish code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj \
10197
-c Release \
10298
--runtime osx-x64 \
103-
--self-contained \
104-
-o dist/Cleanuparr.app/Contents/MacOS \
105-
/p:PublishSingleFile=false \
99+
--self-contained true \
100+
-o dist/temp \
101+
/p:PublishSingleFile=true \
106102
/p:Version=${{ env.appVersion }} \
107103
/p:DebugType=None \
108104
/p:DebugSymbols=false \
109105
/p:UseAppHost=true \
110106
/p:EnableMacOSCodeSign=false \
111107
/p:CodeSignOnCopy=false \
112-
/p:_CodeSignDuringBuild=false
108+
/p:_CodeSignDuringBuild=false \
109+
/p:PublishTrimmed=false \
110+
/p:TrimMode=link
111+
112+
# Create proper app bundle structure
113+
mkdir -p dist/Cleanuparr.app/Contents/MacOS
114+
115+
# Copy the built executable (note: AssemblyName is "Cleanuparr" not "Cleanuparr.Api")
116+
cp dist/temp/Cleanuparr dist/Cleanuparr.app/Contents/MacOS/Cleanuparr
117+
118+
# Copy any additional runtime files if they exist
119+
if [ -d "dist/temp" ]; then
120+
find dist/temp -name "*.dylib" -exec cp {} dist/Cleanuparr.app/Contents/MacOS/ \; 2>/dev/null || true
121+
find dist/temp -name "createdump" -exec cp {} dist/Cleanuparr.app/Contents/MacOS/ \; 2>/dev/null || true
122+
fi
113123
114124
- name: Post-build setup
115125
run: |
116126
# Make sure the executable is actually executable
117127
chmod +x dist/Cleanuparr.app/Contents/MacOS/Cleanuparr
118128
119129
# Remove any .pdb files that might have been created
120-
find dist/Cleanuparr.app/Contents/MacOS -name "*.pdb" -delete
130+
find dist/Cleanuparr.app/Contents/MacOS -name "*.pdb" -delete 2>/dev/null || true
121131
122132
echo "Checking architecture of built binary:"
123133
file dist/Cleanuparr.app/Contents/MacOS/Cleanuparr
@@ -127,11 +137,14 @@ jobs:
127137
128138
echo "Files in MacOS directory:"
129139
ls -la dist/Cleanuparr.app/Contents/MacOS/
140+
141+
echo "Checking if executable can run basic help:"
142+
dist/Cleanuparr.app/Contents/MacOS/Cleanuparr --help || echo "Help command failed, but this might be expected"
130143
131144
- name: Create macOS app bundle structure
132145
run: |
133146
# Create proper app bundle structure
134-
mkdir -p dist/Cleanuparr.app/Contents/{MacOS,Resources}
147+
mkdir -p dist/Cleanuparr.app/Contents/{MacOS,Resources,Frameworks}
135148
136149
# Convert ICO to ICNS for macOS app bundle
137150
if command -v iconutil >/dev/null 2>&1; then
@@ -157,7 +170,7 @@ jobs:
157170
rm -rf Cleanuparr.iconset
158171
fi
159172
160-
# Create Info.plist with icon reference
173+
# Create Info.plist with proper configuration
161174
cat > dist/Cleanuparr.app/Contents/Info.plist << EOF
162175
<?xml version="1.0" encoding="UTF-8"?>
163176
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -166,9 +179,11 @@ jobs:
166179
<key>CFBundleExecutable</key>
167180
<string>Cleanuparr</string>
168181
<key>CFBundleIdentifier</key>
169-
<string>Cleanuparr</string>
182+
<string>com.Cleanuparr</string>
170183
<key>CFBundleName</key>
171184
<string>Cleanuparr</string>
185+
<key>CFBundleDisplayName</key>
186+
<string>Cleanuparr</string>
172187
<key>CFBundleVersion</key>
173188
<string>${{ env.appVersion }}</string>
174189
<key>CFBundleShortVersionString</key>
@@ -187,9 +202,25 @@ jobs:
187202
<false/>
188203
<key>LSMinimumSystemVersion</key>
189204
<string>10.15</string>
205+
<key>LSApplicationCategoryType</key>
206+
<string>public.app-category.productivity</string>
207+
<key>NSSupportsAutomaticTermination</key>
208+
<false/>
209+
<key>NSSupportsSuddenTermination</key>
210+
<false/>
211+
<key>LSBackgroundOnly</key>
212+
<false/>
213+
<key>NSAppTransportSecurity</key>
214+
<dict>
215+
<key>NSAllowsArbitraryLoads</key>
216+
<true/>
217+
</dict>
190218
</dict>
191219
</plist>
192220
EOF
221+
222+
# Clean up temp directory
223+
rm -rf dist/temp
193224
194225
- name: Create PKG installer
195226
run: |
@@ -198,30 +229,62 @@ jobs:
198229
cat > scripts/postinstall << 'EOF'
199230
#!/bin/bash
200231
232+
# Set proper permissions for the app bundle
233+
chmod -R 755 /Applications/Cleanuparr.app
234+
chmod +x /Applications/Cleanuparr.app/Contents/MacOS/Cleanuparr
235+
201236
# Create config directory in user's Application Support
202-
mkdir -p "$HOME/Library/Application Support/Cleanuparr"
237+
# Note: This runs as root during installation, so we need to handle user directories properly
238+
for user_home in /Users/*; do
239+
if [[ -d "$user_home" && ! "$user_home" =~ /(Shared|.localized)$ ]]; then
240+
user_name=$(basename "$user_home")
241+
if [[ "$user_name" != "root" ]]; then
242+
sudo -u "$user_name" mkdir -p "$user_home/Library/Application Support/Cleanuparr"
243+
sudo -u "$user_name" chmod 755 "$user_home/Library/Application Support/Cleanuparr"
244+
fi
245+
fi
246+
done
203247
204-
# Set permissions
205-
chmod -R 755 "$HOME/Library/Application Support/Cleanuparr"
248+
# Add to system PATH if not already there (optional)
249+
# ln -sf /Applications/Cleanuparr.app/Contents/MacOS/Cleanuparr /usr/local/bin/cleanuparr 2>/dev/null || true
206250
207251
exit 0
208252
EOF
209253
210254
chmod +x scripts/postinstall
211255
256+
# Create preinstall script to handle existing installations
257+
cat > scripts/preinstall << 'EOF'
258+
#!/bin/bash
259+
260+
# Stop any running instances of Cleanuparr
261+
pkill -f "Cleanuparr" || true
262+
sleep 2
263+
264+
# Remove old installation if it exists
265+
if [[ -d "/Applications/Cleanuparr.app" ]]; then
266+
rm -rf "/Applications/Cleanuparr.app"
267+
fi
268+
269+
exit 0
270+
EOF
271+
272+
chmod +x scripts/preinstall
273+
212274
# Determine package name
213275
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]]; then
214276
pkg_name="Cleanuparr-${{ env.appVersion }}-macos-intel.pkg"
215277
else
216278
pkg_name="Cleanuparr-${{ env.appVersion }}-macos-intel-dev.pkg"
217279
fi
218280
219-
# Create PKG installer
281+
# Create PKG installer with better metadata
220282
pkgbuild --root dist/ \
221283
--scripts scripts/ \
222-
--identifier Cleanuparr \
284+
--identifier com.Cleanuparr \
223285
--version ${{ env.appVersion }} \
224286
--install-location /Applications \
287+
--ownership preserve \
225288
${pkg_name}
226289
227290
echo "pkgName=${pkg_name}" >> $GITHUB_ENV

0 commit comments

Comments
 (0)