Debian Codegraph @

.github/workflows/build-macos.yml

raw
1 ---
2 name: macOS
3
4 on:
5 push:
6 branches: [master]
7 tags: ['v*']
8 pull_request:
9 branches: [master]
10
11
12 concurrency:
13 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14 cancel-in-progress: true
15
16 env:
17 QT_VERSION: '6.10.2'
18 KF_VERSION: '6.23'
19 KF_PATCH: '0'
20 KF_BRANCH: stable
21 QCA_VERSION: '2.3.10'
22 QTKEYCHAIN_VERSION: '0.15.0'
23
24 jobs:
25 build:
26 permissions:
27 contents: read
28 name: ${{matrix.buildname}}
29 runs-on: ${{matrix.os}}
30 strategy:
31 # Avoid canceling all jobs on transient failures.
32 fail-fast: false
33 matrix:
34 include:
35 - os: macos-15-intel
36 buildname: macOS 13
37 bundle_suffix: '-macos-13'
38 cmake_preset: macOS-13
39
40 - os: macos-14
41 buildname: macOS 12 M1
42 bundle_suffix: '-macos-12-m1'
43 cmake_preset: macOS-12-m1
44
45 steps:
46 - name: Checkout source code
47 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
48 with:
49 submodules: false
50 # Full commit history needed for sortable version string (git describe in CMake).
51 # Blobless filter skips file content for historical commits to speed up clone.
52 fetch-depth: 0
53 filter: blob:none
54 persist-credentials: false
55
56 - name: Enable ccache
57 uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
58 with:
59 key: ${{ github.job }}-${{ matrix.os }}
60 max-size: 1G
61
62 - name: Set up ccache
63 run: |
64 export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
65
66 - name: Install Qt
67 uses: jurplel/install-qt-action@48d3ad6db93f3627c8ee7a0454bc6f3744f7e730 # v4
68 with:
69 version: ${{ env.QT_VERSION }}
70 modules: qtimageformats qt5compat
71 cache: true
72 set-env: true
73
74 - name: Set up dependency paths
75 run: |
76 DEPS_PREFIX=$GITHUB_WORKSPACE/deps/install
77 # install-qt-action sets QT_ROOT_DIR but may not set CMAKE_PREFIX_PATH.
78 echo "DEPS_PREFIX=$DEPS_PREFIX" >> "$GITHUB_ENV"
79 echo "CMAKE_PREFIX_PATH=${DEPS_PREFIX};${QT_ROOT_DIR}" >> "$GITHUB_ENV"
80
81 - name: Restore cached dependencies
82 id: cache-deps
83 uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
84 with:
85 path: ${{ github.workspace }}/deps/install
86 key: >-
87 macos-deps-kf${{ env.KF_VERSION }}.${{ env.KF_PATCH
88 }}-qca${{ env.QCA_VERSION
89 }}-qtkeychain${{ env.QTKEYCHAIN_VERSION
90 }}-${{ runner.arch
91 }}-${{ hashFiles('utils/patches/**') }}
92
93 - name: Build dependencies
94 if: steps.cache-deps.outputs.cache-hit != 'true'
95 run: '${{ github.workspace }}/utils/github/build-macos-deps.sh'
96
97 - name: Save dependency cache
98 if: github.event_name == 'push'
99 uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
100 with:
101 path: ${{ github.workspace }}/deps/install
102 key: >-
103 macos-deps-kf${{ env.KF_VERSION }}.${{ env.KF_PATCH
104 }}-qca${{ env.QCA_VERSION
105 }}-qtkeychain${{ env.QTKEYCHAIN_VERSION
106 }}-${{ runner.arch
107 }}-${{ hashFiles('utils/patches/**') }}
108
109 - name: Download miniaudio
110 uses: ./.github/actions/download-miniaudio
111
112 - name: Build with CMake
113 run: |
114 cmake --preset '${{ matrix.cmake_preset }}'
115 cmake --build --preset '${{ matrix.cmake_preset }}'
116
117 - name: Create gnupg directory for tests
118 run: mkdir -p ~/.gnupg && chmod go-rwx ~/.gnupg
119
120 - name: Get version string
121 id: version
122 uses: ./.github/actions/get-version
123 with:
124 build_dir: ${{ github.workspace }}/build/copyq/${{ matrix.cmake_preset }}
125
126 - name: Create macOS bundle
127 working-directory: '${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}'
128 # Retry cpack due to frequent errors: "hdiutil: create failed - Resource busy"
129 run: (cpack || cpack || cpack) && mv -v copyq-*.dmg "CopyQ-${APP_VERSION}${BUNDLE_SUFFIX}.dmg"
130 env:
131 APP_VERSION: ${{ steps.version.outputs.version }}
132 BUNDLE_SUFFIX: ${{ matrix.bundle_suffix }}
133
134 - name: Upload macOS bundle
135 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
136 with:
137 name: 'CopyQ-${{ steps.version.outputs.version }}${{ matrix.bundle_suffix }}.dmg'
138 path: '${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}/CopyQ-${{ steps.version.outputs.version }}${{ matrix.bundle_suffix }}.dmg'
139 archive: false
140
141 - name: Test
142 working-directory: '${{github.workspace}}/build/copyq/${{ matrix.cmake_preset }}'
143 run: '${{github.workspace}}/utils/github/test-macos.sh'
144
145 - name: Upload crash reports
146 if: failure()
147 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
148 with:
149 name: 'crash-reports${{ matrix.bundle_suffix }}'
150 path: '~/Library/Logs/DiagnosticReports/*'
151 if-no-files-found: ignore
152
153
154 release:
155 if: startsWith(github.ref, 'refs/tags/v')
156 needs: build
157 runs-on: ubuntu-latest
158 permissions:
159 contents: write
160 steps:
161 - name: Download artifacts
162 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
163
164 - name: Upload to release
165 run: |
166 gh release create "$GITHUB_REF_NAME" --draft --notes "" 2>/dev/null || true
167 gh release upload "$GITHUB_REF_NAME" CopyQ-*/*.dmg --clobber
168 env:
169 GH_TOKEN: ${{ github.token }}
170 GH_REPO: ${{ github.repository }}