diff --git a/.ci/macos_build.sh b/.ci/macos_build.sh new file mode 100755 index 0000000..96a430e --- /dev/null +++ b/.ci/macos_build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +.ci/common/build.sh macos || exit $? +mv $(find . -name "${executable_name}.app") . || exit $? + +mkdir -p "${executable_name}.app/Contents/Frameworks" + +for file in $(find . -type f -name "*.dylib"); do + install_name_tool -change "$file" "@rpath/$file" "${executable_name}.app/Contents/MacOS/${executable_name}" || exit $? + cp "$file" "${executable_name}.app/Contents/Frameworks/" +done + +macdeployqt "${executable_name}.app" -qmldir=src || exit $? + +# Sign using self-signed certificate +codesign --verify --verbose --force --deep -s - "${executable_name}.app" +codesign --verify --verbose "${executable_name}.app" + +# Create .dmg with an install screen +npm install -g appdmg || exit $? +mv ${executable_name}.app res/macos-release/ +dmg_name=`echo "${app_name}.dmg" | tr ' ' '_'` +appdmg res/macos-release/scratchcpp-player.json "$dmg_name" || exit $? + +# Verify +#spctl -a -t open --context context:primary-signature -v "$dmg_name" diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml new file mode 100644 index 0000000..964c090 --- /dev/null +++ b/.github/workflows/macos-build.yml @@ -0,0 +1,48 @@ +name: macOS Build + +on: + push: + branches: '*' + tags: '*' + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: macos-14 + strategy: + matrix: + os: [macos-14] + qt-version: ['6.8'] + qt-target: ['desktop'] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + - name: Setup environment + run: | + sed -i -e '/^#/d' .github/config.env + sed -i -e '/^$/d' .github/config.env + cat .github/config.env >> "${GITHUB_ENV}" + shell: bash + - name: Set up node.js + uses: actions/setup-node@v3 + # Install Qt + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt-version }} + host: 'mac' + target: ${{ matrix.qt-target }} + modules: '' + # Build + - name: Build + run: .ci/macos_build.sh + shell: bash + # Upload + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: build-Qt-${{ matrix.qt-version }} + path: '*.dmg' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6e7525..830051e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,7 +119,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: build-Qt-${{ matrix.qt-version }}-${{ matrix.arch }} + name: build-linux-${{ matrix.arch }} path: | *.AppImage *.zsync @@ -224,6 +224,61 @@ jobs: name: build-windows path: '*installer.exe' + build-macos-release: + runs-on: macos-14 + strategy: + matrix: + os: [macos-14] + qt-version: ['6.8'] + qt-target: ['desktop'] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + - name: Setup environment + run: | + sed -i -e '/^#/d' .github/config.env + sed -i -e '/^$/d' .github/config.env + cat .github/config.env >> "${GITHUB_ENV}" + shell: bash + - name: Set up node.js + uses: actions/setup-node@v3 + - if: env.build_on_new_tags != 1 + name: Cancel if build on new tags is disabled + uses: andymckay/cancel-action@0.2 + - name: Get version + run: | + brew install grep + version=$(LC_ALL=en_US.utf8 ggrep -oP 'project\([^)]*\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) + echo "Project version: $version" + echo previous_tag=$version >> "${GITHUB_ENV}" + shell: bash + - if: contains(github.ref, '-') + name: Check if this is a pre-release + run: echo is_prerelease=1 >> "${GITHUB_ENV}" + shell: bash + - name: Set up node.js + uses: actions/setup-node@v3 + # Install Qt + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt-version }} + host: 'mac' + target: ${{ matrix.qt-target }} + modules: '' + # Build + - name: Build + run: .ci/macos_build.sh + shell: bash + # Upload + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: build-macos + path: '*.dmg' + # Release release: runs-on: ubuntu-latest @@ -275,8 +330,7 @@ jobs: name: Create release uses: ncipollo/release-action@v1 with: - #artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync,build-macos/*.dmg" - artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync" + artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync,build-macos/*.dmg" name: "${{ env.app_name }} ${{ env.version }}" owner: ${{ github.event.pusher.name }} draft: true diff --git a/res/macos-release/bg.png b/res/macos-release/bg.png new file mode 100644 index 0000000..3f2fbf1 Binary files /dev/null and b/res/macos-release/bg.png differ diff --git a/res/macos-release/scratchcpp-player.icns b/res/macos-release/scratchcpp-player.icns new file mode 100644 index 0000000..2e8f5bc Binary files /dev/null and b/res/macos-release/scratchcpp-player.icns differ diff --git a/res/macos-release/scratchcpp-player.json b/res/macos-release/scratchcpp-player.json new file mode 100644 index 0000000..1f9be64 --- /dev/null +++ b/res/macos-release/scratchcpp-player.json @@ -0,0 +1,9 @@ +{ + "title": "ScratchCPP Player", + "icon": "scratchcpp-player.icns", + "background": "bg.png", + "contents": [ + { "x": 448, "y": 344, "type": "link", "path": "/Applications" }, + { "x": 192, "y": 344, "type": "file", "path": "scratchcpp-player.app" } + ] +}