ci: Find Qt5 again on macOS
[quassel.git] / .github / workflows / main.yml
1 # Workflow that builds Quassel on various Linux distros, and creates packages for both Windows and macOS.
2 # For tagged pushes, a draft release is automatically created, using the tag message as release description
3 # and attaching Windows and macOS builds, as well as the source archive.
4 name: Quassel CI
5
6 on: [ push, pull_request ]
7
8 defaults:
9   run:
10     shell: bash
11
12 jobs:
13
14 # ------------------------------------------------------------------------------------------------------------------------------------------
15   build-linux:
16     name: Linux
17     runs-on: ubuntu-latest
18     container: quassel/quassel-build-env:${{ matrix.dist }}
19     strategy:
20       fail-fast: false
21       matrix:
22         dist: [ debian-stable, debian-testing, ubuntu-xenial, ubuntu-bionic, ubuntu-focal, ubuntu-groovy ]
23         cxx: [ 'g++', 'clang++' ]
24         with-kde: [ -DWITH_KDE=ON ]
25         extra-options: [ -DWITH_WEBENGINE=ON ]
26         include:
27           # Baseline, test more combinations
28           - dist: ubuntu-xenial
29             with-kde: -DWITH_KDE=OFF
30             extra-options: -DWITH_WEBKIT=ON
31           - dist: ubuntu-xenial
32             with-kde: -DWITH_KDE=ON
33             extra-options: -DWITH_WEBKIT=ON
34         exclude:
35           # QtWebEngine is not available on Xenial
36           - dist: ubuntu-xenial
37             extra-options: -DWITH_WEBENGINE=ON
38     env:
39         CCACHE_BASEDIR: ${{ github.workspace }}
40         CCACHE_DIR: ${{ github.workspace }}/ccache
41         CCACHE_MAXSIZE: 100M
42         CXX: ${{ matrix.cxx }}
43
44     steps:
45     - name: Check out source code
46       uses: actions/checkout@v2
47
48     - name: Get timestamp
49       id: get-timestamp
50       run: echo "::set-output name=timestamp::$(date -u "+%F-%R")"
51
52     - name: Setup ccache
53       uses: actions/cache@v2
54       with:
55         path: ${{ github.workspace }}/ccache
56         key: ${{ matrix.dist }}-ccache-${{ steps.get-timestamp.outputs.timestamp }}
57         restore-keys: |
58              ${{ matrix.dist }}-ccache-
59
60     - name: Zero ccache stats
61       run: ccache -z
62
63     - name: Configure
64       run: |
65         mkdir build
66         cd build && cmake $GITHUB_WORKSPACE \
67                           -GNinja \
68                           -DCMAKE_BUILD_TYPE=Release \
69                           -DBUILD_TESTING=ON \
70                           -DFATAL_WARNINGS=ON \
71                           ${{ matrix.with-kde }} \
72                           ${{ matrix.extra-options }}
73
74     - name: Build
75       run: cd build && ninja
76
77     - name: Run tests
78       run: cd build && ctest
79
80     - name: Install
81       run: cd build && DESTDIR=$GITHUB_WORKSPACE/image ninja install
82
83     - name: Print ccache stats
84       run: ccache -s
85
86 # ------------------------------------------------------------------------------------------------------------------------------------------
87   build-macos:
88     name: macOS
89     runs-on: macos-latest
90     env:
91       CCACHE_BASEDIR: ${{ github.workspace }}
92       CCACHE_DIR: ${{ github.workspace }}/ccache
93       CCACHE_MAXSIZE: 100M
94
95     steps:
96     - name: Select Xcode version
97       uses: maxim-lobanov/setup-xcode@v1
98       with:
99         # Newer Xcode versions may not officially be supported by Qt
100         xcode-version: '10.3'
101
102     - name: Check out source code
103       uses: actions/checkout@v2
104       with:
105         fetch-depth: 0  # so git-describe works
106
107     - name: Fetch tag information
108       if: startsWith(github.ref, 'refs/tags/')
109       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
110
111     - name: Install dependencies
112       # Skip "brew update" as it can trigger 50+ minutes of updating.
113       # GitHub Actions intentionally disables the default auto-update on their
114       # macOS CI images (and macOS CI images usually update once a week).
115       #
116       # See https://github.com/actions/virtual-environments/issues/2173
117       # > We've set no auto-update intentionally here [...]
118       # And https://github.com/microsoft/appcenter/issues/293
119       #
120       # If Homebrew begins failing in the future due to out-of-date versions,
121       # it can be re-enabled here as follows...
122       # run: brew update && [below command]
123       run: brew install boost ccache ninja qca qt@5
124
125     - name: Get timestamp
126       id: get-timestamp
127       run: echo "::set-output name=timestamp::$(date -u "+%F-%R")"
128
129     - name: Setup ccache
130       uses: actions/cache@v2
131       with:
132         path: ${{ github.workspace }}/ccache
133         key: macos-ccache-${{ steps.get-timestamp.outputs.timestamp }}
134         restore-keys: |
135              macos-ccache-
136
137     - name: Zero ccache stats
138       run: ccache -z
139
140     - name: Configure
141       run: |
142         mkdir build
143         cd build && cmake $GITHUB_WORKSPACE \
144                           -GNinja \
145                           -DWANT_CORE=ON \
146                           -DWANT_QTCLIENT=ON \
147                           -DWANT_MONO=ON \
148                           -DCMAKE_PREFIX_PATH=$(brew --prefix)/opt/qt@5 \
149                           -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/bundles \
150                           -DCMAKE_BUILD_TYPE=Release \
151                           -DBUILD_TESTING=ON \
152                           -DFATAL_WARNINGS=OFF \
153                           -DENABLE_SHARED=OFF \
154                           -DBUNDLE=ON \
155
156     - name: Build
157       run: cd build && ninja
158
159     - name: Run tests
160       run: cd build && ctest
161
162     - name: Install
163       run: cd build && ninja install
164
165     - name: Print ccache stats
166       run: ccache -s
167
168     - name: Upload artifacts
169       uses: actions/upload-artifact@v2
170       with:
171         name: macOS
172         path: ${{ github.workspace }}/bundles/*.dmg
173
174 # ------------------------------------------------------------------------------------------------------------------------------------------
175   build-windows:
176     name: Windows
177     runs-on: windows-latest
178     env:
179       WORKSPACE: ${{ github.workspace }}
180       CRAFT: /C/CraftMaster/windows-msvc2019_64-cl/craft/bin/craft.py
181
182     steps:
183     - name: Check out source code
184       uses: actions/checkout@v2
185       with:
186         fetch-depth: 0  # so git-describe works
187
188     - name: Fetch tag information
189       if: startsWith(github.ref, 'refs/tags/')
190       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
191
192     - name: Clone CraftMaster
193       run: git clone --depth=1 https://invent.kde.org/kde/craftmaster.git /C/CraftMaster/CraftMaster
194
195     - name: Configure CraftMaster
196       run: python /C/CraftMaster/CraftMaster/CraftMaster.py --config $WORKSPACE/.craftsettings.ini --variables "WORKSPACE=$WORKSPACE"
197
198     - name: Add Quassel blueprint
199       run: python $CRAFT --add-blueprint-repository https://github.com/quassel/craft-blueprints-quassel.git
200
201     - name: Install NSIS
202       run: python $CRAFT dev-utils/nsis
203
204     - name: Install dependencies
205       run: python $CRAFT --install-deps quassel/quassel
206
207     - name: Build
208       run: python $CRAFT --no-cache --src-dir $WORKSPACE quassel/quassel
209
210     - name: Run tests
211       run: python $CRAFT --no-cache --src-dir $WORKSPACE --test quassel/quassel
212
213     - name: Package
214       run: python $CRAFT --no-cache --src-dir $WORKSPACE --package quassel/quassel
215
216     - name: Upload artifacts
217       uses: actions/upload-artifact@v2
218       with:
219         name: Windows
220         path: ${{ github.workspace }}/packages/*
221
222 # ------------------------------------------------------------------------------------------------------------------------------------------
223   post-build:
224     name: Post-Build
225     runs-on: ubuntu-latest
226     needs: [ build-linux, build-macos, build-windows ]
227     env:
228       GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
229
230     steps:
231     - name: Check out source code
232       uses: actions/checkout@v2
233
234     - name: Fetch tag information
235       if: startsWith(github.ref, 'refs/tags/')
236       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
237
238     - name: Download artifacts
239       uses: actions/download-artifact@v2
240       with:
241         path: artifacts
242
243     - name: List artifacts
244       run: ls -lhR artifacts
245
246     - name: Check artifacts
247       run: |
248         # Sanity check: We should have exactly 5 files matching the given patterns
249         [[ 5 -eq $(find artifacts/ \( -type f -name 'Quassel*.dmg' -o -name 'quassel*.exe' -o -name 'quassel*.7z' \) -printf '.' | wc -c) ]]
250
251     - name: Create release notes
252       if: startsWith(github.ref, 'refs/tags/')
253       run: |
254         # Use the tag's annotation as release notes
255         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
256         MESSAGE=$(git tag -l --format='%(contents)' $TAGNAME | perl -ne 'print if not /-----BEGIN PGP SIGNATURE-----/../-----END PGP SIGNATURE-----/')
257         echo -e "Quassel $TAGNAME\n\n$MESSAGE" > release_notes.txt
258
259     - name: Prepare source archive
260       if: startsWith(github.ref, 'refs/tags/')
261       run: |
262         mkdir assets
263         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
264         git archive --format=tar --prefix=quassel-$TAGNAME/ $TAGNAME | xz > assets/quassel-$TAGNAME.tar.xz
265
266     - name: Prepare packages for release
267       if: startsWith(github.ref, 'refs/tags/')
268       run: |
269         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
270         for type in Client Core Mono; do
271           mv artifacts/macOS/Quassel$type*.dmg assets/Quassel$type-macOS-$TAGNAME.dmg
272         done
273         mv artifacts/Windows/quassel-*.exe assets/quassel-windows-setup-$TAGNAME.exe
274         mv artifacts/Windows/quassel-*.7z assets/quassel-windows-$TAGNAME.7z
275
276     - name: Create checksums for release assets
277       if: startsWith(github.ref, 'refs/tags/')
278       run: find assets/ -type f -execdir sh -c 'sha256sum "$1" > "$1.sha256sum"' _ {} \;
279
280     - name: Create draft release
281       if: startsWith(github.ref, 'refs/tags/')
282       run: |
283         # The stock upload-release-asset action can only handle single files
284         # Instead, use the hub utility so we can upload all assets at once
285         assets=()
286         for asset in assets/*; do assets+=("-a" "$asset"); done
287         hub release create -d "${assets[@]}" -F release_notes.txt `git rev-parse --abbrev-ref $GITHUB_REF`