Skip to content

Add macOS workflow #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .ci/macos_build.sh
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
@@ -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'
60 changes: 57 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Binary file added res/macos-release/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/macos-release/scratchcpp-player.icns
Binary file not shown.
9 changes: 9 additions & 0 deletions res/macos-release/scratchcpp-player.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
Loading