forked from sqlitebrowser/sqlitebrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
361 lines (352 loc) · 17.4 KB
/
cppcmake.yml
File metadata and controls
361 lines (352 loc) · 17.4 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: CI
on:
push:
branches: [ master ]
tags:
pull_request:
release:
types: [ created ]
workflow_dispatch:
jobs:
appimage:
if: github.event_name != 'pull_request'
name: appimage (${{ matrix.os }} - SQLCipher ${{ matrix.sqlcipher }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04]
sqlcipher: ["0", "1"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run : |
sudo apt-get update
sudo apt install libqcustomplot-dev libqt5scintilla2-dev libqt5svg5 libsqlcipher-dev libsqlite3-dev qttools5-dev
- name: Build SQLite
if: matrix.sqlcipher == '0'
run: |
TARBALL=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 3)
SHA3=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 5)
curl -LsS -o sqlite.tar.gz https://sqlite.org/${TARBALL}
VERIFY=$(openssl dgst -sha3-256 sqlite.tar.gz | cut -d ' ' -f 2)
if [ "$SHA3" != "$VERIFY" ]; then exit 1 ; fi
tar -xzf sqlite.tar.gz
cd sqlite-autoconf-*
CPPFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_MAX_ATTACHED=125 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_SNAPSHOT=1" ./configure --enable-shared=no
make -j2
sudo make install -j2
- name: Configure CMake
run: |
mkdir appbuild && mkdir appdir && cd appbuild
cmake -DCMAKE_INSTALL_PREFIX:PATH=../appdir/usr -Wno-dev -DFORCE_INTERNAL_QSCINTILLA=ON -Dsqlcipher=${{ matrix.sqlcipher }} ..
- name: Run make
working-directory: ./appbuild
run: make install -j2
- name: Build AppImage
run: |
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
export VERSION=$(printf "dev-`git -C . rev-parse --short HEAD`")
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -appimage
- name: Rename AppImage
if: matrix.sqlcipher == '1'
run: |
export FILE=$(ls DB_Browser_for_SQLite*.AppImage)
export FILE=${FILE/SQLite/SQLCipher}
mv DB_Browser_for_SQLite*.AppImage $FILE
- name: Archive AppImage
run: tar -cvf appimage.tar DB_Browser_for_*.AppImage
- name: Upload AppImage
uses: actions/upload-artifact@v3
with:
name: appimage
path: appimage.tar
build-macos:
name: build (${{ matrix.os }} - SQLCipher ${{ matrix.sqlcipher }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [macos-12]
sqlcipher: ["0", "1"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run : |
unset HOMEBREW_NO_INSTALL_FROM_API; brew untap homebrew/core; brew untap homebrew/cask; brew update
brew tap sqlitebrowser/sqlite3
brew install cmake qt@5 sqlitefts5
if [ "${{ matrix.sqlcipher }}" = "1" ]; then
brew install sqlcipherdb4s
fi
brew link sqlitefts5 --force
- name: Configure Build
env:
IS_SQLCIPHER: ${{ matrix.sqlcipher }}
run: |
if [ "${{ matrix.sqlcipher }}" = "1" ]; then
sed -i "" 's/"DB Browser for SQLite"/"DB Browser for SQLCipher-dev-'$(git rev-parse --short --verify HEAD)'"/' CMakeLists.txt
else
sed -i "" 's/"DB Browser for SQLite"/"DB Browser for SQLite-dev-'$(git rev-parse --short --verify HEAD)'"/' CMakeLists.txt
fi
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 -Dsqlcipher=${{ matrix.sqlcipher }} ..
- name: Build
working-directory: ./build
run: make -j3
- name: Build extensions
run: |
clang -I /usr/local/opt/sqlitefts5/include -L /usr/local/opt/sqlitefts5/lib -fno-common -dynamiclib src/extensions/extension-formats.c
clang -I /usr/local/opt/sqlitefts5/include -L /usr/local/opt/sqlitefts5/lib -fno-common -dynamiclib src/extensions/extension-functions.c
curl -L -o src/extensions/fileio.c 'https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk'
curl -L -o src/extensions/test_windirect.c 'https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk'
curl -L -o src/extensions/test_windirect.h 'https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk'
clang -I /usr/local/opt/sqlitfts5/include -L /usr/local/opt/sqlitefts5/lib -fno-common -dynamiclib src/extensions/fileio.c src/extensions/test_windirect.c
- name: Archiving app bundle
if: github.event_name != 'pull_request'
run: ditto -c -k --sequesterRsrc --keepParent build/*.app archive.zip
- name: Upload archived app bundle
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3
with:
name: app-bundle-${{ matrix.sqlcipher }}
path: archive.zip
notarization-macos:
if: github.event_name != 'pull_request'
needs: build-macos
name: notarization (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run : |
unset HOMEBREW_NO_INSTALL_FROM_API; brew untap homebrew/core; brew untap homebrew/cask; brew update
brew tap sqlitebrowser/sqlite3
brew install qt@5 sqlitefts5 sqlcipherdb4s
brew reinstall node
brew link sqlitefts5 --force
npm install -g appdmg
- name: Download archived app bundle (SQLite)
uses: actions/download-artifact@v3
with:
name: app-bundle-0
path: archive
- name: Download archived app bundle (SQLCipher)
uses: actions/download-artifact@v3
with:
name: app-bundle-1
path: archive-sqlcipher
- name: Dearchive app bundle
run: |
ditto -x -k archive/archive.zip build/
ditto -x -k archive-sqlcipher/archive.zip build/
- name: Install the Apple certificate
env:
P12: ${{ secrets.MACOS_CODESIGN_P12 }}
P12_PW: ${{ secrets.MACOS_CODESIGN_P12_PW }}
KEYCHAIN_PW: ${{ secrets.MACOS_CODESIGN_KEYCHAIN_PW }}
run: |
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$P12" | base64 --decode -o $CERTIFICATE_PATH
security create-keychain -p "$KEYCHAIN_PW" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PW" $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P "$P12_PW" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Include the dependencies in the app bundle
env:
DEV_ID: ${{ secrets.MACOS_CODESIGN_DEV_ID}}
run: find build -name "DB Browser for SQL*.app" -exec /usr/local/opt/qt@5/bin/macdeployqt {} -sign-for-notarization="$DEV_ID" \;
- name: Add the extension to the app bundle
run: |
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
mkdir "$TARGET/Contents/Extensions"
clang -I /usr/local/opt/sqlitefts5/include -L /usr/local/opt/sqlitefts5/lib -fno-common -dynamiclib src/extensions/extension-formats.c -o "$TARGET/Contents/Extensions/formats.dylib"
clang -I /usr/local/opt/sqlitefts5/include -L /usr/local/opt/sqlitefts5/lib -fno-common -dynamiclib src/extensions/extension-functions.c -o "$TARGET/Contents/Extensions/math.dylib"
if [ -f "$TARGET/Contents/Extensions/formats.dylib" ]; then
install_name_tool -id "@executable_path/../Extensions/formats.dylib" "$TARGET/Contents/Extensions/formats.dylib"
ln -s formats.dylib "$TARGET/Contents/Extensions/formats.dylib.dylib"
fi
if [ -f "$TARGET/Contents/Extensions/math.dylib" ]; then
install_name_tool -id "@executable_path/../Extensions/math.dylib" "$TARGET/Contents/Extensions/math.dylib"
ln -s math.dylib "$TARGET/Contents/Extensions/math.dylib.dylib"
fi
curl -L -o src/extensions/fileio.c 'https://sqlite.org/src/raw?filename=ext/misc/fileio.c&ci=trunk'
curl -L -o src/extensions/test_windirect.c 'https://sqlite.org/src/raw?filename=src/test_windirent.c&ci=trunk'
curl -L -o src/extensions/test_windirect.h 'https://sqlite.org/src/raw?filename=src/test_windirent.h&ci=trunk'
clang -I /usr/local/opt/sqlitfts5/include -L /usr/local/opt/sqlitefts5/lib -fno-common -dynamiclib src/extensions/fileio.c src/extensions/test_windirect.c -o "$TARGET/Contents/Extensions/fileio.dylib"
if [ -f "$TARGET/Contents/Extensions/fileio.dylib" ]; then
install_name_tool -id "@executable_path/../Extensions/fileio.dylib" "$TARGET/Contents/Extensions/fileio.dylib"
ln -s fileio.dylib "$TARGET/Contents/Extensions/fileio.dylib.dylib"
fi
done
- name: Copy the license file to the app bundle
run: |
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
cp LICENSE "$TARGET/Contents/Resources/"
cp LICENSE-PLUGINS "$TARGET/Contents/Resources/"
done
- name: Copy the translation files to the app bundle
run: |
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
mkdir "$TARGET/Contents/translations"
for i in ar cs de en es fr it ko pl pt pt_BR ru uk zh_CN zh_TW; do
find /usr/local/opt/qt@5/translations -name "qt_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \;
find /usr/local/opt/qt@5/translations -name "qtbase_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \;
find /usr/local/opt/qt@5/translations -name "qtmultimedia_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \;
find /usr/local/opt/qt@5/translations -name "qtscript_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \;
find /usr/local/opt/qt@5/translations -name "qtxmlpatterns_${i}.qm" 2> /dev/null -exec cp -v {} "$TARGET/Contents/translations/" \;
done
done
- name: Copy the icon file to the app bundle
run: |
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
cp installer/macos/macapp.icns "$TARGET/Contents/Resources/"
/usr/libexec/PlistBuddy -c "Set :CFBundleIconFile macapp.icns" "$TARGET/Contents/Info.plist"
done
- name: Sign the manually added extensions.
env:
DEV_ID: ${{ secrets.MACOS_CODESIGN_DEV_ID}}
run: |
for TARGET in $(find build -name "DB Browser for SQL*.app" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/fileio.dylib"
codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/formats.dylib"
codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET/Contents/Extensions/math.dylib"
codesign --sign "$DEV_ID" --deep --force --options=runtime --strict --timestamp "$TARGET"
done
- name: Move app bundle to installer folder for DMG creation
run: mv build/*.app installer/macos
- name: Create the DMG
env:
DEV_ID: ${{ secrets.MACOS_CODESIGN_DEV_ID}}
run: |
sed -i "" 's/"DB Browser for SQLite Nightly.app"/"DB Browser for SQLite-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/nightly.json
TARGET="DB Browser for SQLite-dev-$(git rev-parse --short --verify HEAD).dmg"
appdmg --quiet installer/macos/nightly.json "$TARGET"
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
codesign -vvv --deep --strict --verbose=4 "$TARGET"
sed -i "" 's/"DB Browser for SQLCipher Nightly.app"/"DB Browser for SQLCipher-dev-'$(git rev-parse --short --verify HEAD)'.app"/' installer/macos/sqlcipher-nightly.json
TARGET="DB Browser for SQLCipher-dev-$(git rev-parse --short --verify HEAD).dmg"
appdmg --quiet installer/macos/sqlcipher-nightly.json "$TARGET"
codesign --sign "$DEV_ID" --verbose --options=runtime --timestamp "$TARGET"
codesign -vvv --deep --strict --verbose=4 "$TARGET"
- name: Notarize the dmg
env:
APPLE_ID: ${{ secrets.MACOS_CODESIGN_APPLE_ID }}
APPLE_PW: ${{ secrets.MACOS_CODESIGN_APPLE_PW }}
TEAM_ID: ${{ secrets.MACOS_CODESIGN_TEAM_ID }}
run: |
for TARGET in $(find . -name "DB Browser for SQL*.dmg" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
xcrun notarytool submit "$TARGET" --apple-id "$APPLE_ID" --password "$APPLE_PW" --team-id "$TEAM_ID" --wait
done
- name: Staple the notarization ticket
run: |
for TARGET in $(find . -name "DB Browser for SQL*.dmg" | sed -e 's/ /_/g'); do
TARGET=$(echo $TARGET | sed -e 's/_/ /g')
xcrun stapler staple "$TARGET"
done
- name: Archive AppBundle
run: tar -cvf appbundle.tar DB\ Browser\ for\ *.dmg
- name: Upload AppBundle
uses: actions/upload-artifact@v3
with:
name: appbundle
path: appbundle.tar
- name: Clear keychain
if: always()
run: security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
build-ubuntu:
name: build (${{ matrix.os }} - SQLCipher ${{ matrix.sqlcipher }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04]
sqlcipher: ["0", "1"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt update
sudo apt install libqcustomplot-dev libqt5scintilla2-dev libqt5svg5 libsqlcipher-dev libsqlite3-dev qttools5-dev
- name: Configure CMake
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PWD}/install \
-DCPACK_PACKAGE_DIRECTORY=${PWD}/package \
-DENABLE_TESTING=ON \
-Dsqlcipher=${{ matrix.sqlcipher }}
- name: Run make
run: cmake --build build --config Release -j --target install
- name: Run tests
run: ctest -V -C Release --test-dir build
- name: Package
run: |
cmake --build build --config Release -j --target package
cmake -E remove_directory package/_CPack_Packages
- name: Upload package
if: github.event_name == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name }}
UPLOAD_URL: ${{ github.event.release.upload_url }}
run: |
set the env var TAG:
$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/$TAG | jq -r .upload_url)
UPLOAD_URL=${UPLOAD_URL%\{*} # remove "{name,label}" suffix
for pkg in package/*.*; do
NAME=$(basename $pkg)
MIME=$(file --mime-type $pkg|cut -d ' ' -f2)
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: $MIME" --data-binary @$pkg $UPLOAD_URL?name=$NAME
done
release:
name: Release
needs: [appimage, notarization-macos]
runs-on: ubuntu-20.04
if: github.event_name != 'pull_request'
steps:
- name: Download AppBundle
uses: actions/download-artifact@v3
with:
name: appbundle
- name: Download AppImage
uses: actions/download-artifact@v3
with:
name: appimage
- name: Dearchive app bundle
run: |
mkdir target
tar -xvf appbundle.tar -C target/
tar -xvf appimage.tar -C target/
- name: Clear artifacts
if: always()
uses: geekyeggo/delete-artifact@v2
with:
name: |
app-bundle-0
app-bundle-1
appbundle
appimage
failOnError: false
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
chmod a+x upload.sh
UPLOADTOOL_ISPRERELEASE=true ./upload.sh target/*