diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4e57d1e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build-and-release: + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all tags + + - name: Setup Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Install create-dmg + run: brew install create-dmg + + - name: Build and Create DMG + run: make dmg + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: .build/dmg/*.dmg + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9724f98 --- /dev/null +++ b/Makefile @@ -0,0 +1,94 @@ +.PHONY: build clean dmg test help + +# Configuration +PROJECT = TextOverlay.xcodeproj +SCHEME = TextOverlay +CONFIGURATION = Release +BUILD_DIR = .build +DMG_DIR = $(BUILD_DIR)/dmg +APP_NAME = TextOverlay +VERSION ?= $(shell git describe --tags --always) + +help: ## Show this help message + @echo "Available targets:" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' + +clean: ## Clean build artifacts + @echo "๐Ÿงน Cleaning build artifacts..." + rm -rf $(BUILD_DIR) + rm -rf $(DMG_DIR) + xcodebuild clean -project $(PROJECT) -scheme $(SCHEME) -configuration $(CONFIGURATION) + +build: ## Build the app + @echo "๐Ÿ”จ Building $(APP_NAME)..." + xcodebuild -project $(PROJECT) \ + -scheme $(SCHEME) \ + -configuration $(CONFIGURATION) \ + -derivedDataPath $(BUILD_DIR) \ + build + +test: build ## Test the built app + @echo "๐Ÿงช Testing $(APP_NAME)..." + @APP_PATH="$(BUILD_DIR)/Build/Products/$(CONFIGURATION)/$(APP_NAME).app"; \ + if [ ! -d "$$APP_PATH" ]; then \ + echo "โŒ App not found at $$APP_PATH"; \ + exit 1; \ + fi; \ + echo "โœ… App exists at $$APP_PATH"; \ + \ + if [ ! -f "$$APP_PATH/Contents/MacOS/$(APP_NAME)" ]; then \ + echo "โŒ Executable not found"; \ + exit 1; \ + fi; \ + echo "โœ… Executable found"; \ + \ + codesign -dv "$$APP_PATH" 2>&1 | grep -q "Signature" && \ + echo "โœ… App is signed" || \ + echo "โš ๏ธ App is not signed (expected for local builds)"; \ + \ + file "$$APP_PATH/Contents/MacOS/$(APP_NAME)" | grep -q "Mach-O" && \ + echo "โœ… Valid Mach-O executable" || \ + (echo "โŒ Invalid executable format"; exit 1); \ + \ + echo "๐Ÿš€ Running smoke test..."; \ + "$$APP_PATH/Contents/MacOS/$(APP_NAME)" "Build Test" --position top,left & \ + APP_PID=$$!; \ + sleep 9; \ + if kill -0 $$APP_PID 2>/dev/null; then \ + echo "โœ… App launched successfully"; \ + kill $$APP_PID 2>/dev/null; \ + else \ + echo "โš ๏ธ App exited unexpectedly"; \ + fi; \ + \ + echo "โœ… All tests passed" + +dmg: test ## Create DMG file + @echo "๐Ÿ“ฆ Creating DMG for $(APP_NAME) $(VERSION)..." + @mkdir -p $(DMG_DIR) + @rm -f $(DMG_DIR)/$(APP_NAME)-$(VERSION).dmg + + # Check create-dmg installation + @if ! command -v create-dmg &> /dev/null; then \ + echo "โš ๏ธ create-dmg not found. Installing..."; \ + brew install create-dmg; \ + fi + + # Create DMG + create-dmg \ + --volname "$(APP_NAME)" \ + --window-pos 200 120 \ + --window-size 600 400 \ + --icon-size 100 \ + --icon "$(APP_NAME).app" 175 120 \ + --hide-extension "$(APP_NAME).app" \ + --app-drop-link 425 120 \ + "$(DMG_DIR)/$(APP_NAME)-$(VERSION).dmg" \ + "$(BUILD_DIR)/Build/Products/$(CONFIGURATION)/$(APP_NAME).app" + + @echo "โœ… DMG created: $(DMG_DIR)/$(APP_NAME)-$(VERSION).dmg" + +version: ## Show current version + @echo "Current version: $(VERSION)" + +.DEFAULT_GOAL := help