forked from gyunaev/birdtray
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (164 loc) · 6.63 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build
on: [push, pull_request]
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
arch: [x86, x64]
qt_version: [5.9.9, 5.15.2]
include:
- os: windows-latest
arch: x86
qt_compile_suite: win32_msvc2019
- os: windows-latest
arch: x64
qt_compile_suite: win64_msvc2019_64
exclude:
# We only want to test for the latest version of Qt on Windows
- os: windows-latest
qt_version: 5.9.9
# We only compile for the current architecture of the runner for Linux
- os: ubuntu-latest
arch: x86
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Qt ${{ matrix.qt_version }}
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_version }}
arch: ${{ matrix.qt_compile_suite }}
cache: true
dir: ${{ runner.temp }}/Qt
- name: Install additional dependencies
shell: bash
env:
ARCH: ${{ matrix.arch }}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update -qq;
sudo apt install -qq libx11-dev libqt5svg5-dev libx11-xcb-dev desktop-file-utils appstream-util
elif [ "$RUNNER_OS" == "Windows" ]; then
if [ "$ARCH" == "x86" ]; then
echo "CMAKE_PLATFORM_ARG=-A Win32" >> $GITHUB_ENV
export archParam="--forcex86"
else
echo "CMAKE_PLATFORM_ARG=-A x64" >> $GITHUB_ENV
fi
choco install -y --force $archParam openssl.light --version=1.1.1
echo "C:\\Program Files\\OpenSSL" >> $GITHUB_PATH
else
echo "$RUNNER_OS not supported"
exit 1
fi
- name: Create build environment
run: cmake -E make_directory ${{ runner.workspace }}/build
- name: Configure CMake
shell: bash
working-directory: ${{ runner.workspace }}/build
run: cmake $GITHUB_WORKSPACE $CMAKE_PLATFORM_ARG -DCMAKE_BUILD_TYPE=Release -DCOMPILER_WARNINGS_AS_ERRORS=ON -DBUILD_WITH_TESTS=ON -DDONT_EXECUTE_INSTALLER=ON
- name: Register build problem matchers
run: |
echo "::add-matcher::.github/problem-matchers/linguist.json"
echo "::add-matcher::.github/problem-matchers/compiler.json"
- name: Build
working-directory: ${{ runner.workspace }}/build
run: cmake --build . --config Release --target birdtray
- name: Remove build problem matchers
run: |
echo "::remove-matcher owner=linguist::"
echo "::remove-matcher owner=linguist-old::"
echo "::remove-matcher owner=compiler-gcc::"
echo "::remove-matcher owner=compiler-msvc::"
- name: Tests
working-directory: ${{runner.workspace}}/build
run: cmake --build . --config Release --target tests && cmake --build . --config Release --target run_tests
- name: Validate desktop file and app metadata
working-directory: ${{ github.workspace }}
if: runner.os == 'Linux'
shell: bash
run: |
output=$(desktop-file-validate src/res/com.ulduzsoft.Birdtray.desktop)
if [ ! -z "$output" ]; then
echo "$output";
exit 1;
fi
appstream-util validate src/res/com.ulduzsoft.Birdtray.appdata.xml
- name: Check if this is a deployment build
id: check-deploy
shell: bash
run: |
if [[ '${{ github.event.ref }}' =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ && "$RUNNER_OS" == "Windows" ]]; then
echo "is_deploy=true" >> $GITHUB_OUTPUT
echo "Deployment build detected"
else
echo "Not a deployment build, skipping deploy steps"
fi
- name: Install installer dependencies
if: steps.check-deploy.outputs.is_deploy == 'true'
run: choco install -y nsis --version=3.6.1;
- name: Create installer
if: steps.check-deploy.outputs.is_deploy == 'true'
working-directory: ${{ runner.workspace }}/build
run: cmake --build . --config Release --target install
- name: Find installer
if: steps.check-deploy.outputs.is_deploy == 'true'
id: find_installer_file
shell: bash
run: |
installerFile=`find . -name "Birdtray-*.exe" -exec basename {} \;`
echo "installer_file=$installerFile" >> $GITHUB_OUTPUT
echo "Found installer: $installerFile"
mkdir installer/cache
mv installer/$installerFile installer/cache
- name: Cache installer
uses: actions/upload-artifact@v3
if: steps.check-deploy.outputs.is_deploy == 'true'
with:
name: installer-${{ runner.os }}-${{ matrix.arch }}-${{ github.sha }}
path: installer/cache/${{ steps.find_installer_file.outputs.installer_file }}
release:
name: Create Release
needs: build
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && contains(github.ref, '.')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check if this is a deployment build
id: deploy_check
shell: bash
run: |
if [[ '${{ github.event.ref }}' =~ ^refs/tags/(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "Creating release ${BASH_REMATCH[1]}..."
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo "Tag does not match: ${{ github.event.ref }}"
exit 1
fi
- name: Verify that the app metadata contains the release
shell: bash
run: |
grep "version=\"${{ steps.deploy_check.outputs.version }}\"" src/res/com.ulduzsoft.Birdtray.appdata.xml -q || (echo "Version not found in src/res/com.ulduzsoft.Birdtray.appdata.xml"; exit 1)
- name: Download installer (x86)
uses: actions/download-artifact@v3
with:
name: installer-Windows-x86-${{ github.sha }}
path: installer-x86
- name: Download installer (x64)
uses: actions/download-artifact@v3
with:
name: installer-Windows-x64-${{ github.sha }}
path: installer-x64
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: Release ${{ steps.deploy_check.outputs.version }}
draft: true
artifacts: installer*/Birdtray-*.exe
artifactContentType: application/x-msdownload
artifactErrorsFailBuild: true
generateReleaseNotes: true