Skip to content

Commit

Permalink
mac test
Browse files Browse the repository at this point in the history
  • Loading branch information
fralonra committed Aug 6, 2023
1 parent 191654c commit 3cb4aee
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ jobs:
./ppd-editor-linux-${{ github.ref_name }}.tar.gz
./ppd-viewer-linux-${{ github.ref_name }}.tar.gz
macos:
runs-on: macos-11
permissions:
contents: write

steps:
- uses: actions/checkout@v3
- name: Install ARM target
run: rustup update && rustup target add aarch64-apple-darwin
- name: Build ARM
run: GIT_COMMIT_HASH=$(git rev-parse --short HEAD) cargo build --release --target=aarch64-apple-darwin
- name: Copy
run: cp ./target/release/osx/ppd-editor ./ppd-editor-macos-${{ github.ref_name }}
- name: Make DMG
run: |
make dmg-universal
mv ./target/release/osx/ppd-editor.dmg ./ppd-editor-macos-${{ github.ref_name }}.dmg
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
./ppd-editor-macos-${{ github.ref_name }}.dmg
./ppd-editor-macos-${{ github.ref_name }}
windows:
runs-on: windows-latest
defaults:
Expand Down
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
TARGET = ppd-editor

ASSETS_DIR = extra
RELEASE_DIR = target/release

APP_NAME = PpdEditor.app
APP_TEMPLATE = $(ASSETS_DIR)/osx/$(APP_NAME)
APP_DIR = $(RELEASE_DIR)/osx
APP_BINARY = $(RELEASE_DIR)/$(TARGET)
APP_BINARY_DIR = $(APP_DIR)/$(APP_NAME)/Contents/MacOS
APP_EXTRAS_DIR = $(APP_DIR)/$(APP_NAME)/Contents/Resources

DMG_NAME = PpdEditor.dmg
DMG_DIR = $(RELEASE_DIR)/osx

vpath $(TARGET) $(RELEASE_DIR)
vpath $(APP_NAME) $(APP_DIR)
vpath $(DMG_NAME) $(APP_DIR)

all: help

help: ## Print this help message
@grep -E '^[a-zA-Z._-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

binary: $(TARGET)-native ## Build a release binary
binary-universal: $(TARGET)-universal ## Build a universal release binary
$(TARGET)-native:
MACOSX_DEPLOYMENT_TARGET="10.11" cargo build --release
$(TARGET)-universal:
MACOSX_DEPLOYMENT_TARGET="10.11" cargo build --release --target=x86_64-apple-darwin
MACOSX_DEPLOYMENT_TARGET="10.11" cargo build --release --target=aarch64-apple-darwin
@lipo target/{x86_64,aarch64}-apple-darwin/release/$(TARGET) -create -output $(APP_BINARY)

app: $(APP_NAME)-native ## Create an PpdEditor.app
app-universal: $(APP_NAME)-universal ## Create a universal PpdEditor.app
$(APP_NAME)-%: $(TARGET)-%
@mkdir -p $(APP_BINARY_DIR)
@mkdir -p $(APP_EXTRAS_DIR)
@gzip -c $(MANPAGE) > $(APP_EXTRAS_DIR)/ppd-editor.1.gz
@gzip -c $(MANPAGE-MSG) > $(APP_EXTRAS_DIR)/ppd-editor-msg.1.gz
@cp -fRp $(APP_TEMPLATE) $(APP_DIR)
@cp -fp $(APP_BINARY) $(APP_BINARY_DIR)
@touch -r "$(APP_BINARY)" "$(APP_DIR)/$(APP_NAME)"
@codesign --remove-signature "$(APP_DIR)/$(APP_NAME)"
@codesign --force --deep --sign - "$(APP_DIR)/$(APP_NAME)"
@echo "Created '$(APP_NAME)' in '$(APP_DIR)'"

dmg: $(DMG_NAME)-native ## Create an PpdEditor.dmg
dmg-universal: $(DMG_NAME)-universal ## Create a universal PpdEditor.dmg
$(DMG_NAME)-%: $(APP_NAME)-%
@echo "Packing disk image..."
@ln -sf /Applications $(DMG_DIR)/Applications
@hdiutil create $(DMG_DIR)/$(DMG_NAME) \
-volname "PpdEditor" \
-fs HFS+ \
-srcfolder $(APP_DIR) \
-ov -format UDZO
@echo "Packed '$(APP_NAME)' in '$(APP_DIR)'"

install: $(INSTALL)-native ## Mount disk image
install-universal: $(INSTALL)-native ## Mount universal disk image
$(INSTALL)-%: $(DMG_NAME)-%
@open $(DMG_DIR)/$(DMG_NAME)

.PHONY: app binary clean dmg install $(TARGET) $(TARGET)-universal

clean: ## Remove all build artifacts
@cargo clean
36 changes: 36 additions & 0 deletions build/macos/PpdEditor.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">ppd-editor
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>ppd-editor</string>
<key>CFBundleIdentifier</key>
<string>io.github.fralonra.PpdEditor</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>PpdEditor</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.3.1</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleIconFile</key>
<string>ppd-editor.icns</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>PpdEditor</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
</dict>
</plist>
Binary file not shown.

0 comments on commit 3cb4aee

Please sign in to comment.