Build macOS .dmg #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build macOS .dmg | |
| # Controls when the action will run. Workflow runs when manually triggered using the UI | |
| # or API. | |
| on: | |
| workflow_dispatch: | |
| # Inputs the workflow accepts. | |
| inputs: | |
| name: | |
| # Friendly description to be shown in the UI instead of 'name' | |
| description: 'Person to greet' | |
| # Default value if no value is explicitly provided | |
| default: 'World' | |
| # Input has to be provided for the workflow to run | |
| required: true | |
| # The data type of the input | |
| type: string | |
| #on: | |
| # push: | |
| # tags: | |
| # - 'v*' | |
| # workflow_dispatch: | |
| jobs: | |
| build-dmg: | |
| runs-on: macos-latest | |
| steps: | |
| - name: 🧾 Checkout code | |
| uses: actions/checkout@v4 | |
| - name: 🧰 Install Homebrew packages | |
| run: | | |
| brew install gtk4 libadwaita meson ninja create-dmg git | |
| - name: 🐍 Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: 📦 Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyinstaller | |
| - name: 📦 Install blueprint | |
| run: | | |
| git clone https://gitlab.gnome.org/GNOME/blueprint-compiler | |
| cd blueprint-compiler | |
| meson setup _build | |
| ninja -C _build | |
| ninja -C _build install | |
| - name: ⚙️ Build app with Meson | |
| run: | | |
| meson setup builddir --prefix=${PWD}/install | |
| meson compile -C builddir | |
| meson install -C builddir | |
| - name: 🧱 Create .app bundle | |
| run: | | |
| mkdir -p MyApp.app/Contents/MacOS | |
| cp install/bin/my-gtk-app MyApp.app/Contents/MacOS/ | |
| cp -r install/share MyApp.app/Contents/Resources/ | |
| # Create basic Info.plist | |
| cat > MyApp.app/Contents/Info.plist <<EOF | |
| <?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"> | |
| <dict> | |
| <key>CFBundleName</key><string>MyApp</string> | |
| <key>CFBundleIdentifier</key><string>com.example.myapp</string> | |
| <key>CFBundleVersion</key><string>${{ github.ref_name }}</string> | |
| <key>CFBundleExecutable</key><string>my-gtk-app</string> | |
| <key>CFBundlePackageType</key><string>APPL</string> | |
| </dict> | |
| </plist> | |
| EOF | |
| - name: 📀 Create DMG | |
| run: | | |
| create-dmg \ | |
| --volname "MyApp" \ | |
| --window-pos 200 120 \ | |
| --window-size 800 400 \ | |
| --icon-size 100 \ | |
| --icon "MyApp.app" 200 190 \ | |
| --app-drop-link 600 185 \ | |
| dist/ \ | |
| MyApp.app | |
| - name: 📤 Upload DMG artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: MyApp-macos-dmg | |
| path: dist/*.dmg |