Skip to content

Commit 9c77228

Browse files
committed
ci: add macOS DMG build workflow
Add GitHub Actions workflow for building macOS DMG package with Qt6 using aqtinstall and macdeployqt.
1 parent b14bda3 commit 9c77228

1 file changed

Lines changed: 149 additions & 0 deletions

File tree

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Build macOS DMG (Qt6, Universal)
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'Checkout branch'
11+
required: false
12+
default: 'dev'
13+
tag:
14+
description: 'Checkout tag'
15+
required: false
16+
17+
permissions:
18+
contents: write
19+
20+
jobs:
21+
build-omodsim:
22+
name: Build OpenModSim macOS DMG version '${{ github.event.inputs.tag || github.event.inputs.branch || github.ref_name }}' with Qt6
23+
runs-on: macos-latest
24+
25+
env:
26+
QT_VERSION: "6.9.3"
27+
QT_HOST: "mac"
28+
QT_TARGET: "desktop"
29+
QT_ARCH: "clang_64"
30+
QT_INSTALL_DIR: "${{ github.workspace }}/Qt"
31+
CMAKE_GENERATOR: "Ninja"
32+
BUILD_TYPE: "Release"
33+
DMG_PACKAGE_NAME: "qt6-omodsim"
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
with:
39+
ref: ${{ github.event.inputs.tag || github.event.inputs.branch || github.ref_name }}
40+
41+
- name: Determine ref_type and ref_name
42+
run: |
43+
if [ "${{ github.ref_type }}" = "tag" ] || [ -n "${{ github.event.inputs.tag }}" ]; then
44+
REF_TYPE="tags"
45+
if [ -n "${{ github.event.inputs.tag }}" ]; then
46+
REF_NAME="${{ github.event.inputs.tag }}"
47+
else
48+
REF_NAME="${{ github.ref_name }}"
49+
fi
50+
else
51+
REF_TYPE="heads"
52+
REF_NAME="${{ github.ref_name }}"
53+
fi
54+
echo "REF_TYPE=$REF_TYPE" >> $GITHUB_ENV
55+
echo "REF_NAME=$REF_NAME" >> $GITHUB_ENV
56+
57+
- name: Extract version from CMakeLists.txt
58+
run: |
59+
FULL_VERSION=$(grep -oE 'VERSION\s+[0-9]+\.[0-9]+\.[0-9]+' src/CMakeLists.txt | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
60+
61+
if [ "${GITHUB_REF_NAME}" = "dev" ] || [ "${{ github.event.inputs.branch }}" = "dev" ]; then
62+
MAJOR_MINOR=$(echo "$FULL_VERSION" | cut -d. -f1,2)
63+
APP_VERSION="${MAJOR_MINOR}~dev"
64+
else
65+
APP_VERSION="$FULL_VERSION"
66+
fi
67+
68+
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
69+
echo "Extracted version: $APP_VERSION"
70+
71+
- name: Install dependencies
72+
run: |
73+
brew install ninja cmake
74+
75+
- name: Install Python (for aqtinstall)
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: "3.12"
79+
80+
- name: Install aqtinstall
81+
run: python -m pip install aqtinstall
82+
83+
- name: Download Qt
84+
run: |
85+
mkdir -p ${{ env.QT_INSTALL_DIR }}
86+
aqt install-qt \
87+
${{ env.QT_HOST }} \
88+
${{ env.QT_TARGET }} \
89+
${{ env.QT_VERSION }} \
90+
${{ env.QT_ARCH }} \
91+
-m qt5compat qtpdf qtserialport qtserialbus \
92+
-O ${{ env.QT_INSTALL_DIR }}
93+
94+
- name: Add Qt to PATH
95+
run: echo "${{ env.QT_INSTALL_DIR }}/${{ env.QT_VERSION }}/macos/bin" >> $GITHUB_PATH
96+
97+
- name: Set BUILD_DIR
98+
run: echo "BUILD_DIR=build-omodsim-Qt_${{ env.QT_VERSION }}_clang_64-${{ env.BUILD_TYPE }}" >> $GITHUB_ENV
99+
100+
- name: Configure project
101+
run: |
102+
cmake src -B ${{ env.BUILD_DIR }} \
103+
-G "${{ env.CMAKE_GENERATOR }}" \
104+
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
105+
-DCMAKE_PREFIX_PATH=${{ env.QT_INSTALL_DIR }}/${{ env.QT_VERSION }}/macos \
106+
-DUSE_QT6=ON
107+
108+
- name: Build
109+
run: cmake --build ${{ env.BUILD_DIR }} --config ${{ env.BUILD_TYPE }} --parallel
110+
111+
- name: Deploy Qt dependencies using macdeployqt
112+
run: |
113+
"${{ env.QT_INSTALL_DIR }}/${{ env.QT_VERSION }}/macos/bin/macdeployqt" \
114+
"${{ env.BUILD_DIR }}/omodsim.app" \
115+
-always-overwrite
116+
117+
- name: Copy docs into app bundle
118+
run: |
119+
mkdir -p "${{ env.BUILD_DIR }}/omodsim.app/Contents/Resources/docs"
120+
cp -R "${{ env.BUILD_DIR }}/docs/"* "${{ env.BUILD_DIR }}/omodsim.app/Contents/Resources/docs/"
121+
122+
- name: Create DMG
123+
run: |
124+
DMG_NAME="${{ env.DMG_PACKAGE_NAME }}_${{ env.APP_VERSION }}_macos.dmg"
125+
echo "DMG_NAME=$DMG_NAME" >> $GITHUB_ENV
126+
127+
hdiutil create -volname "Open ModSim ${{ env.APP_VERSION }}" \
128+
-srcfolder "${{ env.BUILD_DIR }}/omodsim.app" \
129+
-ov -format UDZO \
130+
"$DMG_NAME"
131+
132+
- name: Upload DMG
133+
uses: actions/upload-artifact@v4
134+
if: success()
135+
with:
136+
name: ${{ env.DMG_NAME }}
137+
path: ${{ env.DMG_NAME }}
138+
139+
- name: Create or update GitHub Release and upload DMG
140+
if: success() && github.event_name == 'push' && github.ref_type == 'tag'
141+
uses: softprops/action-gh-release@v2
142+
with:
143+
draft: true
144+
tag_name: ${{ github.ref_name }}
145+
name: Open ModSim ${{ env.APP_VERSION }}
146+
files: |
147+
${{ env.DMG_NAME }}
148+
env:
149+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)