fix(actions): enhance DMG creation process in macOS notarization workflow by adding CI environment detection and improving reliability of DMG creation methods
This commit is contained in:
parent
8193d167c5
commit
10645afcd4
@ -202,6 +202,9 @@ jobs:
|
||||
run: |
|
||||
echo "🔧 Creating custom DMG with installer script..."
|
||||
|
||||
export CI=true
|
||||
export GITEA_ACTIONS=true
|
||||
|
||||
# Ensure app is in the expected location after notarization
|
||||
APP_PATH="${{ env.APP_PATH }}"
|
||||
|
||||
|
@ -232,32 +232,64 @@ else
|
||||
echo -e "${YELLOW}Volume icon not found at $ICON_PATH. Creating DMG without custom icon.${NC}"
|
||||
fi
|
||||
|
||||
# Create DMG using create-dmg with dynamic volicon parameter
|
||||
CMD_CREATE_DMG="create-dmg \
|
||||
--volname \"LuckyWorld ${VERSION}\" \
|
||||
$VOLICON_PARAM \
|
||||
--window-pos 200 120 \
|
||||
--window-size 800 500 \
|
||||
--icon-size 128 \
|
||||
--icon \"LuckyWorld.app\" 200 250 \
|
||||
--icon \"install_luckyworld.sh\" 400 250 \
|
||||
--icon \"README.txt\" 600 250 \
|
||||
--hide-extension \"LuckyWorld.app\" \
|
||||
--hide-extension \"install_luckyworld.sh\" \
|
||||
--app-drop-link 400 120 \
|
||||
--no-internet-enable \
|
||||
--no-finder \
|
||||
\"$OUTPUT_DMG\" \
|
||||
\"$TEMP_DIR\""
|
||||
# CI ENVIRONMENT DETECTION - Use different approach if in CI
|
||||
if [ -n "$CI" ] || [ -n "$GITHUB_ACTIONS" ] || [ -n "$GITEA_ACTIONS" ]; then
|
||||
echo -e "${BLUE}CI environment detected! Using hdiutil directly instead of create-dmg${NC}"
|
||||
|
||||
# Create DMG using hdiutil directly (much more reliable in CI)
|
||||
hdiutil create -volname "LuckyWorld ${VERSION}" -srcfolder "$TEMP_DIR" -ov -format UDZO "$OUTPUT_DMG"
|
||||
|
||||
# Check if DMG creation was successful
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Error: hdiutil DMG creation failed, attempting ZIP fallback...${NC}"
|
||||
# Create a ZIP file as fallback
|
||||
(cd "$(dirname "$TEMP_DIR")" && zip -r "$OUTPUT_DMG.zip" "$(basename "$TEMP_DIR")")
|
||||
|
||||
# If ZIP succeeded, use it instead
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${YELLOW}Created ZIP fallback: $OUTPUT_DMG.zip${NC}"
|
||||
OUTPUT_DMG="$OUTPUT_DMG.zip"
|
||||
else
|
||||
echo -e "${RED}Error: Both DMG and ZIP creation failed.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Non-CI environment: Use create-dmg
|
||||
# Create DMG using create-dmg with dynamic volicon parameter
|
||||
CMD_CREATE_DMG="create-dmg \
|
||||
--volname \"LuckyWorld ${VERSION}\" \
|
||||
$VOLICON_PARAM \
|
||||
--window-pos 200 120 \
|
||||
--window-size 800 500 \
|
||||
--icon-size 128 \
|
||||
--icon \"LuckyWorld.app\" 200 250 \
|
||||
--icon \"install_luckyworld.sh\" 400 250 \
|
||||
--icon \"README.txt\" 600 250 \
|
||||
--hide-extension \"LuckyWorld.app\" \
|
||||
--hide-extension \"install_luckyworld.sh\" \
|
||||
--app-drop-link 400 120 \
|
||||
--no-internet-enable \
|
||||
--no-finder \
|
||||
\"$OUTPUT_DMG\" \
|
||||
\"$TEMP_DIR\""
|
||||
|
||||
# Execute the command
|
||||
echo -e "${BLUE}Executing: $CMD_CREATE_DMG${NC}"
|
||||
eval $CMD_CREATE_DMG
|
||||
# Execute the command
|
||||
echo -e "${BLUE}Executing: $CMD_CREATE_DMG${NC}"
|
||||
eval $CMD_CREATE_DMG
|
||||
|
||||
# Check if DMG creation was successful
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Error: Failed to create DMG file.${NC}"
|
||||
exit 1
|
||||
# Check if DMG creation was successful
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Error: Failed to create DMG with create-dmg, trying hdiutil...${NC}"
|
||||
|
||||
# Fallback to hdiutil
|
||||
hdiutil create -volname "LuckyWorld ${VERSION}" -srcfolder "$TEMP_DIR" -ov -format UDZO "$OUTPUT_DMG"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Error: All DMG creation methods failed.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ DMG file created successfully: $OUTPUT_DMG${NC}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user