Merge pull request #14 from MusicMaster4/feature/feature-and-corrections #70
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 | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches-ignore: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: macOS ${{ matrix.name }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Intel | |
| runner: macos-15-intel | |
| electron_arch: x64 | |
| pyinstaller_arch: x86_64 | |
| - name: Apple-Silicon | |
| runner: macos-15 | |
| electron_arch: arm64 | |
| pyinstaller_arch: arm64 | |
| env: | |
| PYINSTALLER_TARGET_ARCH: ${{ matrix.pyinstaller_arch }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| cache-dependency-path: python/requirements.txt | |
| - name: Create virtual environment | |
| run: | | |
| python -m venv .venv | |
| - name: Install Python dependencies | |
| run: | | |
| ./.venv/bin/python -m pip install --upgrade pip | |
| ./.venv/bin/python -m pip install -r python/requirements.txt | |
| ./.venv/bin/python -m pip install pyinstaller | |
| - name: Install Node dependencies | |
| run: npm ci | |
| - name: Validate JavaScript | |
| run: npm run check | |
| - name: Ensure build script is executable | |
| run: chmod +x ./scripts/build-python.sh | |
| - name: Build macOS package | |
| run: npm run dist:mac:${{ matrix.electron_arch }} | |
| - name: Use architecture-specific update metadata | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| metadata="dist/latest-mac.yml" | |
| target="dist/latest-${{ matrix.electron_arch }}-mac.yml" | |
| if [[ ! -f "$metadata" ]]; then | |
| echo "Expected macOS update metadata not found: $metadata" | |
| exit 1 | |
| fi | |
| mv "$metadata" "$target" | |
| - name: Verify packaged binary architectures | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| APP_PATH="$(find dist -maxdepth 2 -name 'OpenFlow.app' -print -quit)" | |
| if [[ -z "$APP_PATH" ]]; then | |
| echo "OpenFlow.app not found in dist/" | |
| exit 1 | |
| fi | |
| EXPECTED_ARCH="${{ matrix.pyinstaller_arch }}" | |
| BINARIES=( | |
| "$APP_PATH/Contents/MacOS/OpenFlow" | |
| "$APP_PATH/Contents/Resources/bin/dictation_service/dictation_service" | |
| "$APP_PATH/Contents/Resources/bin/hotkey_listener/hotkey_listener" | |
| ) | |
| for BINARY in "${BINARIES[@]}"; do | |
| ACTUAL_ARCHES="$(lipo -archs "$BINARY")" | |
| echo "$BINARY -> $ACTUAL_ARCHES" | |
| if [[ "$ACTUAL_ARCHES" != *"$EXPECTED_ARCH"* ]]; then | |
| echo "Unexpected architecture for $BINARY" | |
| exit 1 | |
| fi | |
| done | |
| - name: Generate checksums | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| find dist -maxdepth 1 -type f \( -name '*.dmg' -o -name '*.zip' -o -name '*.yml' -o -name '*.blockmap' \) -print0 \ | |
| | sort -z \ | |
| | xargs -0 shasum -a 256 > "dist/SHA256SUMS-macos-${{ matrix.electron_arch }}.txt" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openflow-macos-${{ matrix.electron_arch }} | |
| path: | | |
| dist/*.dmg | |
| dist/*.zip | |
| dist/*.yml | |
| dist/*.blockmap | |
| dist/SHA256SUMS-macos-${{ matrix.electron_arch }}.txt | |
| if-no-files-found: error |