name: release-maa-mac on: release: types: [published] jobs: macos-latest: name: macos-latest runs-on: macos-12 steps: - uses: actions/checkout@v3 with: submodules: recursive - name: 'Install Developer ID Certificate' uses: ssrobins/import-codesign-certs@v2 with: p12-file-base64: ${{ secrets.HGUANDL_SIGN_CERT_P12 }} p12-password: ${{ secrets.HGUANDL_SIGN_CERT_PASSWD }} - name: Cache Homebrew uses: actions/cache@v3 with: path: $(brew --prefix) key: ${{ runner.os }}-homebrew-${{ hashFiles('.config/brew/Brewfile') }} - name: Install Dependencies run: | brew update --preinstall brew install create-dmg ninja pkg-config - name: Bootstrap MaaDeps env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | python3 maadeps-download.py "arm64-osx" python3 maadeps-download.py "x64-osx" - name: Configure MaaCore run: | cmake -B build-arm64 -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64" cmake -B build-x86_64 -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64" - name: Build libMaaCore run: | cmake --build build-arm64 cmake --build build-x86_64 - name: Build universal binaries run: | mkdir build lipo -create build-arm64/libMaaCore.dylib build-x86_64/libMaaCore.dylib -output build/libMaaCore.dylib for LIB_NAME in $(ls MaaDeps/runtime/maa-x64-osx); do lipo -create MaaDeps/runtime/maa-arm64-osx/$LIB_NAME MaaDeps/runtime/maa-x64-osx/$LIB_NAME -output build/$LIB_NAME done - name: Build XCFramework working-directory: build run: | xcodebuild -create-xcframework -library libMaaCore.dylib -headers ../include -output MaaCore.xcframework xcodebuild -create-xcframework -library libMaaDerpLearning.dylib -output MaaDerpLearning.xcframework xcodebuild -create-xcframework -library libonnxruntime.*.dylib -output ONNXRuntime.xcframework xcodebuild -create-xcframework -library libopencv*.dylib -output OpenCV.xcframework - name: Build MAA working-directory: src/MaaMacGui run: xcodebuild -project MeoAsstMac.xcodeproj -scheme MAA archive -archivePath MAA.xcarchive -configuration Release - name: Export MAA working-directory: src/MaaMacGui run: xcodebuild -exportArchive -archivePath MAA.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath Export - name: Create disk image working-directory: src/MaaMacGui run: create-dmg --background dmg-bkg.png --window-size 500 300 --icon-size 128 --icon MAA.app 0 120 --hide-extension MAA.app --app-drop-link 270 120 MAA.dmg Export/MAA.app - name: Archive debug symbols working-directory: src/MaaMacGui/MAA.xcarchive/dSYMs run: ditto -c -k --keepParent MAA.app.dSYM MAA.app.dSYM.zip - name: Place packages run: | GIT_TAG=${GITHUB_REF#refs/*/} APP_DMG=MAA-${GIT_TAG}-macos-universal.dmg APP_SYM=MAAComponent-DebugSymbol-${GIT_TAG}-macos-universal.zip mkdir -p release mv src/MaaMacGui/MAA.dmg release/${APP_DMG} mv src/MaaMacGui/MAA.xcarchive/dSYMs/MAA.app.dSYM.zip release/${APP_SYM} - name: Upload products uses: actions/upload-artifact@v3 with: name: MAA-macos path: release macos-release: name: macos-release runs-on: macos-12 needs: [macos-latest] steps: - name: 'Setup tag information' run: | GIT_TAG=${GITHUB_REF#refs/*/} echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_ENV - name: Download artifacts uses: actions/download-artifact@v3 with: name: MAA-macos - name: 'Verify image' run: | find . -name "*.dmg" -exec hdiutil verify {} \; - name: 'Notarize image' env: NOTARY_USER: ${{ secrets.HGUANDL_NOTARY_AAPL_ID }} NOTARY_PASSWD: ${{ secrets.HGUANDL_NOTARY_PASSWD }} NOTARY_TEAM: ${{ secrets.HGUANDL_SIGN_IDENTITY }} run: | find . -name "*.dmg" | while read dmg; do xcrun notarytool submit --apple-id "$NOTARY_USER" --password "$NOTARY_PASSWD" --team-id "$NOTARY_TEAM" --wait ${dmg} xcrun stapler staple ${dmg} done - name: Upload image to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: 'MAA*${{ env.GIT_TAG }}-macos*' file_glob: true tag: ${{ env.GIT_TAG }} overwrite: true