SerialPrograms MacOS Release #12
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: SerialPrograms MacOS Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| repo: | |
| description: 'Source code repo' | |
| required: false | |
| default: 'PokemonAutomation/Arduino-Source' | |
| branch: | |
| description: 'Branch for the manual release. This should match the branch of Arduino-Source.' | |
| required: true | |
| version: | |
| description: 'Version tag for the release (e.g. v0.55.5)' | |
| required: true | |
| package_version: | |
| description: 'Commit SHA of the Packages repo with firmware compatible with the given release version' | |
| required: false | |
| default: 'master' | |
| jobs: | |
| description: 'Number of parallel jobs to build with' | |
| default: 4 | |
| type: number | |
| qt_version: | |
| description: 'Qt version to use' | |
| required: true | |
| default: '6.9.0' | |
| type: choice | |
| options: | |
| - '6.9.0' | |
| - '6.8.2' | |
| - '6.5.3' | |
| jobs: | |
| build: | |
| name: Build SerialPrograms ${{ matrix.name }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - name: Apple Silicon | |
| runner: macos-15 | |
| arch: arm64 | |
| - name: Intel | |
| runner: macos-13 | |
| arch: x86_64 | |
| steps: | |
| - name: Checkout Arduino-Source | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.inputs.repo }} | |
| ref: ${{ github.event.inputs.branch }} | |
| path: Arduino-Source | |
| # MacOS runners have Homebrew, Xcode, and Cmake already installed | |
| - name: Install Dependencies | |
| run: | | |
| brew install tesseract | |
| brew install tesseract-lang | |
| brew install opencv | |
| brew install onnxruntime | |
| - uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: ${{ github.event.inputs.qt_version }} | |
| modules: 'qtmultimedia qtserialport' | |
| - name: Build SerialPrograms.app | |
| run: | | |
| cd Arduino-Source/SerialPrograms | |
| mkdir bin | |
| cd bin | |
| cmake .. -DUNIX_LINK_TESSERACT:BOOL=true -DCMAKE_BUILD_TYPE:STRING=Release -DPACKAGE_BUILD=true | |
| cmake --build . -j ${{ github.event.inputs.jobs || 4}} | |
| cp -r SerialPrograms.app ../../../SerialPrograms.app | |
| # Important: GitHub MacOS runners do not have the lib area in its rpath by default. It must manually be added for frameworks to be discovered and added to the bundle | |
| # Some libraries are not copied in QT deployment on the runner but will still be proprely linked if they're added prior to deployment | |
| - name: rpath resolution | |
| run: | | |
| BREW_PREFIX=$(brew --prefix) | |
| install_name_tool -add_rpath $BREW_PREFIX/lib SerialPrograms.app/Contents/MacOS/SerialPrograms | |
| otool -l SerialPrograms.app/Contents/MacOS/SerialPrograms | grep -A2 LC_RPATH | |
| mkdir SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/gcc/lib/gcc/current/libgcc_s.1.1.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/protobuf/lib/libutf8_validity.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/webp/lib/libsharpyuv.0.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/jpeg-xl/lib/libjxl_cms.0.11.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkCommonComputationalGeometry-*.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkFiltersVerdict-*.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkfmt-*.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkFiltersGeometry-*.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkFiltersCore-*.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkCommonCore-*.dylib SerialPrograms.app/Contents/Frameworks | |
| cp $BREW_PREFIX/opt/vtk/lib/libvtkCommonSystem-*.dylib SerialPrograms.app/Contents/Frameworks | |
| # Use macdeployqt to bundle the app with dependencies | |
| - name: Run macdeployqt | |
| run: macdeployqt SerialPrograms.app -verbose=3 | |
| # Dummy codesign | |
| - name: Codesign | |
| run: codesign --force --deep --sign - SerialPrograms.app | |
| # Create a disk image for installation | |
| - name: Create Disk Image | |
| run: | | |
| brew install create-dmg | |
| mkdir dmg | |
| cd dmg | |
| mv ../SerialPrograms.app ./SerialPrograms.app | |
| # Workaround for https://github.com/actions/runner-images/issues/7522 | |
| i=0 | |
| max_retries=10 | |
| until create-dmg --volname "SerialPrograms Installer" \ | |
| --window-pos 150 150 \ | |
| --window-size 600 400 \ | |
| --icon-size 128 \ | |
| --icon "SerialPrograms.app" 140 160 \ | |
| --hide-extension "SerialPrograms.app" \ | |
| --app-drop-link 450 160 \ | |
| "SerialPrograms-Installer.dmg" \ | |
| "./" | |
| do | |
| if [ $i -eq $max_retries ]; then | |
| echo "Failed to create disk image after $max_retries attempts." | |
| exit 1 | |
| fi | |
| echo "Retrying create-dmg... Attempt $((i+1))" | |
| sleep 5 | |
| i=$((i+1)) | |
| done | |
| mv SerialPrograms-Installer.dmg $GITHUB_WORKSPACE/SerialPrograms-Installer-${{ matrix.arch }}.dmg | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: SerialPrograms-Installer-${{ matrix.arch }} | |
| path: SerialPrograms-Installer-${{ matrix.arch }}.dmg | |
| release: | |
| name: Create GitHub Release | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Packages | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: 'PokemonAutomation/Packages' | |
| path: Packages | |
| ref: ${{ github.event.inputs.package_version }} | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: dmgs | |
| - name: GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body: "${{ github.event.inputs.version }} MacOS Release" | |
| files: | | |
| dmgs/**/*.dmg | |
| Packages/Firmware/* | |
| tag_name: ${{ github.event.inputs.version }} | |
| token: ${{ secrets.GITHUB_TOKEN }} |