Skip to content

Commit 573a3a3

Browse files
authored
Merge pull request #55 from scratchcpp/macos_workflow
Add macOS workflow
2 parents b8d8f2a + 9f9e471 commit 573a3a3

File tree

6 files changed

+140
-3
lines changed

6 files changed

+140
-3
lines changed

.ci/macos_build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
.ci/common/build.sh macos || exit $?
4+
mv $(find . -name "${executable_name}.app") . || exit $?
5+
6+
mkdir -p "${executable_name}.app/Contents/Frameworks"
7+
8+
for file in $(find . -type f -name "*.dylib"); do
9+
install_name_tool -change "$file" "@rpath/$file" "${executable_name}.app/Contents/MacOS/${executable_name}" || exit $?
10+
cp "$file" "${executable_name}.app/Contents/Frameworks/"
11+
done
12+
13+
macdeployqt "${executable_name}.app" -qmldir=src || exit $?
14+
15+
# Sign using self-signed certificate
16+
codesign --verify --verbose --force --deep -s - "${executable_name}.app"
17+
codesign --verify --verbose "${executable_name}.app"
18+
19+
# Create .dmg with an install screen
20+
npm install -g appdmg || exit $?
21+
mv ${executable_name}.app res/macos-release/
22+
dmg_name=`echo "${app_name}.dmg" | tr ' ' '_'`
23+
appdmg res/macos-release/scratchcpp-player.json "$dmg_name" || exit $?
24+
25+
# Verify
26+
#spctl -a -t open --context context:primary-signature -v "$dmg_name"

.github/workflows/macos-build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: macOS Build
2+
3+
on:
4+
push:
5+
branches: '*'
6+
tags: '*'
7+
pull_request:
8+
branches: [ "master" ]
9+
10+
jobs:
11+
build:
12+
runs-on: macos-14
13+
strategy:
14+
matrix:
15+
os: [macos-14]
16+
qt-version: ['6.8']
17+
qt-target: ['desktop']
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
submodules: 'recursive'
23+
- name: Setup environment
24+
run: |
25+
sed -i -e '/^#/d' .github/config.env
26+
sed -i -e '/^$/d' .github/config.env
27+
cat .github/config.env >> "${GITHUB_ENV}"
28+
shell: bash
29+
- name: Set up node.js
30+
uses: actions/setup-node@v3
31+
# Install Qt
32+
- name: Install Qt
33+
uses: jurplel/install-qt-action@v3
34+
with:
35+
version: ${{ matrix.qt-version }}
36+
host: 'mac'
37+
target: ${{ matrix.qt-target }}
38+
modules: ''
39+
# Build
40+
- name: Build
41+
run: .ci/macos_build.sh
42+
shell: bash
43+
# Upload
44+
- name: Upload artifacts
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: build-Qt-${{ matrix.qt-version }}
48+
path: '*.dmg'

.github/workflows/release.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
- name: Upload artifacts
120120
uses: actions/upload-artifact@v4
121121
with:
122-
name: build-Qt-${{ matrix.qt-version }}-${{ matrix.arch }}
122+
name: build-linux-${{ matrix.arch }}
123123
path: |
124124
*.AppImage
125125
*.zsync
@@ -224,6 +224,61 @@ jobs:
224224
name: build-windows
225225
path: '*installer.exe'
226226

227+
build-macos-release:
228+
runs-on: macos-14
229+
strategy:
230+
matrix:
231+
os: [macos-14]
232+
qt-version: ['6.8']
233+
qt-target: ['desktop']
234+
steps:
235+
- uses: actions/checkout@v4
236+
with:
237+
fetch-depth: 0
238+
submodules: 'recursive'
239+
- name: Setup environment
240+
run: |
241+
sed -i -e '/^#/d' .github/config.env
242+
sed -i -e '/^$/d' .github/config.env
243+
cat .github/config.env >> "${GITHUB_ENV}"
244+
shell: bash
245+
- name: Set up node.js
246+
uses: actions/setup-node@v3
247+
- if: env.build_on_new_tags != 1
248+
name: Cancel if build on new tags is disabled
249+
uses: andymckay/[email protected]
250+
- name: Get version
251+
run: |
252+
brew install grep
253+
version=$(LC_ALL=en_US.utf8 ggrep -oP 'project\([^)]*\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
254+
echo "Project version: $version"
255+
echo previous_tag=$version >> "${GITHUB_ENV}"
256+
shell: bash
257+
- if: contains(github.ref, '-')
258+
name: Check if this is a pre-release
259+
run: echo is_prerelease=1 >> "${GITHUB_ENV}"
260+
shell: bash
261+
- name: Set up node.js
262+
uses: actions/setup-node@v3
263+
# Install Qt
264+
- name: Install Qt
265+
uses: jurplel/install-qt-action@v3
266+
with:
267+
version: ${{ matrix.qt-version }}
268+
host: 'mac'
269+
target: ${{ matrix.qt-target }}
270+
modules: ''
271+
# Build
272+
- name: Build
273+
run: .ci/macos_build.sh
274+
shell: bash
275+
# Upload
276+
- name: Upload artifacts
277+
uses: actions/upload-artifact@v4
278+
with:
279+
name: build-macos
280+
path: '*.dmg'
281+
227282
# Release
228283
release:
229284
runs-on: ubuntu-latest
@@ -275,8 +330,7 @@ jobs:
275330
name: Create release
276331
uses: ncipollo/release-action@v1
277332
with:
278-
#artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync,build-macos/*.dmg"
279-
artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync"
333+
artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync,build-macos/*.dmg"
280334
name: "${{ env.app_name }} ${{ env.version }}"
281335
owner: ${{ github.event.pusher.name }}
282336
draft: true

res/macos-release/bg.png

12.1 KB
Loading
47.4 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"title": "ScratchCPP Player",
3+
"icon": "scratchcpp-player.icns",
4+
"background": "bg.png",
5+
"contents": [
6+
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
7+
{ "x": 192, "y": 344, "type": "file", "path": "scratchcpp-player.app" }
8+
]
9+
}

0 commit comments

Comments
 (0)