Skip to content

Commit adc4fdb

Browse files
committed
feat(ci): macos workflow
1 parent 5dc0879 commit adc4fdb

File tree

3 files changed

+157
-3
lines changed

3 files changed

+157
-3
lines changed

.github/workflows/linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ on:
77
paths-ignore:
88
- .github/workflows/docker.yml
99
- .github/workflows/windows.yml
10+
- .github/workflows/macos.yml
1011
pull_request:
1112
branches:
1213
- main
1314
paths-ignore:
1415
- .github/workflows/docker.yml
1516
- .github/workflows/windows.yml
17+
- .github/workflows/macos.yml
1618

1719
jobs:
1820
build:

.github/workflows/macos.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: macOS workflow
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths-ignore:
9+
- .github/workflows/docker.yml
10+
- .github/workflows/linux.yml
11+
- .github/workflows/windows.yml
12+
pull_request:
13+
branches:
14+
- main
15+
paths-ignore:
16+
- .github/workflows/docker.yml
17+
- .github/workflows/linux.yml
18+
- .github/workflows/windows.yml
19+
20+
jobs:
21+
build:
22+
runs-on: ${{ matrix.runner.name }}
23+
name: build (${{ matrix.config.type }}, ${{ matrix.runner.arch }})
24+
strategy:
25+
max-parallel: 1
26+
matrix:
27+
runner:
28+
- name: macos-15-intel # github-hosted runner name
29+
packages: qtbase qtimageformats quazip exiv2 ffmpeg wget
30+
arch: intel
31+
arch_flags:
32+
homebrew-opt: "/usr/local/opt" # root of qt_dir
33+
34+
- name: macos-15
35+
packages: qtbase qtimageformats quazip exiv2 ffmpeg wget
36+
arch: arm64
37+
arch_flags:
38+
homebrew-opt: "/opt/homebrew/opt"
39+
40+
config:
41+
- type: full
42+
packages: extra-cmake-modules karchive jpeg-xl libraw libde265 jxrlib libavif
43+
flags: ""
44+
kimageformats: true # compile kimageformat-plugins
45+
opencv: true # compile a minimal opencv
46+
portable: true # build portable folder
47+
artifacts: true # upload artifacts
48+
release: true # TODO: publish release
49+
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 0 # ensure full history for git rev-parse
54+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
55+
56+
- name: Get System Info
57+
id: get_info
58+
run: |
59+
COMPILER_ID=$(echo $(c++ --version) $(realpath $(xcrun --show-sdk-path)))
60+
SCRIPTS_ID=$(cat docker/*env docker/*.sh docker/*.diff | sha256)
61+
OPENCV_KEY=$(echo $COMPILER_ID $OPENCV_ID | sha256)
62+
KIF_KEY=$(echo $COMPILER_ID $SCRIPTS_ID | sha256)
63+
echo "Compiler: $COMPILER_ID"
64+
echo "OpenCV: $OPENCV_ID"
65+
echo "OpenCV Cache Key: $OPENCV_KEY"
66+
echo "OPENCV_KEY=${OPENCV_KEY}" >> $GITHUB_OUTPUT
67+
echo "KIF_KEY=${KIF_KEY}" >> $GITHUB_OUTPUT
68+
69+
- name: Setup Cache
70+
run: |
71+
# we must install things to /opt for packaging script to work, but cache@v4 won't write there
72+
# note this location is hardcoded to docker/macos.env
73+
sudo mkdir /opt/opencv2 /opt/kimageformats
74+
sudo chown $USER:$(id -gn) /opt/opencv2 /opt/kimageformats
75+
76+
- name: Install Packages
77+
run: |
78+
brew install --quiet --force-bottle ${{ matrix.runner.packages }} ${{ matrix.config.packages }}
79+
80+
- name: Cache opencv
81+
id: cache_opencv
82+
if: matrix.config.opencv
83+
uses: actions/cache@v4
84+
with:
85+
path: /opt/opencv2
86+
key: ${{ runner.os }}-opencv-${{ steps.get_info.outputs.OPENCV_KEY }}
87+
88+
- name: Build opencv
89+
if: matrix.config.opencv && steps.cache_opencv.outputs.cache-hit != 'true'
90+
shell: bash
91+
run: |
92+
cd ${GITHUB_WORKSPACE}/docker
93+
shopt -s expand_aliases
94+
source macos.env
95+
./build-opencv.sh
96+
97+
- name: Cache kimageformats
98+
id: cache_kimageformats
99+
if: matrix.config.opencv
100+
uses: actions/cache@v4
101+
with:
102+
path: /opt/kimageformats
103+
key: ${{ runner.os }}-kimageformats-${{ steps.get_info.outputs.KIF_KEY }}
104+
105+
- name: Build kimageformats
106+
if: matrix.config.kimageformats && steps.cache_kimageformats.outputs.cache-hit != 'true'
107+
shell: bash
108+
run: |
109+
cd ${GITHUB_WORKSPACE}/docker
110+
shopt -s expand_aliases
111+
source macos.env
112+
./build-kimageformats.sh
113+
114+
- name: Configure
115+
shell: bash
116+
run: |
117+
cd ${GITHUB_WORKSPACE}
118+
shopt -s expand_aliases
119+
source docker/macos.env
120+
qmake6
121+
make _mac/git.h
122+
123+
- name: Get Build Version
124+
id: get_version
125+
run: |
126+
cd ${GITHUB_WORKSPACE}/
127+
ARCH=$(uname -m)
128+
OS="$(sw_vers -productName)-$(sw_vers -productVersion)"
129+
SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.sha }})
130+
VERSION=$(cat _mac/git.h | grep CBIRD_VERSION | sed 's/[^0-9\.]*//g')
131+
echo "VERSION=${VERSION}-${SHA}-${OS}-${ARCH}" >> $GITHUB_OUTPUT
132+
133+
- name: Build
134+
run: |
135+
cd ${GITHUB_WORKSPACE}/
136+
make -j$(nproc)
137+
138+
- name: Make Portable Bundle
139+
if: matrix.config.portable
140+
run: |
141+
cd ${GITHUB_WORKSPACE}/
142+
make portable
143+
144+
- name: Upload Artifacts
145+
if: matrix.config.artifacts
146+
uses: actions/upload-artifact@v4
147+
with:
148+
name: "cbird-${{ steps.get_version.outputs.VERSION }}-${{ matrix.config.type }}"
149+
path: _mac/cbird-mac
150+
retention-days: 30

.github/workflows/windows.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ on:
66
- main
77
paths-ignore:
88
- .github/workflows/docker.yml
9-
- .github/workflows/windows.yml
9+
- .github/workflows/linux.yml
10+
- .github/workflows/macos.yml
1011
pull_request:
1112
branches:
1213
- main
1314
paths-ignore:
1415
- .github/workflows/docker.yml
15-
- .github/workflows/windows.yml
16+
- .github/workflows/linux.yml
17+
- .github/workflows/macos.yml
1618

1719
jobs:
1820
build:
@@ -82,7 +84,7 @@ jobs:
8284
shell: bash
8385
run: |
8486
shopt -s expand_aliases
85-
source /build/mxe.env
87+
source /build/mxe.env # TODO: =>build.env after rebuilding docker image
8688
export HOME="$PWD/home"
8789
export WINEPREFIX="$PWD/wineprefix"
8890
mkdir -p "$HOME" "$WINEPREFIX"

0 commit comments

Comments
 (0)