ci: Make artifact sanity checks non-fatal for now
[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       matrix:
21         dist: [ debian-stable, debian-testing, ubuntu-xenial, ubuntu-bionic, ubuntu-eoan, ubuntu-focal ]
22         cxx: [ gcc, clang++ ]
23         with-kde: [ -DWITH_KDE=ON ]
24         extra-options: [ -DWITH_WEBENGINE=ON ]
25         include:
26           # Baseline, test more combinations
27           - dist: ubuntu-xenial
28             with-kde: -DWITH_KDE=OFF
29             extra-options: -DWITH_WEBKIT=ON
30           - dist: ubuntu-xenial
31             with-kde: -DWITH_KDE=ON
32             extra-options: -DWITH_WEBKIT=ON
33         exclude:
34           # QtWebEngine is not available on Xenial
35           - dist: ubuntu-xenial
36             extra-options: -DWITH_WEBENGINE=ON
37     env:
38         CCACHE_BASEDIR: ${{ github.workspace }}
39         CCACHE_DIR: ${{ github.workspace }}/ccache
40         CCACHE_MAXSIZE: 100M
41
42     steps:
43     - name: Check out source code
44       uses: actions/checkout@v2
45
46     - name: Get timestamp
47       id: get-timestamp
48       run: echo "::set-output name=timestamp::$(date -u "+%F-%R")"
49
50     - name: Setup ccache
51       uses: actions/cache@v2
52       with:
53         path: ${{ github.workspace }}/ccache
54         key: ${{ matrix.dist }}-ccache-${{ steps.get-timestamp.outputs.timestamp }}
55         restore-keys: |
56              ${{ matrix.dist }}-ccache-
57
58     - name: Zero ccache stats
59       run: ccache -z
60
61     - name: Configure
62       run: |
63         mkdir build
64         cd build && cmake $GITHUB_WORKSPACE \
65                           -GNinja \
66                           -DCMAKE_BUILD_TYPE=Release \
67                           -DBUILD_TESTING=ON \
68                           -DFATAL_WARNINGS=ON \
69                           ${{ matrix.with-kde }} \
70                           ${{ matrix.extra-options }}
71
72     - name: Build
73       run: cd build && ninja
74
75     - name: Run tests
76       run: cd build && ctest
77
78     - name: Install
79       run: cd build && DESTDIR=$GITHUB_WORKSPACE/image ninja install
80
81     - name: Print ccache stats
82       run: ccache -s
83
84 # ------------------------------------------------------------------------------------------------------------------------------------------
85   build-macos:
86     name: macOS
87     runs-on: macos-latest
88     env:
89       CCACHE_BASEDIR: ${{ github.workspace }}
90       CCACHE_DIR: ${{ github.workspace }}/ccache
91       CCACHE_MAXSIZE: 100M
92
93     steps:
94     - name: Check out source code
95       uses: actions/checkout@v2
96       with:
97         fetch-depth: 0  # so git-describe works
98
99     - name: Fetch tag information
100       if: startsWith(github.ref, 'refs/tags/')
101       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
102
103     - name: Install dependencies
104       run: brew update && brew install boost ccache ninja qca qt5
105
106     - name: Get timestamp
107       id: get-timestamp
108       run: echo "::set-output name=timestamp::$(date -u "+%F-%R")"
109
110     - name: Setup ccache
111       uses: actions/cache@v2
112       with:
113         path: ${{ github.workspace }}/ccache
114         key: macos-ccache-${{ steps.get-timestamp.outputs.timestamp }}
115         restore-keys: |
116              macos-ccache-
117
118     - name: Zero ccache stats
119       run: ccache -z
120
121     - name: Configure
122       run: |
123         mkdir build
124         cd build && cmake $GITHUB_WORKSPACE \
125                           -GNinja \
126                           -DCMAKE_PREFIX_PATH=/usr/local/opt/qt/lib/cmake \
127                           -DCMAKE_BUILD_TYPE=Release \
128                           -DBUILD_TESTING=ON \
129                           -DFATAL_WARNINGS=OFF \
130                           -DDEPLOY=ON \
131                           -DENABLE_SHARED=OFF
132
133     - name: Build
134       run: |
135         # Deploy scripts require qmake in the path
136         export PATH=$PATH:/usr/local/opt/qt5/bin
137         cd build && ninja
138
139     - name: Run tests
140       run: cd build && ctest
141
142     - name: Install
143       run: cd build && DESTDIR=$GITHUB_WORKSPACE/image ninja install
144
145     - name: Print ccache stats
146       run: ccache -s
147
148     - name: Upload artifacts
149       uses: actions/upload-artifact@v2
150       with:
151         name: macOS
152         path: ${{ github.workspace }}/build/*.dmg
153
154 # ------------------------------------------------------------------------------------------------------------------------------------------
155   build-windows:
156     name: Windows
157     runs-on: windows-latest
158     env:
159       WORKSPACE: ${{ github.workspace }}
160       CRAFT: /C/CraftMaster/windows-msvc2019_64-cl/craft/bin/craft.py
161
162     steps:
163     - name: Check out source code
164       uses: actions/checkout@v2
165       with:
166         fetch-depth: 0  # so git-describe works
167
168     - name: Fetch tag information
169       if: startsWith(github.ref, 'refs/tags/')
170       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
171
172     - name: Clone CraftMaster
173       run: git clone --depth=1 https://invent.kde.org/kde/craftmaster.git /C/CraftMaster/CraftMaster
174
175     - name: Configure CraftMaster
176       run: python /C/CraftMaster/CraftMaster/CraftMaster.py --config $WORKSPACE/.craftsettings.ini --variables "WORKSPACE=$WORKSPACE"
177
178     - name: Add Quassel blueprint
179       run: python $CRAFT --add-blueprint-repository https://github.com/quassel/craft-blueprints-quassel.git
180
181     - name: Install NSIS
182       run: python $CRAFT dev-utils/nsis
183
184     - name: Install dependencies
185       run: python $CRAFT --install-deps quassel/quassel
186
187     - name: Build
188       run: python $CRAFT --no-cache --src-dir $WORKSPACE quassel/quassel
189
190     - name: Run tests
191       run: python $CRAFT --no-cache --src-dir $WORKSPACE --test quassel/quassel
192
193     - name: Package
194       run: python $CRAFT --no-cache --src-dir $WORKSPACE --package quassel/quassel
195
196     - name: Upload artifacts
197       uses: actions/upload-artifact@v2
198       with:
199         name: Windows
200         path: ${{ github.workspace }}/packages/*
201
202 # ------------------------------------------------------------------------------------------------------------------------------------------
203   post-build:
204     name: Post-Build
205     runs-on: ubuntu-latest
206     needs: [ build-linux, build-macos, build-windows ]
207     env:
208       GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
209
210     steps:
211     - name: Check out source code
212       uses: actions/checkout@v2
213
214     - name: Fetch tag information
215       if: startsWith(github.ref, 'refs/tags/')
216       run: git fetch -f origin $GITHUB_REF:$GITHUB_REF
217
218     - name: Download artifacts
219       uses: actions/download-artifact@v2
220       with:
221         path: artifacts
222
223     - name: List artifacts
224       run: ls -lhR artifacts
225
226     - name: Check artifacts
227       continue-on-error: true # macOS packaging is unreliable
228       run: |
229         # Sanity check: We should have exactly 5 files matching the given patterns
230         [[ 5 -eq $(find artifacts/ \( -type f -name 'Quassel*.dmg' -o -name 'quassel*.exe' -o -name 'quassel*.7z' \) -printf '.' | wc -c) ]]
231
232     - name: Create release notes
233       if: startsWith(github.ref, 'refs/tags/')
234       run: |
235         # Use the tag's annotation as release notes
236         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
237         MESSAGE=$(git tag -l --format='%(contents)' $TAGNAME | perl -ne 'print if not /-----BEGIN PGP SIGNATURE-----/../-----END PGP SIGNATURE-----/')
238         echo -e "Quassel $TAGNAME\n\n$MESSAGE" > release_notes.txt
239
240     - name: Prepare source archive
241       if: startsWith(github.ref, 'refs/tags/')
242       run: |
243         mkdir assets
244         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
245         git archive --format=tar --prefix=quassel-$TAGNAME/ $TAGNAME | xz > assets/quassel-$TAGNAME.tar.xz
246
247     - name: Prepare packages for release
248       if: startsWith(github.ref, 'refs/tags/')
249       run: |
250         TAGNAME=$(git rev-parse --abbrev-ref $GITHUB_REF)
251         for type in Client Core Mono; do
252           mv artifacts/macOS/Quassel$type*.dmg assets/Quassel$type-macOS-$TAGNAME.dmg
253         done
254         mv artifacts/Windows/quassel-*.exe assets/quassel-windows-setup-$TAGNAME.exe
255         mv artifacts/Windows/quassel-*.7z assets/quassel-windows-$TAGNAME.7z
256
257     - name: Create checksums for release assets
258       if: startsWith(github.ref, 'refs/tags/')
259       run: find assets/ -type f -execdir sh -c 'sha256sum "$1" > "$1.sha256sum"' _ {} \;
260
261     - name: Create draft release
262       if: startsWith(github.ref, 'refs/tags/')
263       run: |
264         # The stock upload-release-asset action can only handle single files
265         # Instead, use the hub utility so we can upload all assets at once
266         assets=()
267         for asset in assets/*; do assets+=("-a" "$asset"); done
268         hub release create -d "${assets[@]}" -F release_notes.txt `git rev-parse --abbrev-ref $GITHUB_REF`